add generation tests from escodegen

This commit is contained in:
Sebastian McKenzie
2014-10-31 11:35:57 +11:00
parent 7c84af2ba8
commit 9c7c385ee8
97 changed files with 1200 additions and 6 deletions

View File

@@ -0,0 +1,3 @@
x | y ^ z;
x | (y ^ z);
(x | y) ^ z;

View File

@@ -0,0 +1,3 @@
x | y ^ z;
x | y ^ z;
(x | y) ^ z;

View File

@@ -0,0 +1,2 @@
1.1.valueOf();
(1e+300).valueOf();

View File

@@ -0,0 +1,2 @@
1.1.valueOf();
1e+300.valueOf();

View 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 []));;);

View 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 []));;);

View 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));

View 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();

View File

@@ -0,0 +1,3 @@
dejavu.Class.declare({
method2: function () {}
});

View File

@@ -0,0 +1,4 @@
dejavu.Class.declare({
method2: function () {
}
});

View File

@@ -0,0 +1,5 @@
delete delete i;
+ +i;
!!i;
+ ++i;
- --i;

View File

@@ -0,0 +1,5 @@
delete delete i;
+ +i;
!!i;
+ ++i;
- --i;

View File

@@ -0,0 +1,2 @@
var i = 1 * (2 + 0 in []);
for (var i = 1 * (2 + 0 in []) in []);

View File

@@ -0,0 +1,2 @@
var i = 1 * (2 + 0 in []);
for (var i = 1 * (2 + 0 in []) in []);

View File

@@ -0,0 +1 @@
var i = 0 in ['test'];

View File

@@ -0,0 +1 @@
var i = 0 in ['test'];

View File

@@ -0,0 +1,5 @@
var fact5 = function fact(n) {
if (n <= 1)
return 1;
return n * fact(n - 1);
}(5);

View File

@@ -0,0 +1,4 @@
var fact5 = function fact(n){
if (n <= 1) return 1
return n * fact(n - 1)
}(5)

View File

@@ -0,0 +1,6 @@
function test() {
/*
* this is comment
*/
var i = 20;
}

View File

@@ -0,0 +1,6 @@
function test() {
/*
* this is comment
*/
var i = 20;
}

View File

@@ -0,0 +1,4 @@
// Leading to block
{
print('hello');
}

View File

@@ -0,0 +1,4 @@
// Leading to block
{
print('hello');
}

View File

@@ -0,0 +1,4 @@
// from #23
/**/
/*
*/

View File

@@ -0,0 +1,4 @@
// from #23
/**/
/*
*/

View File

@@ -0,0 +1,10 @@
var test = {
/**
* Before bracket init
*/
['a']:'1',
[/*
* Inside bracket init
*/
'b']:'2'
}, ok = 42;

View File

@@ -0,0 +1,10 @@
var test = {
/**
* Before bracket init
*/
['a']: '1',
[/*
* Inside bracket init
*/
'b']: '2'
}, ok = 42;

View 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'
};

View 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'
};

View File

@@ -0,0 +1,3 @@
do {
} // LINE
while (true);

View File

@@ -0,0 +1,3 @@
do {
} // LINE
while (true);

View File

@@ -0,0 +1,5 @@
function test() {
// Leading to EmptyStatement
;
// Trailing to EmptyStatement
}

View File

