From 9c7c385ee8603807544738208e562c983c53dff2 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 31 Oct 2014 11:35:57 +1100 Subject: [PATCH] add generation tests from escodegen --- .../basic/bitwise-precedence/actual.js | 3 + .../basic/bitwise-precedence/expected.js | 3 + .../generation/basic/floating-point/actual.js | 2 + .../basic/floating-point/expected.js | 2 + .../generation/basic/for-in-no-in/actual.js | 12 ++++ .../generation/basic/for-in-no-in/expected.js | 12 ++++ .../generation/basic/new-precedence/actual.js | 9 +++ .../basic/new-precedence/expected.js | 9 +++ .../actual.js | 3 + .../expected.js | 4 ++ .../generation/basic/unary-op/actual.js | 5 ++ .../generation/basic/unary-op/expected.js | 5 ++ .../unnecessary-parenthesized-in-2/actual.js | 2 + .../expected.js | 2 + .../unnecessary-parenthesized-in/actual.js | 1 + .../unnecessary-parenthesized-in/expected.js | 1 + .../basic/variable-declaration/expected.js | 5 ++ .../variable-declaration.js | 4 ++ .../comment/2-space-multi-comment/actual.js | 6 ++ .../comment/2-space-multi-comment/expected.js | 6 ++ .../comment/block-line-comment/actual.js | 4 ++ .../comment/block-line-comment/expected.js | 4 ++ .../generation/comment/comment-only/actual.js | 4 ++ .../comment/comment-only/expected.js | 4 ++ .../computed-property-comments-2/actual.js | 10 ++++ .../computed-property-comments-2/expected.js | 10 ++++ .../computed-property-comments/actual.js | 28 +++++++++ .../computed-property-comments/expected.js | 19 ++++++ .../comment/do-while-line-comment/actual.js | 3 + .../comment/do-while-line-comment/expected.js | 3 + .../comment/empty-line-comment/actual.js | 5 ++ .../comment/empty-line-comment/expected.js | 4 ++ .../generation/comment/empty/actual.js | 1 + .../generation/comment/empty/expected.js | 1 + .../function-block-line-comment/actual.js | 6 ++ .../function-block-line-comment/expected.js | 12 ++++ .../comment/if-block-line-comment/actual.js | 5 ++ .../comment/if-block-line-comment/expected.js | 5 ++ .../comment/if-empty-line-comment/actual.js | 3 + .../comment/if-empty-line-comment/expected.js | 3 + .../comment/if-line-comment/actual.js | 5 ++ .../comment/if-line-comment/expected.js | 6 ++ .../comment/object_comments/actual.js | 12 ++++ .../comment/object_comments/expected.js | 12 ++++ .../comment/return-no-argument/actual.js | 3 + .../comment/return-no-argument/expected.js | 3 + .../simple-a-lot-of-line-comment/actual.js | 49 ++++++++++++++++ .../simple-a-lot-of-line-comment/expected.js | 43 ++++++++++++++ .../simple-a-lot-of-multi-comment/actual.js | 56 ++++++++++++++++++ .../simple-a-lot-of-multi-comment/expected.js | 47 +++++++++++++++ .../comment/simple-line-comment/actual.js | 3 + .../comment/simple-line-comment/expected.js | 2 + .../comment/simple-multi-comment/actual.js | 22 +++++++ .../comment/simple-multi-comment/expected.js | 18 ++++++ .../simple-statement-comment/actual.js | 1 + .../simple-statement-comment/expected.js | 1 + .../comment/try-block-line-comment/actual.js | 12 ++++ .../try-block-line-comment/expected.js | 16 +++++ .../actual.js | 9 +++ .../expected.js | 9 +++ .../actual.js | 13 +++++ .../expected.js | 13 +++++ .../actual.js | 16 +++++ .../expected.js | 17 ++++++ .../harmony/arrow-function/actual.js | 11 ++++ .../harmony/arrow-function/expected.js | 11 ++++ .../harmony/class-declaration/actual.js | 58 +++++++++++++++++++ .../harmony/class-declaration/expected.js | 46 +++++++++++++++ .../harmony/class-expression/actual.js | 57 ++++++++++++++++++ .../harmony/class-expression/expected.js | 50 ++++++++++++++++ .../harmony/computed-property/actual.js | 16 +++++ .../harmony/computed-property/expected.js | 18 ++++++ .../harmony/default-parameter/actual.js | 11 ++++ .../harmony/default-parameter/expected.js | 10 ++++ .../destructuring-assignment/actual.js | 19 ++++++ .../destructuring-assignment/expected.js | 28 +++++++++ .../export-default-declaration/actual.js | 3 + .../export-default-declaration/expected.js | 2 + .../generation/harmony/exports/actual.js | 9 +++ .../generation/harmony/exports/expected.js | 18 ++++++ .../harmony/for-of-statement/actual.js | 7 +++ .../harmony/for-of-statement/expected.js | 6 ++ .../harmony/import-with-default/actual.js | 8 +++ .../harmony/import-with-default/expected.js | 8 +++ .../generation/harmony/imports/actual.js | 8 +++ .../generation/harmony/imports/expected.js | 8 +++ .../harmony/one-assignment-property/actual.js | 5 ++ .../one-assignment-property/expected.js | 5 ++ .../harmony/spread-element/actual.js | 5 ++ .../harmony/spread-element/expected.js | 22 +++++++ .../harmony/templates-escape/actual.js | 12 ++++ .../harmony/templates-escape/expected.js | 11 ++++ .../generation/harmony/templates/actual.js | 31 ++++++++++ .../generation/harmony/templates/expected.js | 25 ++++++++ .../harmony/yield-precedence/actual.js | 7 +++ .../harmony/yield-precedence/expected.js | 7 +++ test/generation.js | 46 +++++++++++++-- 97 files changed, 1200 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/generation/basic/bitwise-precedence/actual.js create mode 100644 test/fixtures/generation/basic/bitwise-precedence/expected.js create mode 100644 test/fixtures/generation/basic/floating-point/actual.js create mode 100644 test/fixtures/generation/basic/floating-point/expected.js create mode 100644 test/fixtures/generation/basic/for-in-no-in/actual.js create mode 100644 test/fixtures/generation/basic/for-in-no-in/expected.js create mode 100644 test/fixtures/generation/basic/new-precedence/actual.js create mode 100644 test/fixtures/generation/basic/new-precedence/expected.js create mode 100644 test/fixtures/generation/basic/one-property-with-line-terminator/actual.js create mode 100644 test/fixtures/generation/basic/one-property-with-line-terminator/expected.js create mode 100644 test/fixtures/generation/basic/unary-op/actual.js create mode 100644 test/fixtures/generation/basic/unary-op/expected.js create mode 100644 test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js create mode 100644 test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js create mode 100644 test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js create mode 100644 test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js create mode 100644 test/fixtures/generation/basic/variable-declaration/expected.js create mode 100644 test/fixtures/generation/basic/variable-declaration/variable-declaration.js create mode 100644 test/fixtures/generation/comment/2-space-multi-comment/actual.js create mode 100644 test/fixtures/generation/comment/2-space-multi-comment/expected.js create mode 100644 test/fixtures/generation/comment/block-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/block-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/comment-only/actual.js create mode 100644 test/fixtures/generation/comment/comment-only/expected.js create mode 100644 test/fixtures/generation/comment/computed-property-comments-2/actual.js create mode 100644 test/fixtures/generation/comment/computed-property-comments-2/expected.js create mode 100644 test/fixtures/generation/comment/computed-property-comments/actual.js create mode 100644 test/fixtures/generation/comment/computed-property-comments/expected.js create mode 100644 test/fixtures/generation/comment/do-while-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/do-while-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/empty-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/empty-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/empty/actual.js create mode 100644 test/fixtures/generation/comment/empty/expected.js create mode 100644 test/fixtures/generation/comment/function-block-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/function-block-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/if-block-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/if-block-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/if-empty-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/if-empty-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/if-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/if-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/object_comments/actual.js create mode 100644 test/fixtures/generation/comment/object_comments/expected.js create mode 100644 test/fixtures/generation/comment/return-no-argument/actual.js create mode 100644 test/fixtures/generation/comment/return-no-argument/expected.js create mode 100644 test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js create mode 100644 test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js create mode 100644 test/fixtures/generation/comment/simple-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/simple-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/simple-multi-comment/actual.js create mode 100644 test/fixtures/generation/comment/simple-multi-comment/expected.js create mode 100644 test/fixtures/generation/comment/simple-statement-comment/actual.js create mode 100644 test/fixtures/generation/comment/simple-statement-comment/expected.js create mode 100644 test/fixtures/generation/comment/try-block-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/try-block-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/variable-declarator-line-comment/actual.js create mode 100644 test/fixtures/generation/comment/variable-declarator-line-comment/expected.js create mode 100644 test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js create mode 100644 test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js create mode 100644 test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js create mode 100644 test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js create mode 100644 test/fixtures/generation/harmony/arrow-function/actual.js create mode 100644 test/fixtures/generation/harmony/arrow-function/expected.js create mode 100644 test/fixtures/generation/harmony/class-declaration/actual.js create mode 100644 test/fixtures/generation/harmony/class-declaration/expected.js create mode 100644 test/fixtures/generation/harmony/class-expression/actual.js create mode 100644 test/fixtures/generation/harmony/class-expression/expected.js create mode 100644 test/fixtures/generation/harmony/computed-property/actual.js create mode 100644 test/fixtures/generation/harmony/computed-property/expected.js create mode 100644 test/fixtures/generation/harmony/default-parameter/actual.js create mode 100644 test/fixtures/generation/harmony/default-parameter/expected.js create mode 100644 test/fixtures/generation/harmony/destructuring-assignment/actual.js create mode 100644 test/fixtures/generation/harmony/destructuring-assignment/expected.js create mode 100644 test/fixtures/generation/harmony/export-default-declaration/actual.js create mode 100644 test/fixtures/generation/harmony/export-default-declaration/expected.js create mode 100644 test/fixtures/generation/harmony/exports/actual.js create mode 100644 test/fixtures/generation/harmony/exports/expected.js create mode 100644 test/fixtures/generation/harmony/for-of-statement/actual.js create mode 100644 test/fixtures/generation/harmony/for-of-statement/expected.js create mode 100644 test/fixtures/generation/harmony/import-with-default/actual.js create mode 100644 test/fixtures/generation/harmony/import-with-default/expected.js create mode 100644 test/fixtures/generation/harmony/imports/actual.js create mode 100644 test/fixtures/generation/harmony/imports/expected.js create mode 100644 test/fixtures/generation/harmony/one-assignment-property/actual.js create mode 100644 test/fixtures/generation/harmony/one-assignment-property/expected.js create mode 100644 test/fixtures/generation/harmony/spread-element/actual.js create mode 100644 test/fixtures/generation/harmony/spread-element/expected.js create mode 100644 test/fixtures/generation/harmony/templates-escape/actual.js create mode 100644 test/fixtures/generation/harmony/templates-escape/expected.js create mode 100644 test/fixtures/generation/harmony/templates/actual.js create mode 100644 test/fixtures/generation/harmony/templates/expected.js create mode 100644 test/fixtures/generation/harmony/yield-precedence/actual.js create mode 100644 test/fixtures/generation/harmony/yield-precedence/expected.js diff --git a/test/fixtures/generation/basic/bitwise-precedence/actual.js b/test/fixtures/generation/basic/bitwise-precedence/actual.js new file mode 100644 index 0000000000..7c6969bfc8 --- /dev/null +++ b/test/fixtures/generation/basic/bitwise-precedence/actual.js @@ -0,0 +1,3 @@ +x | y ^ z; +x | (y ^ z); +(x | y) ^ z; diff --git a/test/fixtures/generation/basic/bitwise-precedence/expected.js b/test/fixtures/generation/basic/bitwise-precedence/expected.js new file mode 100644 index 0000000000..ffcf91adde --- /dev/null +++ b/test/fixtures/generation/basic/bitwise-precedence/expected.js @@ -0,0 +1,3 @@ +x | y ^ z; +x | y ^ z; +(x | y) ^ z; diff --git a/test/fixtures/generation/basic/floating-point/actual.js b/test/fixtures/generation/basic/floating-point/actual.js new file mode 100644 index 0000000000..b38eebf513 --- /dev/null +++ b/test/fixtures/generation/basic/floating-point/actual.js @@ -0,0 +1,2 @@ +1.1.valueOf(); +(1e+300).valueOf(); diff --git a/test/fixtures/generation/basic/floating-point/expected.js b/test/fixtures/generation/basic/floating-point/expected.js new file mode 100644 index 0000000000..f0c3126dbe --- /dev/null +++ b/test/fixtures/generation/basic/floating-point/expected.js @@ -0,0 +1,2 @@ +1.1.valueOf(); +1e+300.valueOf(); diff --git a/test/fixtures/generation/basic/for-in-no-in/actual.js b/test/fixtures/generation/basic/for-in-no-in/actual.js new file mode 100644 index 0000000000..f84b95ae6b --- /dev/null +++ b/test/fixtures/generation/basic/for-in-no-in/actual.js @@ -0,0 +1,12 @@ +for (var i = (1 in []) in []); +for (var i = 1 in [] in []); +for (var i = (10 * 10 in []) in []); +for (var i = (10 + 10 in []) in []); +for (var i = 10 + (10 in []) in []); +for (var i = 10 + 10 in [] in []); +for (var i = (1 in []);;); +for ((1 in []);;); +for (1 * (1 in []);;); +for (1 * (1 + 1 in []);;); +for (1 * ((1 + 1) in []);;); +for (1 * (1 + (1 in []));;); diff --git a/test/fixtures/generation/basic/for-in-no-in/expected.js b/test/fixtures/generation/basic/for-in-no-in/expected.js new file mode 100644 index 0000000000..6aa84e89ed --- /dev/null +++ b/test/fixtures/generation/basic/for-in-no-in/expected.js @@ -0,0 +1,12 @@ +for (var i = (1 in []) in []); +for (var i = 1 in [] in []); +for (var i = (10 * 10 in []) in []); +for (var i = (10 + 10 in []) in []); +for (var i = 10 + (10 in []) in []); +for (var i = 10 + 10 in [] in []); +for (var i = (1 in []);;); +for ((1 in []);;); +for (1 * (1 in []);;); +for (1 * (1 + 1 in []);;); +for (1 * (1 + 1 in []);;); +for (1 * (1 + (1 in []));;); diff --git a/test/fixtures/generation/basic/new-precedence/actual.js b/test/fixtures/generation/basic/new-precedence/actual.js new file mode 100644 index 0000000000..56044a7b99 --- /dev/null +++ b/test/fixtures/generation/basic/new-precedence/actual.js @@ -0,0 +1,9 @@ +new (a().b)(); +new a().b(); +new (a()).b(); +new (a()); +new new a(a); +new (new a)(a); +(new a()).test; +(new a().test); +(new (a().test)); diff --git a/test/fixtures/generation/basic/new-precedence/expected.js b/test/fixtures/generation/basic/new-precedence/expected.js new file mode 100644 index 0000000000..ff626b14a2 --- /dev/null +++ b/test/fixtures/generation/basic/new-precedence/expected.js @@ -0,0 +1,9 @@ +new (a()).b(); +new a().b(); +new (a()).b(); +new (a())(); +new new a(a)(); +new new a()(a); +new a().test; +new a().test; +new (a()).test(); diff --git a/test/fixtures/generation/basic/one-property-with-line-terminator/actual.js b/test/fixtures/generation/basic/one-property-with-line-terminator/actual.js new file mode 100644 index 0000000000..af6823817f --- /dev/null +++ b/test/fixtures/generation/basic/one-property-with-line-terminator/actual.js @@ -0,0 +1,3 @@ +dejavu.Class.declare({ + method2: function () {} +}); diff --git a/test/fixtures/generation/basic/one-property-with-line-terminator/expected.js b/test/fixtures/generation/basic/one-property-with-line-terminator/expected.js new file mode 100644 index 0000000000..c076cb4d0d --- /dev/null +++ b/test/fixtures/generation/basic/one-property-with-line-terminator/expected.js @@ -0,0 +1,4 @@ +dejavu.Class.declare({ + method2: function () { + } +}); diff --git a/test/fixtures/generation/basic/unary-op/actual.js b/test/fixtures/generation/basic/unary-op/actual.js new file mode 100644 index 0000000000..9f318cdb1f --- /dev/null +++ b/test/fixtures/generation/basic/unary-op/actual.js @@ -0,0 +1,5 @@ +delete delete i; ++ +i; +!!i; ++ ++i; +- --i; diff --git a/test/fixtures/generation/basic/unary-op/expected.js b/test/fixtures/generation/basic/unary-op/expected.js new file mode 100644 index 0000000000..9f318cdb1f --- /dev/null +++ b/test/fixtures/generation/basic/unary-op/expected.js @@ -0,0 +1,5 @@ +delete delete i; ++ +i; +!!i; ++ ++i; +- --i; diff --git a/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js b/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js new file mode 100644 index 0000000000..89bd0be917 --- /dev/null +++ b/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js @@ -0,0 +1,2 @@ +var i = 1 * (2 + 0 in []); +for (var i = 1 * (2 + 0 in []) in []); diff --git a/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js b/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js new file mode 100644 index 0000000000..89bd0be917 --- /dev/null +++ b/test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js @@ -0,0 +1,2 @@ +var i = 1 * (2 + 0 in []); +for (var i = 1 * (2 + 0 in []) in []); diff --git a/test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js b/test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js new file mode 100644 index 0000000000..f9fd342e80 --- /dev/null +++ b/test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js @@ -0,0 +1 @@ +var i = 0 in ['test']; diff --git a/test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js b/test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js new file mode 100644 index 0000000000..f9fd342e80 --- /dev/null +++ b/test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js @@ -0,0 +1 @@ +var i = 0 in ['test']; diff --git a/test/fixtures/generation/basic/variable-declaration/expected.js b/test/fixtures/generation/basic/variable-declaration/expected.js new file mode 100644 index 0000000000..8341f277bf --- /dev/null +++ b/test/fixtures/generation/basic/variable-declaration/expected.js @@ -0,0 +1,5 @@ +var fact5 = function fact(n) { + if (n <= 1) + return 1; + return n * fact(n - 1); +}(5); diff --git a/test/fixtures/generation/basic/variable-declaration/variable-declaration.js b/test/fixtures/generation/basic/variable-declaration/variable-declaration.js new file mode 100644 index 0000000000..0373c49bb1 --- /dev/null +++ b/test/fixtures/generation/basic/variable-declaration/variable-declaration.js @@ -0,0 +1,4 @@ +var fact5 = function fact(n){ + if (n <= 1) return 1 + return n * fact(n - 1) +}(5) \ No newline at end of file diff --git a/test/fixtures/generation/comment/2-space-multi-comment/actual.js b/test/fixtures/generation/comment/2-space-multi-comment/actual.js new file mode 100644 index 0000000000..1cacd84afd --- /dev/null +++ b/test/fixtures/generation/comment/2-space-multi-comment/actual.js @@ -0,0 +1,6 @@ +function test() { + /* + * this is comment + */ + var i = 20; +} diff --git a/test/fixtures/generation/comment/2-space-multi-comment/expected.js b/test/fixtures/generation/comment/2-space-multi-comment/expected.js new file mode 100644 index 0000000000..0f2595c0c6 --- /dev/null +++ b/test/fixtures/generation/comment/2-space-multi-comment/expected.js @@ -0,0 +1,6 @@ +function test() { + /* + * this is comment + */ + var i = 20; +} diff --git a/test/fixtures/generation/comment/block-line-comment/actual.js b/test/fixtures/generation/comment/block-line-comment/actual.js new file mode 100644 index 0000000000..13ab7155d9 --- /dev/null +++ b/test/fixtures/generation/comment/block-line-comment/actual.js @@ -0,0 +1,4 @@ +// Leading to block +{ + print('hello'); +} diff --git a/test/fixtures/generation/comment/block-line-comment/expected.js b/test/fixtures/generation/comment/block-line-comment/expected.js new file mode 100644 index 0000000000..fc0f85872d --- /dev/null +++ b/test/fixtures/generation/comment/block-line-comment/expected.js @@ -0,0 +1,4 @@ +// Leading to block +{ + print('hello'); +} diff --git a/test/fixtures/generation/comment/comment-only/actual.js b/test/fixtures/generation/comment/comment-only/actual.js new file mode 100644 index 0000000000..acfb1b9a7b --- /dev/null +++ b/test/fixtures/generation/comment/comment-only/actual.js @@ -0,0 +1,4 @@ +// from #23 +/**/ +/* +*/ diff --git a/test/fixtures/generation/comment/comment-only/expected.js b/test/fixtures/generation/comment/comment-only/expected.js new file mode 100644 index 0000000000..acfb1b9a7b --- /dev/null +++ b/test/fixtures/generation/comment/comment-only/expected.js @@ -0,0 +1,4 @@ +// from #23 +/**/ +/* +*/ diff --git a/test/fixtures/generation/comment/computed-property-comments-2/actual.js b/test/fixtures/generation/comment/computed-property-comments-2/actual.js new file mode 100644 index 0000000000..00728f8c47 --- /dev/null +++ b/test/fixtures/generation/comment/computed-property-comments-2/actual.js @@ -0,0 +1,10 @@ +var test = { + /** + * Before bracket init + */ + ['a']:'1', + [/* + * Inside bracket init + */ + 'b']:'2' + }, ok = 42; diff --git a/test/fixtures/generation/comment/computed-property-comments-2/expected.js b/test/fixtures/generation/comment/computed-property-comments-2/expected.js new file mode 100644 index 0000000000..05464111c0 --- /dev/null +++ b/test/fixtures/generation/comment/computed-property-comments-2/expected.js @@ -0,0 +1,10 @@ +var test = { + /** + * Before bracket init + */ + ['a']: '1', + [/* + * Inside bracket init + */ + 'b']: '2' + }, ok = 42; diff --git a/test/fixtures/generation/comment/computed-property-comments/actual.js b/test/fixtures/generation/comment/computed-property-comments/actual.js new file mode 100644 index 0000000000..16cdc21615 --- /dev/null +++ b/test/fixtures/generation/comment/computed-property-comments/actual.js @@ -0,0 +1,28 @@ +var test = { + /** + * Before bracket init + */ + ['a']:'1', + + [/* + * Inside bracket init + */ + 'b']:'2', + + ['c' + /* + * After bracket key + */]:'3', + + // Before bracket, line comment + [ + 'd']:'4', + + [ + // Inside bracket, line comment + 'e']:'5', + + ['f' + // After bracket, line comment + ]:'6' +}; diff --git a/test/fixtures/generation/comment/computed-property-comments/expected.js b/test/fixtures/generation/comment/computed-property-comments/expected.js new file mode 100644 index 0000000000..042316fe50 --- /dev/null +++ b/test/fixtures/generation/comment/computed-property-comments/expected.js @@ -0,0 +1,19 @@ +var test = { + /** + * Before bracket init + */ + ['a']: '1', + [/* + * Inside bracket init + */ + 'b']: '2', + ['c' /* + * After bracket key + */]: '3', + // Before bracket, line comment + ['d']: '4', + [// Inside bracket, line comment + 'e']: '5', + ['f' // After bracket, line comment +]: '6' +}; diff --git a/test/fixtures/generation/comment/do-while-line-comment/actual.js b/test/fixtures/generation/comment/do-while-line-comment/actual.js new file mode 100644 index 0000000000..760ae4934e --- /dev/null +++ b/test/fixtures/generation/comment/do-while-line-comment/actual.js @@ -0,0 +1,3 @@ +do { +} // LINE +while (true); diff --git a/test/fixtures/generation/comment/do-while-line-comment/expected.js b/test/fixtures/generation/comment/do-while-line-comment/expected.js new file mode 100644 index 0000000000..9a53a86255 --- /dev/null +++ b/test/fixtures/generation/comment/do-while-line-comment/expected.js @@ -0,0 +1,3 @@ +do { +} // LINE +while (true); diff --git a/test/fixtures/generation/comment/empty-line-comment/actual.js b/test/fixtures/generation/comment/empty-line-comment/actual.js new file mode 100644 index 0000000000..e1e6ea6456 --- /dev/null +++ b/test/fixtures/generation/comment/empty-line-comment/actual.js @@ -0,0 +1,5 @@ +function test() { +// Leading to EmptyStatement +; + // Trailing to EmptyStatement +} diff --git a/test/fixtures/generation/comment/empty-line-comment/expected.js b/test/fixtures/generation/comment/empty-line-comment/expected.js new file mode 100644 index 0000000000..61517f7ff4 --- /dev/null +++ b/test/fixtures/generation/comment/empty-line-comment/expected.js @@ -0,0 +1,4 @@ +function test() { + // Leading to EmptyStatement + ; // Trailing to EmptyStatement +} diff --git a/test/fixtures/generation/comment/empty/actual.js b/test/fixtures/generation/comment/empty/actual.js new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test/fixtures/generation/comment/empty/actual.js @@ -0,0 +1 @@ + diff --git a/test/fixtures/generation/comment/empty/expected.js b/test/fixtures/generation/comment/empty/expected.js new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test/fixtures/generation/comment/empty/expected.js @@ -0,0 +1 @@ + diff --git a/test/fixtures/generation/comment/function-block-line-comment/actual.js b/test/fixtures/generation/comment/function-block-line-comment/actual.js new file mode 100644 index 0000000000..105b25217c --- /dev/null +++ b/test/fixtures/generation/comment/function-block-line-comment/actual.js @@ -0,0 +1,6 @@ +!function(){}// +,42; +!{get 42(){}// +,foo:42}; +(function(){}// +) diff --git a/test/fixtures/generation/comment/function-block-line-comment/expected.js b/test/fixtures/generation/comment/function-block-line-comment/expected.js new file mode 100644 index 0000000000..fba319cf72 --- /dev/null +++ b/test/fixtures/generation/comment/function-block-line-comment/expected.js @@ -0,0 +1,12 @@ +!function () { +} // +, 42; +!{ + get 42() { + } // +, + foo: 42 +}; +(function () { +} // +); diff --git a/test/fixtures/generation/comment/if-block-line-comment/actual.js b/test/fixtures/generation/comment/if-block-line-comment/actual.js new file mode 100644 index 0000000000..4042e28fe9 --- /dev/null +++ b/test/fixtures/generation/comment/if-block-line-comment/actual.js @@ -0,0 +1,5 @@ +if (cond) + // Leading to if-block +{ + print('hello'); +} // Trailing to if-block diff --git a/test/fixtures/generation/comment/if-block-line-comment/expected.js b/test/fixtures/generation/comment/if-block-line-comment/expected.js new file mode 100644 index 0000000000..5ae7a6e03b --- /dev/null +++ b/test/fixtures/generation/comment/if-block-line-comment/expected.js @@ -0,0 +1,5 @@ +if (cond) + // Leading to if-block + { + print('hello'); + } // Trailing to if-block diff --git a/test/fixtures/generation/comment/if-empty-line-comment/actual.js b/test/fixtures/generation/comment/if-empty-line-comment/actual.js new file mode 100644 index 0000000000..f606377c22 --- /dev/null +++ b/test/fixtures/generation/comment/if-empty-line-comment/actual.js @@ -0,0 +1,3 @@ +if (cond) +// Leading to EmptyStatement + ; // Trailing to EmptyStatement diff --git a/test/fixtures/generation/comment/if-empty-line-comment/expected.js b/test/fixtures/generation/comment/if-empty-line-comment/expected.js new file mode 100644 index 0000000000..43c56bdf03 --- /dev/null +++ b/test/fixtures/generation/comment/if-empty-line-comment/expected.js @@ -0,0 +1,3 @@ +if (cond) + // Leading to EmptyStatement + ; // Trailing to EmptyStatement diff --git a/test/fixtures/generation/comment/if-line-comment/actual.js b/test/fixtures/generation/comment/if-line-comment/actual.js new file mode 100644 index 0000000000..b56aa0619b --- /dev/null +++ b/test/fixtures/generation/comment/if-line-comment/actual.js @@ -0,0 +1,5 @@ +function test() { +// Leading if statement + if (cond) {print('hello') } +// Trailing if-block statement +} diff --git a/test/fixtures/generation/comment/if-line-comment/expected.js b/test/fixtures/generation/comment/if-line-comment/expected.js new file mode 100644 index 0000000000..895f8b6d1e --- /dev/null +++ b/test/fixtures/generation/comment/if-line-comment/expected.js @@ -0,0 +1,6 @@ +function test() { + // Leading if statement + if (cond) { + print('hello'); + } // Trailing if-block statement +} diff --git a/test/fixtures/generation/comment/object_comments/actual.js b/test/fixtures/generation/comment/object_comments/actual.js new file mode 100644 index 0000000000..4a929ef100 --- /dev/null +++ b/test/fixtures/generation/comment/object_comments/actual.js @@ -0,0 +1,12 @@ +var test = { + /** + * Test 2 + */ + a:'1', + /* + * Test 1 + */ + b:'2', + // Test 3 + c:'3' +}; \ No newline at end of file diff --git a/test/fixtures/generation/comment/object_comments/expected.js b/test/fixtures/generation/comment/object_comments/expected.js new file mode 100644 index 0000000000..2c62424076 --- /dev/null +++ b/test/fixtures/generation/comment/object_comments/expected.js @@ -0,0 +1,12 @@ +var test = { + /** + * Test 2 + */ + a: '1', + /* + * Test 1 + */ + b: '2', + // Test 3 + c: '3' +}; diff --git a/test/fixtures/generation/comment/return-no-argument/actual.js b/test/fixtures/generation/comment/return-no-argument/actual.js new file mode 100644 index 0000000000..1255bd1a4d --- /dev/null +++ b/test/fixtures/generation/comment/return-no-argument/actual.js @@ -0,0 +1,3 @@ +(function() { + return; // comment +}()); diff --git a/test/fixtures/generation/comment/return-no-argument/expected.js b/test/fixtures/generation/comment/return-no-argument/expected.js new file mode 100644 index 0000000000..c0a518d8a2 --- /dev/null +++ b/test/fixtures/generation/comment/return-no-argument/expected.js @@ -0,0 +1,3 @@ +(function () { + return; // comment +}()); diff --git a/test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js b/test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js new file mode 100644 index 0000000000..624df7d6b1 --- /dev/null +++ b/test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js @@ -0,0 +1,49 @@ +// Copyright (C) 2012 Yusuke Suzuki +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +function test() { +} + + + +// Copyright (C) 2012 Yusuke Suzuki +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js b/test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js new file mode 100644 index 0000000000..b47dba555d --- /dev/null +++ b/test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js @@ -0,0 +1,43 @@ +// Copyright (C) 2012 Yusuke Suzuki +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +function test() { +} // Copyright (C) 2012 Yusuke Suzuki + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are met: + // + // * Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // * Redistributions in binary form must reproduce the above copyright + // notice, this list of conditions and the following disclaimer in the + // documentation and/or other materials provided with the distribution. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + // ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js b/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js new file mode 100644 index 0000000000..a99018660b --- /dev/null +++ b/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js @@ -0,0 +1,56 @@ +/* + Copyright (C) 2012 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + + + +function test() { } + + + + + +/* + Copyright (C) 2012 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ diff --git a/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js b/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js new file mode 100644 index 0000000000..cae689a223 --- /dev/null +++ b/test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js @@ -0,0 +1,47 @@ +/* + Copyright (C) 2012 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +function test() { +} /* + Copyright (C) 2012 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/test/fixtures/generation/comment/simple-line-comment/actual.js b/test/fixtures/generation/comment/simple-line-comment/actual.js new file mode 100644 index 0000000000..780a9c2b4a --- /dev/null +++ b/test/fixtures/generation/comment/simple-line-comment/actual.js @@ -0,0 +1,3 @@ +// Leading +var i = 20; +// Trailing diff --git a/test/fixtures/generation/comment/simple-line-comment/expected.js b/test/fixtures/generation/comment/simple-line-comment/expected.js new file mode 100644 index 0000000000..7422cfa501 --- /dev/null +++ b/test/fixtures/generation/comment/simple-line-comment/expected.js @@ -0,0 +1,2 @@ +// Leading +var i = 20; // Trailing diff --git a/test/fixtures/generation/comment/simple-multi-comment/actual.js b/test/fixtures/generation/comment/simple-multi-comment/actual.js new file mode 100644 index 0000000000..9bb712d345 --- /dev/null +++ b/test/fixtures/generation/comment/simple-multi-comment/actual.js @@ -0,0 +1,22 @@ +function test() { + /* + * Leading comment + */ + + /* + * + * Leading comment 2 + * + */ + + var i = 20; + /* + * Trailing comment + */ + + /* + * + * Trailing comment 2 + * + */ +} diff --git a/test/fixtures/generation/comment/simple-multi-comment/expected.js b/test/fixtures/generation/comment/simple-multi-comment/expected.js new file mode 100644 index 0000000000..1b1c848281 --- /dev/null +++ b/test/fixtures/generation/comment/simple-multi-comment/expected.js @@ -0,0 +1,18 @@ +function test() { + /* + * Leading comment + */ + /* + * + * Leading comment 2 + * + */ + var i = 20; /* + * Trailing comment + */ + /* + * + * Trailing comment 2 + * + */ +} diff --git a/test/fixtures/generation/comment/simple-statement-comment/actual.js b/test/fixtures/generation/comment/simple-statement-comment/actual.js new file mode 100644 index 0000000000..fb4f32e7e2 --- /dev/null +++ b/test/fixtures/generation/comment/simple-statement-comment/actual.js @@ -0,0 +1 @@ +; // Trailing diff --git a/test/fixtures/generation/comment/simple-statement-comment/expected.js b/test/fixtures/generation/comment/simple-statement-comment/expected.js new file mode 100644 index 0000000000..fb4f32e7e2 --- /dev/null +++ b/test/fixtures/generation/comment/simple-statement-comment/expected.js @@ -0,0 +1 @@ +; // Trailing diff --git a/test/fixtures/generation/comment/try-block-line-comment/actual.js b/test/fixtures/generation/comment/try-block-line-comment/actual.js new file mode 100644 index 0000000000..2ef66cdb71 --- /dev/null +++ b/test/fixtures/generation/comment/try-block-line-comment/actual.js @@ -0,0 +1,12 @@ +try{}// +finally{} + +try{} +catch(e){}// +finally{} + +{ +try{} +catch(e){}// +finally{} +} diff --git a/test/fixtures/generation/comment/try-block-line-comment/expected.js b/test/fixtures/generation/comment/try-block-line-comment/expected.js new file mode 100644 index 0000000000..726ada5b00 --- /dev/null +++ b/test/fixtures/generation/comment/try-block-line-comment/expected.js @@ -0,0 +1,16 @@ +try { +} // +finally { +} +try { +} catch (e) { +} // +finally { +} +{ + try { + } catch (e) { + } // + finally { + } +} diff --git a/test/fixtures/generation/comment/variable-declarator-line-comment/actual.js b/test/fixtures/generation/comment/variable-declarator-line-comment/actual.js new file mode 100644 index 0000000000..7178dcf22e --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-line-comment/actual.js @@ -0,0 +1,9 @@ +function test() { + var + // Leading to VariableDeclarator + // Leading to VariableDeclarator + i = 20, + // Leading to VariableDeclarator + // Leading to VariableDeclarator + j = 20; +} diff --git a/test/fixtures/generation/comment/variable-declarator-line-comment/expected.js b/test/fixtures/generation/comment/variable-declarator-line-comment/expected.js new file mode 100644 index 0000000000..7178dcf22e --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-line-comment/expected.js @@ -0,0 +1,9 @@ +function test() { + var + // Leading to VariableDeclarator + // Leading to VariableDeclarator + i = 20, + // Leading to VariableDeclarator + // Leading to VariableDeclarator + j = 20; +} diff --git a/test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js b/test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js new file mode 100644 index 0000000000..a2377ce8bc --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js @@ -0,0 +1,13 @@ +function test() { + var + /* + * Leading to VariableDeclarator + * Leading to VariableDeclarator + */ + i = 20, + /* + * Leading to VariableDeclarator + * Leading to VariableDeclarator + */ + j = 20; +} diff --git a/test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js b/test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js new file mode 100644 index 0000000000..a2377ce8bc --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js @@ -0,0 +1,13 @@ +function test() { + var + /* + * Leading to VariableDeclarator + * Leading to VariableDeclarator + */ + i = 20, + /* + * Leading to VariableDeclarator + * Leading to VariableDeclarator + */ + j = 20; +} diff --git a/test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js b/test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js new file mode 100644 index 0000000000..c6e758e308 --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js @@ -0,0 +1,16 @@ +{ + var t = 20; /* + * This is trailing comment + */ +} + +{ + var tt = 20; /* + * This is trailing comment + */ +} +{{ + var t = 20; /* + * This is trailing comment + */ +}} diff --git a/test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js b/test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js new file mode 100644 index 0000000000..8933885443 --- /dev/null +++ b/test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js @@ -0,0 +1,17 @@ +{ + var t = 20; /* + * This is trailing comment + */ +} +{ + var tt = 20; /* + * This is trailing comment + */ +} +{ + { + var t = 20; /* + * This is trailing comment + */ + } +} diff --git a/test/fixtures/generation/harmony/arrow-function/actual.js b/test/fixtures/generation/harmony/arrow-function/actual.js new file mode 100644 index 0000000000..dee9149778 --- /dev/null +++ b/test/fixtures/generation/harmony/arrow-function/actual.js @@ -0,0 +1,11 @@ +e => { + print('hello world'); +}; +(e1, e2, e3) => { + print('hello world'); +}; +e => e; +(e1, e2, e3) => e; +(e) => { +}; +e => 20 + 20 diff --git a/test/fixtures/generation/harmony/arrow-function/expected.js b/test/fixtures/generation/harmony/arrow-function/expected.js new file mode 100644 index 0000000000..de012ae894 --- /dev/null +++ b/test/fixtures/generation/harmony/arrow-function/expected.js @@ -0,0 +1,11 @@ +e => { + print('hello world'); +}; +(e1, e2, e3) => { + print('hello world'); +}; +e => e; +(e1, e2, e3) => e; +e => { +}; +e => 20 + 20; diff --git a/test/fixtures/generation/harmony/class-declaration/actual.js b/test/fixtures/generation/harmony/class-declaration/actual.js new file mode 100644 index 0000000000..ee610d0d87 --- /dev/null +++ b/test/fixtures/generation/harmony/class-declaration/actual.js @@ -0,0 +1,58 @@ +class Test { +} +class Derived extends Super { +} +class Derived2 extends Super() { +} +class StaticMethods { + static n1() { + } + + static get get1() { + } + + static set set1(value) { + } + + static *gen1() { + } +} +class Methods { + n2() { + } + + get get2() { + } + + set set2(value) { + } + + *gen1() { + } +} +class ComputedStaticMethods { + static [n1]() { + } + + static get [get1]() { + } + + static set [set1](value) { + } + + static *[gen1]() { + } +} +class ComputedMethods { + [n2]() { + } + + get [get2]() { + } + + set [set2](value) { + } + + *[gen1]() { + } +} diff --git a/test/fixtures/generation/harmony/class-declaration/expected.js b/test/fixtures/generation/harmony/class-declaration/expected.js new file mode 100644 index 0000000000..1f5cb50318 --- /dev/null +++ b/test/fixtures/generation/harmony/class-declaration/expected.js @@ -0,0 +1,46 @@ +class Test { +} +class Derived extends Super { +} +class Derived2 extends Super() { +} +class StaticMethods { + static n1() { + } + static get get1() { + } + static set set1(value) { + } + static *gen1() { + } +} +class Methods { + n2() { + } + get get2() { + } + set set2(value) { + } + *gen1() { + } +} +class ComputedStaticMethods { + static n1() { + } + static get get1() { + } + static set set1(value) { + } + static *gen1() { + } +} +class ComputedMethods { + n2() { + } + get get2() { + } + set set2(value) { + } + *gen1() { + } +} diff --git a/test/fixtures/generation/harmony/class-expression/actual.js b/test/fixtures/generation/harmony/class-expression/actual.js new file mode 100644 index 0000000000..0f669c2f51 --- /dev/null +++ b/test/fixtures/generation/harmony/class-expression/actual.js @@ -0,0 +1,57 @@ +(class Test { }); +(class Derived extends Super { }); +(class Derived2 extends Super() { }); +(class StaticMethods { + static n1() { + } + + static get get1() { + } + + static set set1(value) { + } + + static *gen1() { + } +}); +(class Methods { + n2() { + } + + get get2() { + } + + set set2(value) { + } + + *gen1() { + } +}); +(class ComputedStaticMethods { + static [n1]() { + } + + static get [get1]() { + } + + static set [set1](value) { + } + + static *[gen1]() { + } +}); +(class ComputedMethods { + [n2]() { + } + + get [get2]() { + } + + set [set2](value) { + } + + *[gen1]() { + } +}); +(class { }); +(class extends Super() { }); diff --git a/test/fixtures/generation/harmony/class-expression/expected.js b/test/fixtures/generation/harmony/class-expression/expected.js new file mode 100644 index 0000000000..a22730f84a --- /dev/null +++ b/test/fixtures/generation/harmony/class-expression/expected.js @@ -0,0 +1,50 @@ +(class Test { +}); +(class Derived extends Super { +}); +(class Derived2 extends Super() { +}); +(class StaticMethods { + static n1() { + } + static get get1() { + } + static set set1(value) { + } + static *gen1() { + } +}); +(class Methods { + n2() { + } + get get2() { + } + set set2(value) { + } + *gen1() { + } +}); +(class ComputedStaticMethods { + static n1() { + } + static get get1() { + } + static set set1(value) { + } + static *gen1() { + } +}); +(class ComputedMethods { + n2() { + } + get get2() { + } + set set2(value) { + } + *gen1() { + } +}); +(class { +}); +(class extends Super() { +}); diff --git a/test/fixtures/generation/harmony/computed-property/actual.js b/test/fixtures/generation/harmony/computed-property/actual.js new file mode 100644 index 0000000000..308549f694 --- /dev/null +++ b/test/fixtures/generation/harmony/computed-property/actual.js @@ -0,0 +1,16 @@ +var object1 = { + // MethodDefinition + get [Symbol.create]() { }, + set [set()](value) { }, +}; +var object2 = { + *[generator()]() { } +}; +var object3 = { + *[generator()]() { } +}; +var object4 = { + // Normal Property + [Symbol.xxx]: 'hello', + [ok()]: 42, +}; diff --git a/test/fixtures/generation/harmony/computed-property/expected.js b/test/fixtures/generation/harmony/computed-property/expected.js new file mode 100644 index 0000000000..4900da494d --- /dev/null +++ b/test/fixtures/generation/harmony/computed-property/expected.js @@ -0,0 +1,18 @@ +var object1 = { + get [Symbol.create]() { + }, + set [set()](value) { + } +}; +var object2 = { + *[generator()]() { + } +}; +var object3 = { + *[generator()]() { + } +}; +var object4 = { + [Symbol.xxx]: 'hello', + [ok()]: 42 +}; diff --git a/test/fixtures/generation/harmony/default-parameter/actual.js b/test/fixtures/generation/harmony/default-parameter/actual.js new file mode 100644 index 0000000000..aa61f5ec66 --- /dev/null +++ b/test/fixtures/generation/harmony/default-parameter/actual.js @@ -0,0 +1,11 @@ +function a(p=20) { +} + +function b(p, q=30) { +} + +function c(p, q=30, ...r) { +} + +(p = 20) => { }; +(p = 20, ...q) => { }; diff --git a/test/fixtures/generation/harmony/default-parameter/expected.js b/test/fixtures/generation/harmony/default-parameter/expected.js new file mode 100644 index 0000000000..2953cbb3e6 --- /dev/null +++ b/test/fixtures/generation/harmony/default-parameter/expected.js @@ -0,0 +1,10 @@ +function a(p = 20) { +} +function b(p, q = 30) { +} +function c(p, q = 30, ...r) { +} +(p = 20) => { +}; +(p = 20, ...q) => { +}; diff --git a/test/fixtures/generation/harmony/destructuring-assignment/actual.js b/test/fixtures/generation/harmony/destructuring-assignment/actual.js new file mode 100644 index 0000000000..76ca7c66e0 --- /dev/null +++ b/test/fixtures/generation/harmony/destructuring-assignment/actual.js @@ -0,0 +1,19 @@ +function t1({responseText: responseText}) { +} +function t2({responseText}) { +} +function t3([a, b]) { +} +var [i, j, k] = array; +var {i, j, k} = obj; +let {i, j, k} = obj; +const {i, j, k} = obj; +var { + value +} = obj; +var { + value +} = obj; +var [obj.hello] = prop; +var [obj.hello, ...obj.ok] = prop; +var [obj.hello, ...obj['hello']] = prop; diff --git a/test/fixtures/generation/harmony/destructuring-assignment/expected.js b/test/fixtures/generation/harmony/destructuring-assignment/expected.js new file mode 100644 index 0000000000..227c366b1e --- /dev/null +++ b/test/fixtures/generation/harmony/destructuring-assignment/expected.js @@ -0,0 +1,28 @@ +function t1({responseText: responseText}) { +} +function t2({responseText}) { +} +function t3([ + a, + b +]) { +} +var [ + i, + j, + k +] = array; +var {i, j, k} = obj; +let {i, j, k} = obj; +const {i, j, k} = obj; +var {value} = obj; +var {value} = obj; +var [obj.hello] = prop; +var [ + obj.hello, + ...obj.ok +] = prop; +var [ + obj.hello, + ...obj['hello'] +] = prop; diff --git a/test/fixtures/generation/harmony/export-default-declaration/actual.js b/test/fixtures/generation/harmony/export-default-declaration/actual.js new file mode 100644 index 0000000000..5ef9d4be11 --- /dev/null +++ b/test/fixtures/generation/harmony/export-default-declaration/actual.js @@ -0,0 +1,3 @@ +export default function a () { } +// export default var i = 20; +// export default const K = 20; diff --git a/test/fixtures/generation/harmony/export-default-declaration/expected.js b/test/fixtures/generation/harmony/export-default-declaration/expected.js new file mode 100644 index 0000000000..2010202854 --- /dev/null +++ b/test/fixtures/generation/harmony/export-default-declaration/expected.js @@ -0,0 +1,2 @@ +export default function a() { +} diff --git a/test/fixtures/generation/harmony/exports/actual.js b/test/fixtures/generation/harmony/exports/actual.js new file mode 100644 index 0000000000..d76fe5a8ad --- /dev/null +++ b/test/fixtures/generation/harmony/exports/actual.js @@ -0,0 +1,9 @@ +export * from "OK" +export { name } from "OK" +export { a as b, c as d } from "hello" +export { a as b, c as d } +export { } +export default i = 20 +export function test() { } +export var i = 20 +export let i = 42 diff --git a/test/fixtures/generation/harmony/exports/expected.js b/test/fixtures/generation/harmony/exports/expected.js new file mode 100644 index 0000000000..e85a78edcc --- /dev/null +++ b/test/fixtures/generation/harmony/exports/expected.js @@ -0,0 +1,18 @@ +export * from 'OK'; +export { + name +} from 'OK'; +export { + a as b, + c as d +} from 'hello'; +export { + a as b, + c as d +}; +export { }; +export default i = 20; +export function test() { +} +export var i = 20; +export let i = 42; diff --git a/test/fixtures/generation/harmony/for-of-statement/actual.js b/test/fixtures/generation/harmony/for-of-statement/actual.js new file mode 100644 index 0000000000..10a0e580ca --- /dev/null +++ b/test/fixtures/generation/harmony/for-of-statement/actual.js @@ -0,0 +1,7 @@ +function test() { + for (var i of array) { + } + + for (let i of array) { + } +} diff --git a/test/fixtures/generation/harmony/for-of-statement/expected.js b/test/fixtures/generation/harmony/for-of-statement/expected.js new file mode 100644 index 0000000000..5101c94413 --- /dev/null +++ b/test/fixtures/generation/harmony/for-of-statement/expected.js @@ -0,0 +1,6 @@ +function test() { + for (var i of array) { + } + for (let i of array) { + } +} diff --git a/test/fixtures/generation/harmony/import-with-default/actual.js b/test/fixtures/generation/harmony/import-with-default/actual.js new file mode 100644 index 0000000000..5e55c4ff0c --- /dev/null +++ b/test/fixtures/generation/harmony/import-with-default/actual.js @@ -0,0 +1,8 @@ +import foo from 'foo'; +import foo, * as foo from 'foo'; +import * as foo from 'foo'; +import ok, { + foo as bar, + test as testing, + logging +} from 'foo'; diff --git a/test/fixtures/generation/harmony/import-with-default/expected.js b/test/fixtures/generation/harmony/import-with-default/expected.js new file mode 100644 index 0000000000..5e55c4ff0c --- /dev/null +++ b/test/fixtures/generation/harmony/import-with-default/expected.js @@ -0,0 +1,8 @@ +import foo from 'foo'; +import foo, * as foo from 'foo'; +import * as foo from 'foo'; +import ok, { + foo as bar, + test as testing, + logging +} from 'foo'; diff --git a/test/fixtures/generation/harmony/imports/actual.js b/test/fixtures/generation/harmony/imports/actual.js new file mode 100644 index 0000000000..04c7f62f94 --- /dev/null +++ b/test/fixtures/generation/harmony/imports/actual.js @@ -0,0 +1,8 @@ +import 'foo'; +import {foo} from 'foo'; +import {foo as bar} from 'foo'; +import { + foo as bar, + test as testing, + logging +} from 'foo'; diff --git a/test/fixtures/generation/harmony/imports/expected.js b/test/fixtures/generation/harmony/imports/expected.js new file mode 100644 index 0000000000..b7803897b9 --- /dev/null +++ b/test/fixtures/generation/harmony/imports/expected.js @@ -0,0 +1,8 @@ +import 'foo'; +import { foo } from 'foo'; +import { foo as bar } from 'foo'; +import { + foo as bar, + test as testing, + logging +} from 'foo'; diff --git a/test/fixtures/generation/harmony/one-assignment-property/actual.js b/test/fixtures/generation/harmony/one-assignment-property/actual.js new file mode 100644 index 0000000000..7ae3d19f05 --- /dev/null +++ b/test/fixtures/generation/harmony/one-assignment-property/actual.js @@ -0,0 +1,5 @@ +({ t: t }) = obj; +({ + t: { C: C } +}) = obj; +({ a, b, c }) = obj; diff --git a/test/fixtures/generation/harmony/one-assignment-property/expected.js b/test/fixtures/generation/harmony/one-assignment-property/expected.js new file mode 100644 index 0000000000..a6fb3f0385 --- /dev/null +++ b/test/fixtures/generation/harmony/one-assignment-property/expected.js @@ -0,0 +1,5 @@ +({t: t} = obj); +({ + t: {C: C} +} = obj); +({a, b, c} = obj); diff --git a/test/fixtures/generation/harmony/spread-element/actual.js b/test/fixtures/generation/harmony/spread-element/actual.js new file mode 100644 index 0000000000..56d6b3b87c --- /dev/null +++ b/test/fixtures/generation/harmony/spread-element/actual.js @@ -0,0 +1,5 @@ +var [a, b, ...rest] = array; +const [a, b, ...rest] = array; +function a([a, b, ...rest]) { +} +([a, b, ...rest]) => { }; diff --git a/test/fixtures/generation/harmony/spread-element/expected.js b/test/fixtures/generation/harmony/spread-element/expected.js new file mode 100644 index 0000000000..48a01abd03 --- /dev/null +++ b/test/fixtures/generation/harmony/spread-element/expected.js @@ -0,0 +1,22 @@ +var [ + a, + b, + ...rest +] = array; +const [ + a, + b, + ...rest +] = array; +function a([ + a, + b, + ...rest +]) { +} +([ + a, + b, + ...rest +]) => { +}; diff --git a/test/fixtures/generation/harmony/templates-escape/actual.js b/test/fixtures/generation/harmony/templates-escape/actual.js new file mode 100644 index 0000000000..5d8a96d54f --- /dev/null +++ b/test/fixtures/generation/harmony/templates-escape/actual.js @@ -0,0 +1,12 @@ +var escaped = ` +\u2028 +\u2029 +`; + +var escaped = ` +\v +\b +\t +\n +\r +`; diff --git a/test/fixtures/generation/harmony/templates-escape/expected.js b/test/fixtures/generation/harmony/templates-escape/expected.js new file mode 100644 index 0000000000..cf5574d59d --- /dev/null +++ b/test/fixtures/generation/harmony/templates-escape/expected.js @@ -0,0 +1,11 @@ +var escaped = ` +\u2028 +\u2029 +`; +var escaped = ` +\v +\b +\t +\n +\r +`; diff --git a/test/fixtures/generation/harmony/templates/actual.js b/test/fixtures/generation/harmony/templates/actual.js new file mode 100644 index 0000000000..2ddb2ec9f1 --- /dev/null +++ b/test/fixtures/generation/harmony/templates/actual.js @@ -0,0 +1,31 @@ +var hello = `hello`; + +var hello = ` +line +terminators`; + +var tagged = tagged`hello`; +var tagged = member.call`hello`; +var tagged = new call`hello`(); +var tagged = new (call`hello`()); +var tageed = member[call`hello`]; + +var middles = ` +Is the order a rabbit? +`; + +var middles = ` +Is the order ${ order }? +`; + +var middles = ` +Is the order ${ order }? +`; + +var middles = ` +1. ${ cocoa } +2. ${ chino } +3. ${ rize } +4. ${ syaro } +5. ${ chiya } +`; diff --git a/test/fixtures/generation/harmony/templates/expected.js b/test/fixtures/generation/harmony/templates/expected.js new file mode 100644 index 0000000000..f8739f0175 --- /dev/null +++ b/test/fixtures/generation/harmony/templates/expected.js @@ -0,0 +1,25 @@ +var hello = `hello`; +var hello = ` +line +terminators`; +var tagged = tagged`hello`; +var tagged = member.call`hello`; +var tagged = new call`hello`(); +var tagged = new (call`hello`())(); +var tageed = member[call`hello`]; +var middles = ` +Is the order a rabbit? +`; +var middles = ` +Is the order ${ order }? +`; +var middles = ` +Is the order ${ order }? +`; +var middles = ` +1. ${ cocoa } +2. ${ chino } +3. ${ rize } +4. ${ syaro } +5. ${ chiya } +`; diff --git a/test/fixtures/generation/harmony/yield-precedence/actual.js b/test/fixtures/generation/harmony/yield-precedence/actual.js new file mode 100644 index 0000000000..c5cd08ca3a --- /dev/null +++ b/test/fixtures/generation/harmony/yield-precedence/actual.js @@ -0,0 +1,7 @@ +function *foo () { + var a = yield wat(), b = 2; + var c = yield a = b; + yield a, yield b; + yield a = b; + return (yield 1) || (yield 2); +} diff --git a/test/fixtures/generation/harmony/yield-precedence/expected.js b/test/fixtures/generation/harmony/yield-precedence/expected.js new file mode 100644 index 0000000000..9f0af3c0f0 --- /dev/null +++ b/test/fixtures/generation/harmony/yield-precedence/expected.js @@ -0,0 +1,7 @@ +function* foo() { + var a = yield wat(), b = 2; + var c = yield a = b; + yield a, yield b; + yield a = b; + return (yield 1) || (yield 2); +} diff --git a/test/generation.js b/test/generation.js index 60dc9a6a40..a902446847 100644 --- a/test/generation.js +++ b/test/generation.js @@ -1,17 +1,51 @@ -var CodeGenerator = require("../lib/6to5/generator").CodeGenerator; -var traverse = require("../lib/6to5/traverse"); -var assert = require("assert"); -var _ = require("lodash"); +var generate = require("../lib/6to5/generator"); +var traverse = require("../lib/6to5/traverse"); +var assert = require("assert"); +var util = require("../lib/6to5/util"); +var fs = require("fs"); +var _ = require("lodash"); + +var fixturesLoc = __dirname + "/fixtures/generation"; suite("generation", function () { test("completeness", function () { _.each(traverse.VISITOR_KEYS, function (keys, type) { - assert.ok(!!CodeGenerator.prototype[type], type + " should exist"); + assert.ok(!!generate.CodeGenerator.prototype[type], type + " should exist"); }); - _.each(CodeGenerator.prototype, function (fn, type) { + _.each(generate.CodeGenerator.prototype, function (fn, type) { if (!/[A-Z]/.test(type[0])) return; assert.ok(traverse.VISITOR_KEYS[type], type + " should not exist"); }); }); + + _.each(fs.readdirSync(fixturesLoc), function (suiteName) { + if (suiteName[0] === ".") return; + + var suiteLoc = fixturesLoc + "/" + suiteName; + + suite(suiteName, function () { + _.each(fs.readdirSync(suiteLoc), function (testName) { + if (testName[0] === ".") return; + + var testLoc = suiteLoc + "/" + testName; + + test(testName, function () { + var expectedLoc = testLoc + "/expected.js"; + var actualLoc = testLoc + "/actual.js"; + + var expected = fs.readFileSync(expectedLoc, "utf8"); + var actual = fs.readFileSync(actualLoc, "utf8"); + + var actualAst = util.parseNoProperties(actualLoc, actual); + actual = generate(actualAst).code; + actualAst = util.parseNoProperties(actualLoc, actual); + + var expectedAst = util.parseNoProperties(expectedLoc, expected); + + assert.deepEqual(actualAst, expectedAst); + }); + }); + }); + }); });