diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-07 18:55:13 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-07 18:55:13 +0300 |
commit | 43c75c9248f3f2fe3732b263fc03d73528f005c8 (patch) | |
tree | 37257a79abe993c8d5a5a72de1116e62fcc7007c /test/run-tests.js | |
parent | 048d6906ae6f43b60cfb0c025c242743f6d2c16f (diff) | |
download | tracifyjs-43c75c9248f3f2fe3732b263fc03d73528f005c8.tar.gz tracifyjs-43c75c9248f3f2fe3732b263fc03d73528f005c8.zip |
checkpoint
Diffstat (limited to 'test/run-tests.js')
-rwxr-xr-x | test/run-tests.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/run-tests.js b/test/run-tests.js index 158c9d35..385c43f1 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -44,6 +44,13 @@ function test_directory(dir) { return path.resolve(tests_dir, dir); } +function as_toplevel(input) { + if (input instanceof U.AST_BlockStatement) input = input.body; + else if (input instanceof U.AST_StatementBase) input = [ input ]; + else throw new Error("Unsupported input syntax"); + return new U.AST_Toplevel({ body: input }); +} + function run_compress_tests() { var dir = test_directory("compress"); log_directory("compress"); @@ -53,8 +60,10 @@ function run_compress_tests() { function test_case(test) { log_test(test.name); var cmp = new U.Compressor(test.options || {}, true); - var expect = make_code(test.expect, false); - var output = make_code(test.input.squeeze(cmp), false); + var expect = make_code(as_toplevel(test.expect), false); + var input = as_toplevel(test.input); + input.figure_out_scope(); + var output = make_code(input.squeeze(cmp), false); if (expect != output) { log("!!! failed\n---INPUT---\n{input}\n---OUTPUT---\n{output}\n---EXPECTED---\n{expected}\n\n", { input: make_code(test.input), |