@@ -0,0 +1,4 @@
function test() {
// Leading to EmptyStatement
; // Trailing to EmptyStatement
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,6 @@
!function(){}//
,42;
!{get 42(){}//
,foo:42};
(function(){}//
)

View File

@@ -0,0 +1,12 @@
!function () {
} //
, 42;
!{
get 42() {
} //
,
foo: 42
};
(function () {
} //
);

View File

@@ -0,0 +1,5 @@
if (cond)
// Leading to if-block
{
print('hello');
} // Trailing to if-block

View File

@@ -0,0 +1,5 @@
if (cond)
// Leading to if-block
{
print('hello');
} // Trailing to if-block

View File

@@ -0,0 +1,3 @@
if (cond)
// Leading to EmptyStatement
; // Trailing to EmptyStatement

View File

@@ -0,0 +1,3 @@
if (cond)
// Leading to EmptyStatement
; // Trailing to EmptyStatement

View File

@@ -0,0 +1,5 @@
function test() {
// Leading if statement
if (cond) {print('hello') }
// Trailing if-block statement
}

View File

@@ -0,0 +1,6 @@
function test() {
// Leading if statement
if (cond) {
print('hello');
} // Trailing if-block statement
}

View File

@@ -0,0 +1,12 @@
var test = {
/**
* Test 2
*/
a:'1',
/*
* Test 1
*/
b:'2',
// Test 3
c:'3'
};

View File

@@ -0,0 +1,12 @@
var test = {
/**
* Test 2
*/
a: '1',
/*
* Test 1
*/
b: '2',
// Test 3
c: '3'
};

View File

@@ -0,0 +1,3 @@
(function() {
return; // comment
}());

View File

@@ -0,0 +1,3 @@
(function () {
return; // comment
}());

View 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.

View 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.

View 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.
*/

View 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.
*/

View File

@@ -0,0 +1,3 @@
// Leading
var i = 20;
// Trailing

View File

@@ -0,0 +1,2 @@
// Leading
var i = 20; // Trailing

View File

@@ -0,0 +1,22 @@
function test() {
/*
* Leading comment
*/
/*
*
* Leading comment 2
*
*/
var i = 20;
/*
* Trailing comment
*/
/*
*
* Trailing comment 2
*
*/
}

View File

@@ -0,0 +1,18 @@
function test() {
/*
* Leading comment
*/
/*
*
* Leading comment 2
*
*/
var i = 20; /*
* Trailing comment
*/
/*
*
* Trailing comment 2
*
*/
}

View File

@@ -0,0 +1 @@
; // Trailing

View File

@@ -0,0 +1 @@
; // Trailing

View File

@@ -0,0 +1,12 @@
try{}//
finally{}
try{}
catch(e){}//
finally{}
{
try{}
catch(e){}//
finally{}
}

View File

@@ -0,0 +1,16 @@
try {
} //
finally {
}
try {
} catch (e) {
} //
finally {
}
{
try {
} catch (e) {
} //
finally {
}
}

View File

@@ -0,0 +1,9 @@
function test() {
var
// Leading to VariableDeclarator
// Leading to VariableDeclarator
i = 20,
// Leading to VariableDeclarator
// Leading to VariableDeclarator
j = 20;
}

View File

@@ -0,0 +1,9 @@
function test() {
var
// Leading to VariableDeclarator
// Leading to VariableDeclarator
i = 20,
// Leading to VariableDeclarator
// Leading to VariableDeclarator
j = 20;
}

View File

@@ -0,0 +1,13 @@
function test() {
var
/*
* Leading to VariableDeclarator
* Leading to VariableDeclarator
*/
i = 20,
/*
* Leading to VariableDeclarator
* Leading to VariableDeclarator
*/
j = 20;
}

View File

@@ -0,0 +1,13 @@
function test() {
var
/*
* Leading to VariableDeclarator
* Leading to VariableDeclarator
*/
i = 20,
/*
* Leading to VariableDeclarator
* Leading to VariableDeclarator
*/
j = 20;
}

View 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
*/
}}

View 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
*/
}
}

View 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

View 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;

View 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]() {
}
}

View 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() {
}
}

View 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() { });

View 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() {
});

View 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,
};

View 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
};

View 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) => { };

View 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) => {
};

View 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;

View 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;

View File

@@ -0,0 +1,3 @@
export default function a () { }
// export default var i = 20;
// export default const K = 20;

View File

@@ -0,0 +1,2 @@
export default function a() {
}

View 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

View 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;

View File

@@ -0,0 +1,7 @@
function test() {
for (var i of array) {
}
for (let i of array) {
}
}

View File

@@ -0,0 +1,6 @@
function test() {
for (var i of array) {
}
for (let i of array) {
}
}

View 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';

View 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';

View 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';

View 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';

View File

@@ -0,0 +1,5 @@
({ t: t }) = obj;
({
t: { C: C }
}) = obj;
({ a, b, c }) = obj;

View File

@@ -0,0 +1,5 @@
({t: t} = obj);
({
t: {C: C}
} = obj);
({a, b, c} = obj);

View File

@@ -0,0 +1,5 @@
var [a, b, ...rest] = array;
const [a, b, ...rest] = array;
function a([a, b, ...rest]) {
}
([a, b, ...rest]) => { };

View File

@@ -0,0 +1,22 @@
var [
a,
b,
...rest
] = array;
const [
a,
b,
...rest
] = array;
function a([
a,
b,
...rest
]) {
}
([
a,
b,
...rest
]) => {
};

View File

@@ -0,0 +1,12 @@
var escaped = `
\u2028
\u2029
`;
var escaped = `
\v
\b
\t
\n
\r
`;

View File

@@ -0,0 +1,11 @@
var escaped = `
\u2028
\u2029
`;
var escaped = `
\v
\b
\t
\n
\r
`;

View 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 }
`;

View 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 }
`;

View 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);
}

View 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);
}

View File

@@ -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);
});
});
});
});
});