add generation tests from escodegen
This commit is contained in:
3
test/fixtures/generation/basic/bitwise-precedence/actual.js
vendored
Normal file
3
test/fixtures/generation/basic/bitwise-precedence/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
x | y ^ z;
|
||||
x | (y ^ z);
|
||||
(x | y) ^ z;
|
||||
3
test/fixtures/generation/basic/bitwise-precedence/expected.js
vendored
Normal file
3
test/fixtures/generation/basic/bitwise-precedence/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
x | y ^ z;
|
||||
x | y ^ z;
|
||||
(x | y) ^ z;
|
||||
2
test/fixtures/generation/basic/floating-point/actual.js
vendored
Normal file
2
test/fixtures/generation/basic/floating-point/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
1.1.valueOf();
|
||||
(1e+300).valueOf();
|
||||
2
test/fixtures/generation/basic/floating-point/expected.js
vendored
Normal file
2
test/fixtures/generation/basic/floating-point/expected.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
1.1.valueOf();
|
||||
1e+300.valueOf();
|
||||
12
test/fixtures/generation/basic/for-in-no-in/actual.js
vendored
Normal file
12
test/fixtures/generation/basic/for-in-no-in/actual.js
vendored
Normal file
@@ -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 []));;);
|
||||
12
test/fixtures/generation/basic/for-in-no-in/expected.js
vendored
Normal file
12
test/fixtures/generation/basic/for-in-no-in/expected.js
vendored
Normal file
@@ -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 []));;);
|
||||
9
test/fixtures/generation/basic/new-precedence/actual.js
vendored
Normal file
9
test/fixtures/generation/basic/new-precedence/actual.js
vendored
Normal file
@@ -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));
|
||||
9
test/fixtures/generation/basic/new-precedence/expected.js
vendored
Normal file
9
test/fixtures/generation/basic/new-precedence/expected.js
vendored
Normal file
@@ -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();
|
||||
3
test/fixtures/generation/basic/one-property-with-line-terminator/actual.js
vendored
Normal file
3
test/fixtures/generation/basic/one-property-with-line-terminator/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
dejavu.Class.declare({
|
||||
method2: function () {}
|
||||
});
|
||||
4
test/fixtures/generation/basic/one-property-with-line-terminator/expected.js
vendored
Normal file
4
test/fixtures/generation/basic/one-property-with-line-terminator/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
dejavu.Class.declare({
|
||||
method2: function () {
|
||||
}
|
||||
});
|
||||
5
test/fixtures/generation/basic/unary-op/actual.js
vendored
Normal file
5
test/fixtures/generation/basic/unary-op/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
delete delete i;
|
||||
+ +i;
|
||||
!!i;
|
||||
+ ++i;
|
||||
- --i;
|
||||
5
test/fixtures/generation/basic/unary-op/expected.js
vendored
Normal file
5
test/fixtures/generation/basic/unary-op/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
delete delete i;
|
||||
+ +i;
|
||||
!!i;
|
||||
+ ++i;
|
||||
- --i;
|
||||
2
test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js
vendored
Normal file
2
test/fixtures/generation/basic/unnecessary-parenthesized-in-2/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var i = 1 * (2 + 0 in []);
|
||||
for (var i = 1 * (2 + 0 in []) in []);
|
||||
2
test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js
vendored
Normal file
2
test/fixtures/generation/basic/unnecessary-parenthesized-in-2/expected.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var i = 1 * (2 + 0 in []);
|
||||
for (var i = 1 * (2 + 0 in []) in []);
|
||||
1
test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js
vendored
Normal file
1
test/fixtures/generation/basic/unnecessary-parenthesized-in/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var i = 0 in ['test'];
|
||||
1
test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js
vendored
Normal file
1
test/fixtures/generation/basic/unnecessary-parenthesized-in/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var i = 0 in ['test'];
|
||||
5
test/fixtures/generation/basic/variable-declaration/expected.js
vendored
Normal file
5
test/fixtures/generation/basic/variable-declaration/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var fact5 = function fact(n) {
|
||||
if (n <= 1)
|
||||
return 1;
|
||||
return n * fact(n - 1);
|
||||
}(5);
|
||||
4
test/fixtures/generation/basic/variable-declaration/variable-declaration.js
vendored
Normal file
4
test/fixtures/generation/basic/variable-declaration/variable-declaration.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var fact5 = function fact(n){
|
||||
if (n <= 1) return 1
|
||||
return n * fact(n - 1)
|
||||
}(5)
|
||||
6
test/fixtures/generation/comment/2-space-multi-comment/actual.js
vendored
Normal file
6
test/fixtures/generation/comment/2-space-multi-comment/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function test() {
|
||||
/*
|
||||
* this is comment
|
||||
*/
|
||||
var i = 20;
|
||||
}
|
||||
6
test/fixtures/generation/comment/2-space-multi-comment/expected.js
vendored
Normal file
6
test/fixtures/generation/comment/2-space-multi-comment/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function test() {
|
||||
/*
|
||||
* this is comment
|
||||
*/
|
||||
var i = 20;
|
||||
}
|
||||
4
test/fixtures/generation/comment/block-line-comment/actual.js
vendored
Normal file
4
test/fixtures/generation/comment/block-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// Leading to block
|
||||
{
|
||||
print('hello');
|
||||
}
|
||||
4
test/fixtures/generation/comment/block-line-comment/expected.js
vendored
Normal file
4
test/fixtures/generation/comment/block-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// Leading to block
|
||||
{
|
||||
print('hello');
|
||||
}
|
||||
4
test/fixtures/generation/comment/comment-only/actual.js
vendored
Normal file
4
test/fixtures/generation/comment/comment-only/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// from #23
|
||||
/**/
|
||||
/*
|
||||
*/
|
||||
4
test/fixtures/generation/comment/comment-only/expected.js
vendored
Normal file
4
test/fixtures/generation/comment/comment-only/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// from #23
|
||||
/**/
|
||||
/*
|
||||
*/
|
||||
10
test/fixtures/generation/comment/computed-property-comments-2/actual.js
vendored
Normal file
10
test/fixtures/generation/comment/computed-property-comments-2/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var test = {
|
||||
/**
|
||||
* Before bracket init
|
||||
*/
|
||||
['a']:'1',
|
||||
[/*
|
||||
* Inside bracket init
|
||||
*/
|
||||
'b']:'2'
|
||||
}, ok = 42;
|
||||
10
test/fixtures/generation/comment/computed-property-comments-2/expected.js
vendored
Normal file
10
test/fixtures/generation/comment/computed-property-comments-2/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var test = {
|
||||
/**
|
||||
* Before bracket init
|
||||
*/
|
||||
['a']: '1',
|
||||
[/*
|
||||
* Inside bracket init
|
||||
*/
|
||||
'b']: '2'
|
||||
}, ok = 42;
|
||||
28
test/fixtures/generation/comment/computed-property-comments/actual.js
vendored
Normal file
28
test/fixtures/generation/comment/computed-property-comments/actual.js
vendored
Normal file
@@ -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'
|
||||
};
|
||||
19
test/fixtures/generation/comment/computed-property-comments/expected.js
vendored
Normal file
19
test/fixtures/generation/comment/computed-property-comments/expected.js
vendored
Normal file
@@ -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'
|
||||
};
|
||||
3
test/fixtures/generation/comment/do-while-line-comment/actual.js
vendored
Normal file
3
test/fixtures/generation/comment/do-while-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
do {
|
||||
} // LINE
|
||||
while (true);
|
||||
3
test/fixtures/generation/comment/do-while-line-comment/expected.js
vendored
Normal file
3
test/fixtures/generation/comment/do-while-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
do {
|
||||
} // LINE
|
||||
while (true);
|
||||
5
test/fixtures/generation/comment/empty-line-comment/actual.js
vendored
Normal file
5
test/fixtures/generation/comment/empty-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function test() {
|
||||
// Leading to EmptyStatement
|
||||
;
|
||||
// Trailing to EmptyStatement
|
||||
}
|
||||
4
test/fixtures/generation/comment/empty-line-comment/expected.js
vendored
Normal file
4
test/fixtures/generation/comment/empty-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
function test() {
|
||||
// Leading to EmptyStatement
|
||||
; // Trailing to EmptyStatement
|
||||
}
|
||||
1
test/fixtures/generation/comment/empty/actual.js
vendored
Normal file
1
test/fixtures/generation/comment/empty/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
test/fixtures/generation/comment/empty/expected.js
vendored
Normal file
1
test/fixtures/generation/comment/empty/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
6
test/fixtures/generation/comment/function-block-line-comment/actual.js
vendored
Normal file
6
test/fixtures/generation/comment/function-block-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
!function(){}//
|
||||
,42;
|
||||
!{get 42(){}//
|
||||
,foo:42};
|
||||
(function(){}//
|
||||
)
|
||||
12
test/fixtures/generation/comment/function-block-line-comment/expected.js
vendored
Normal file
12
test/fixtures/generation/comment/function-block-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
!function () {
|
||||
} //
|
||||
, 42;
|
||||
!{
|
||||
get 42() {
|
||||
} //
|
||||
,
|
||||
foo: 42
|
||||
};
|
||||
(function () {
|
||||
} //
|
||||
);
|
||||
5
test/fixtures/generation/comment/if-block-line-comment/actual.js
vendored
Normal file
5
test/fixtures/generation/comment/if-block-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
if (cond)
|
||||
// Leading to if-block
|
||||
{
|
||||
print('hello');
|
||||
} // Trailing to if-block
|
||||
5
test/fixtures/generation/comment/if-block-line-comment/expected.js
vendored
Normal file
5
test/fixtures/generation/comment/if-block-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
if (cond)
|
||||
// Leading to if-block
|
||||
{
|
||||
print('hello');
|
||||
} // Trailing to if-block
|
||||
3
test/fixtures/generation/comment/if-empty-line-comment/actual.js
vendored
Normal file
3
test/fixtures/generation/comment/if-empty-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
if (cond)
|
||||
// Leading to EmptyStatement
|
||||
; // Trailing to EmptyStatement
|
||||
3
test/fixtures/generation/comment/if-empty-line-comment/expected.js
vendored
Normal file
3
test/fixtures/generation/comment/if-empty-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
if (cond)
|
||||
// Leading to EmptyStatement
|
||||
; // Trailing to EmptyStatement
|
||||
5
test/fixtures/generation/comment/if-line-comment/actual.js
vendored
Normal file
5
test/fixtures/generation/comment/if-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function test() {
|
||||
// Leading if statement
|
||||
if (cond) {print('hello') }
|
||||
// Trailing if-block statement
|
||||
}
|
||||
6
test/fixtures/generation/comment/if-line-comment/expected.js
vendored
Normal file
6
test/fixtures/generation/comment/if-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function test() {
|
||||
// Leading if statement
|
||||
if (cond) {
|
||||
print('hello');
|
||||
} // Trailing if-block statement
|
||||
}
|
||||
12
test/fixtures/generation/comment/object_comments/actual.js
vendored
Normal file
12
test/fixtures/generation/comment/object_comments/actual.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var test = {
|
||||
/**
|
||||
* Test 2
|
||||
*/
|
||||
a:'1',
|
||||
/*
|
||||
* Test 1
|
||||
*/
|
||||
b:'2',
|
||||
// Test 3
|
||||
c:'3'
|
||||
};
|
||||
12
test/fixtures/generation/comment/object_comments/expected.js
vendored
Normal file
12
test/fixtures/generation/comment/object_comments/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var test = {
|
||||
/**
|
||||
* Test 2
|
||||
*/
|
||||
a: '1',
|
||||
/*
|
||||
* Test 1
|
||||
*/
|
||||
b: '2',
|
||||
// Test 3
|
||||
c: '3'
|
||||
};
|
||||
3
test/fixtures/generation/comment/return-no-argument/actual.js
vendored
Normal file
3
test/fixtures/generation/comment/return-no-argument/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(function() {
|
||||
return; // comment
|
||||
}());
|
||||
3
test/fixtures/generation/comment/return-no-argument/expected.js
vendored
Normal file
3
test/fixtures/generation/comment/return-no-argument/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(function () {
|
||||
return; // comment
|
||||
}());
|
||||
49
test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js
vendored
Normal file
49
test/fixtures/generation/comment/simple-a-lot-of-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
//
|
||||
// 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 <COPYRIGHT HOLDER> 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 <utatane.tea@gmail.com>
|
||||
//
|
||||
// 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 <COPYRIGHT HOLDER> 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.
|
||||
43
test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js
vendored
Normal file
43
test/fixtures/generation/comment/simple-a-lot-of-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
//
|
||||
// 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 <COPYRIGHT HOLDER> 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 <utatane.tea@gmail.com>
|
||||
//
|
||||
// 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 <COPYRIGHT HOLDER> 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.
|
||||
56
test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js
vendored
Normal file
56
test/fixtures/generation/comment/simple-a-lot-of-multi-comment/actual.js
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
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 <COPYRIGHT HOLDER> 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 <utatane.tea@gmail.com>
|
||||
|
||||
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 <COPYRIGHT HOLDER> 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.
|
||||
*/
|
||||
47
test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js
vendored
Normal file
47
test/fixtures/generation/comment/simple-a-lot-of-multi-comment/expected.js
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
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 <COPYRIGHT HOLDER> 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 <utatane.tea@gmail.com>
|
||||
|
||||
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 <COPYRIGHT HOLDER> 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.
|
||||
*/
|
||||
3
test/fixtures/generation/comment/simple-line-comment/actual.js
vendored
Normal file
3
test/fixtures/generation/comment/simple-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// Leading
|
||||
var i = 20;
|
||||
// Trailing
|
||||
2
test/fixtures/generation/comment/simple-line-comment/expected.js
vendored
Normal file
2
test/fixtures/generation/comment/simple-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// Leading
|
||||
var i = 20; // Trailing
|
||||
22
test/fixtures/generation/comment/simple-multi-comment/actual.js
vendored
Normal file
22
test/fixtures/generation/comment/simple-multi-comment/actual.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
function test() {
|
||||
/*
|
||||
* Leading comment
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Leading comment 2
|
||||
*
|
||||
*/
|
||||
|
||||
var i = 20;
|
||||
/*
|
||||
* Trailing comment
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Trailing comment 2
|
||||
*
|
||||
*/
|
||||
}
|
||||
18
test/fixtures/generation/comment/simple-multi-comment/expected.js
vendored
Normal file
18
test/fixtures/generation/comment/simple-multi-comment/expected.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
function test() {
|
||||
/*
|
||||
* Leading comment
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Leading comment 2
|
||||
*
|
||||
*/
|
||||
var i = 20; /*
|
||||
* Trailing comment
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Trailing comment 2
|
||||
*
|
||||
*/
|
||||
}
|
||||
1
test/fixtures/generation/comment/simple-statement-comment/actual.js
vendored
Normal file
1
test/fixtures/generation/comment/simple-statement-comment/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
; // Trailing
|
||||
1
test/fixtures/generation/comment/simple-statement-comment/expected.js
vendored
Normal file
1
test/fixtures/generation/comment/simple-statement-comment/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
; // Trailing
|
||||
12
test/fixtures/generation/comment/try-block-line-comment/actual.js
vendored
Normal file
12
test/fixtures/generation/comment/try-block-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
try{}//
|
||||
finally{}
|
||||
|
||||
try{}
|
||||
catch(e){}//
|
||||
finally{}
|
||||
|
||||
{
|
||||
try{}
|
||||
catch(e){}//
|
||||
finally{}
|
||||
}
|
||||
16
test/fixtures/generation/comment/try-block-line-comment/expected.js
vendored
Normal file
16
test/fixtures/generation/comment/try-block-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
try {
|
||||
} //
|
||||
finally {
|
||||
}
|
||||
try {
|
||||
} catch (e) {
|
||||
} //
|
||||
finally {
|
||||
}
|
||||
{
|
||||
try {
|
||||
} catch (e) {
|
||||
} //
|
||||
finally {
|
||||
}
|
||||
}
|
||||
9
test/fixtures/generation/comment/variable-declarator-line-comment/actual.js
vendored
Normal file
9
test/fixtures/generation/comment/variable-declarator-line-comment/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
function test() {
|
||||
var
|
||||
// Leading to VariableDeclarator
|
||||
// Leading to VariableDeclarator
|
||||
i = 20,
|
||||
// Leading to VariableDeclarator
|
||||
// Leading to VariableDeclarator
|
||||
j = 20;
|
||||
}
|
||||
9
test/fixtures/generation/comment/variable-declarator-line-comment/expected.js
vendored
Normal file
9
test/fixtures/generation/comment/variable-declarator-line-comment/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
function test() {
|
||||
var
|
||||
// Leading to VariableDeclarator
|
||||
// Leading to VariableDeclarator
|
||||
i = 20,
|
||||
// Leading to VariableDeclarator
|
||||
// Leading to VariableDeclarator
|
||||
j = 20;
|
||||
}
|
||||
13
test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js
vendored
Normal file
13
test/fixtures/generation/comment/variable-declarator-multi-comment/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
function test() {
|
||||
var
|
||||
/*
|
||||
* Leading to VariableDeclarator
|
||||
* Leading to VariableDeclarator
|
||||
*/
|
||||
i = 20,
|
||||
/*
|
||||
* Leading to VariableDeclarator
|
||||
* Leading to VariableDeclarator
|
||||
*/
|
||||
j = 20;
|
||||
}
|
||||
13
test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js
vendored
Normal file
13
test/fixtures/generation/comment/variable-declarator-multi-comment/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
function test() {
|
||||
var
|
||||
/*
|
||||
* Leading to VariableDeclarator
|
||||
* Leading to VariableDeclarator
|
||||
*/
|
||||
i = 20,
|
||||
/*
|
||||
* Leading to VariableDeclarator
|
||||
* Leading to VariableDeclarator
|
||||
*/
|
||||
j = 20;
|
||||
}
|
||||
16
test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js
vendored
Normal file
16
test/fixtures/generation/comment/variable-declarator-trailing-comment/actual.js
vendored
Normal file
@@ -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
|
||||
*/
|
||||
}}
|
||||
17
test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js
vendored
Normal file
17
test/fixtures/generation/comment/variable-declarator-trailing-comment/expected.js
vendored
Normal file
@@ -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
|
||||
*/
|
||||
}
|
||||
}
|
||||
11
test/fixtures/generation/harmony/arrow-function/actual.js
vendored
Normal file
11
test/fixtures/generation/harmony/arrow-function/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
e => {
|
||||
print('hello world');
|
||||
};
|
||||
(e1, e2, e3) => {
|
||||
print('hello world');
|
||||
};
|
||||
e => e;
|
||||
(e1, e2, e3) => e;
|
||||
(e) => {
|
||||
};
|
||||
e => 20 + 20
|
||||
11
test/fixtures/generation/harmony/arrow-function/expected.js
vendored
Normal file
11
test/fixtures/generation/harmony/arrow-function/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
e => {
|
||||
print('hello world');
|
||||
};
|
||||
(e1, e2, e3) => {
|
||||
print('hello world');
|
||||
};
|
||||
e => e;
|
||||
(e1, e2, e3) => e;
|
||||
e => {
|
||||
};
|
||||
e => 20 + 20;
|
||||
58
test/fixtures/generation/harmony/class-declaration/actual.js
vendored
Normal file
58
test/fixtures/generation/harmony/class-declaration/actual.js
vendored
Normal file
@@ -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]() {
|
||||
}
|
||||
}
|
||||
46
test/fixtures/generation/harmony/class-declaration/expected.js
vendored
Normal file
46
test/fixtures/generation/harmony/class-declaration/expected.js
vendored
Normal file
@@ -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() {
|
||||
}
|
||||
}
|
||||
57
test/fixtures/generation/harmony/class-expression/actual.js
vendored
Normal file
57
test/fixtures/generation/harmony/class-expression/actual.js
vendored
Normal file
@@ -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() { });
|
||||
50
test/fixtures/generation/harmony/class-expression/expected.js
vendored
Normal file
50
test/fixtures/generation/harmony/class-expression/expected.js
vendored
Normal file
@@ -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() {
|
||||
});
|
||||
16
test/fixtures/generation/harmony/computed-property/actual.js
vendored
Normal file
16
test/fixtures/generation/harmony/computed-property/actual.js
vendored
Normal file
@@ -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,
|
||||
};
|
||||
18
test/fixtures/generation/harmony/computed-property/expected.js
vendored
Normal file
18
test/fixtures/generation/harmony/computed-property/expected.js
vendored
Normal file
@@ -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
|
||||
};
|
||||
11
test/fixtures/generation/harmony/default-parameter/actual.js
vendored
Normal file
11
test/fixtures/generation/harmony/default-parameter/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
function a(p=20) {
|
||||
}
|
||||
|
||||
function b(p, q=30) {
|
||||
}
|
||||
|
||||
function c(p, q=30, ...r) {
|
||||
}
|
||||
|
||||
(p = 20) => { };
|
||||
(p = 20, ...q) => { };
|
||||
10
test/fixtures/generation/harmony/default-parameter/expected.js
vendored
Normal file
10
test/fixtures/generation/harmony/default-parameter/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
function a(p = 20) {
|
||||
}
|
||||
function b(p, q = 30) {
|
||||
}
|
||||
function c(p, q = 30, ...r) {
|
||||
}
|
||||
(p = 20) => {
|
||||
};
|
||||
(p = 20, ...q) => {
|
||||
};
|
||||
19
test/fixtures/generation/harmony/destructuring-assignment/actual.js
vendored
Normal file
19
test/fixtures/generation/harmony/destructuring-assignment/actual.js
vendored
Normal file
@@ -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;
|
||||
28
test/fixtures/generation/harmony/destructuring-assignment/expected.js
vendored
Normal file
28
test/fixtures/generation/harmony/destructuring-assignment/expected.js
vendored
Normal file
@@ -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;
|
||||
3
test/fixtures/generation/harmony/export-default-declaration/actual.js
vendored
Normal file
3
test/fixtures/generation/harmony/export-default-declaration/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function a () { }
|
||||
// export default var i = 20;
|
||||
// export default const K = 20;
|
||||
2
test/fixtures/generation/harmony/export-default-declaration/expected.js
vendored
Normal file
2
test/fixtures/generation/harmony/export-default-declaration/expected.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function a() {
|
||||
}
|
||||
9
test/fixtures/generation/harmony/exports/actual.js
vendored
Normal file
9
test/fixtures/generation/harmony/exports/actual.js
vendored
Normal file
@@ -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
|
||||
18
test/fixtures/generation/harmony/exports/expected.js
vendored
Normal file
18
test/fixtures/generation/harmony/exports/expected.js
vendored
Normal file
@@ -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;
|
||||
7
test/fixtures/generation/harmony/for-of-statement/actual.js
vendored
Normal file
7
test/fixtures/generation/harmony/for-of-statement/actual.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
function test() {
|
||||
for (var i of array) {
|
||||
}
|
||||
|
||||
for (let i of array) {
|
||||
}
|
||||
}
|
||||
6
test/fixtures/generation/harmony/for-of-statement/expected.js
vendored
Normal file
6
test/fixtures/generation/harmony/for-of-statement/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function test() {
|
||||
for (var i of array) {
|
||||
}
|
||||
for (let i of array) {
|
||||
}
|
||||
}
|
||||
8
test/fixtures/generation/harmony/import-with-default/actual.js
vendored
Normal file
8
test/fixtures/generation/harmony/import-with-default/actual.js
vendored
Normal file
@@ -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';
|
||||
8
test/fixtures/generation/harmony/import-with-default/expected.js
vendored
Normal file
8
test/fixtures/generation/harmony/import-with-default/expected.js
vendored
Normal file
@@ -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';
|
||||
8
test/fixtures/generation/harmony/imports/actual.js
vendored
Normal file
8
test/fixtures/generation/harmony/imports/actual.js
vendored
Normal file
@@ -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';
|
||||
8
test/fixtures/generation/harmony/imports/expected.js
vendored
Normal file
8
test/fixtures/generation/harmony/imports/expected.js
vendored
Normal file
@@ -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';
|
||||
5
test/fixtures/generation/harmony/one-assignment-property/actual.js
vendored
Normal file
5
test/fixtures/generation/harmony/one-assignment-property/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
({ t: t }) = obj;
|
||||
({
|
||||
t: { C: C }
|
||||
}) = obj;
|
||||
({ a, b, c }) = obj;
|
||||
5
test/fixtures/generation/harmony/one-assignment-property/expected.js
vendored
Normal file
5
test/fixtures/generation/harmony/one-assignment-property/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
({t: t} = obj);
|
||||
({
|
||||
t: {C: C}
|
||||
} = obj);
|
||||
({a, b, c} = obj);
|
||||
5
test/fixtures/generation/harmony/spread-element/actual.js
vendored
Normal file
5
test/fixtures/generation/harmony/spread-element/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var [a, b, ...rest] = array;
|
||||
const [a, b, ...rest] = array;
|
||||
function a([a, b, ...rest]) {
|
||||
}
|
||||
([a, b, ...rest]) => { };
|
||||
22
test/fixtures/generation/harmony/spread-element/expected.js
vendored
Normal file
22
test/fixtures/generation/harmony/spread-element/expected.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var [
|
||||
a,
|
||||
b,
|
||||
...rest
|
||||
] = array;
|
||||
const [
|
||||
a,
|
||||
b,
|
||||
...rest
|
||||
] = array;
|
||||
function a([
|
||||
a,
|
||||
b,
|
||||
...rest
|
||||
]) {
|
||||
}
|
||||
([
|
||||
a,
|
||||
b,
|
||||
...rest
|
||||
]) => {
|
||||
};
|
||||
12
test/fixtures/generation/harmony/templates-escape/actual.js
vendored
Normal file
12
test/fixtures/generation/harmony/templates-escape/actual.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var escaped = `
|
||||
\u2028
|
||||
\u2029
|
||||
`;
|
||||
|
||||
var escaped = `
|
||||
\v
|
||||
\b
|
||||
\t
|
||||
\n
|
||||
\r
|
||||
`;
|
||||
11
test/fixtures/generation/harmony/templates-escape/expected.js
vendored
Normal file
11
test/fixtures/generation/harmony/templates-escape/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var escaped = `
|
||||
\u2028
|
||||
\u2029
|
||||
`;
|
||||
var escaped = `
|
||||
\v
|
||||
\b
|
||||
\t
|
||||
\n
|
||||
\r
|
||||
`;
|
||||
31
test/fixtures/generation/harmony/templates/actual.js
vendored
Normal file
31
test/fixtures/generation/harmony/templates/actual.js
vendored
Normal file
@@ -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 }
|
||||
`;
|
||||
25
test/fixtures/generation/harmony/templates/expected.js
vendored
Normal file
25
test/fixtures/generation/harmony/templates/expected.js
vendored
Normal file
@@ -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 }
|
||||
`;
|
||||
7
test/fixtures/generation/harmony/yield-precedence/actual.js
vendored
Normal file
7
test/fixtures/generation/harmony/yield-precedence/actual.js
vendored
Normal file
@@ -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);
|
||||
}
|
||||
7
test/fixtures/generation/harmony/yield-precedence/expected.js
vendored
Normal file
7
test/fixtures/generation/harmony/yield-precedence/expected.js
vendored
Normal file
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user