Added tests from 'captureArguments' branch.

This commit is contained in:
Daniel Rosenwasser 2015-04-16 12:29:49 -07:00
parent 3b74503898
commit fc7be363f1
38 changed files with 243 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// @target: es6
// @target: es5
var a = () => {
var arg = arguments[0]; // error
}

View File

@ -0,0 +1,3 @@
// @target: es5
var a = () => arguments;

View File

@ -0,0 +1,3 @@
// @target: es6
var a = () => arguments;

View File

@ -0,0 +1,4 @@
// @target: es5
var arguments;
var a = () => arguments;

View File

@ -0,0 +1,4 @@
// @target: es6
var arguments;
var a = () => arguments;

View File

@ -0,0 +1,6 @@
// @target: es5
function f() {
var arguments;
var a = () => arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es6
function f() {
var arguments;
var a = () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es5
function f(arguments) {
var a = () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es6
function f(arguments) {
var a = () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es5
function f(arguments) {
var a = () => () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es6
function f(arguments) {
var a = () => () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es5
function f(arguments) {
var a = (arguments) => () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es6
function f(arguments) {
var a = (arguments) => () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es5
function f(arguments) {
var a = () => (arguments) => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es6
function f(arguments) {
var a = () => (arguments) => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es5
function f(_arguments) {
var a = () => () => arguments;
}

View File

@ -0,0 +1,5 @@
// @target: es6
function f(_arguments) {
var a = () => () => arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es5
function f() {
var _arguments = 10;
var a = () => () => arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es6
function f() {
var _arguments = 10;
var a = () => () => arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es5
function f(arguments) {
var _arguments = 10;
var a = () => () => arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es6
function f(arguments) {
var _arguments = 10;
var a = () => () => arguments;
}

View File

@ -0,0 +1,7 @@
// @target: es5
class C {
f(arguments) {
var a = () => arguments;
}
}

View File

@ -0,0 +1,7 @@
// @target: es6
class C {
f(arguments) {
var a = () => arguments;
}
}

View File

@ -0,0 +1,6 @@
// @target: es5
function f() {
var _arguments = 10;
var a = (arguments) => () => _arguments;
}

View File

@ -0,0 +1,6 @@
// @target: es6
function f() {
var _arguments = 10;
var a = (arguments) => () => _arguments;
}

View File

@ -0,0 +1,8 @@
// @target: es5
function f() {
if (Math.random()) {
const arguments = 100;
return () => arguments;
}
}

View File

@ -0,0 +1,8 @@
// @target: es6
function f() {
if (Math.random()) {
let arguments = 100;
return () => arguments;
}
}

View File

@ -0,0 +1,9 @@
// @target: es5
function f() {
var arguments = "hello";
if (Math.random()) {
const arguments = 100;
return () => arguments;
}
}

View File

@ -0,0 +1,9 @@
// @target: es6
function f() {
var arguments = "hello";
if (Math.random()) {
const arguments = 100;
return () => arguments;
}
}

View File

@ -0,0 +1,9 @@
// @target: es5
function f() {
var arguments = "hello";
if (Math.random()) {
return () => arguments[0];
}
var arguments = "world";
}

View File

@ -0,0 +1,9 @@
// @target: es6
function f() {
var arguments = "hello";
if (Math.random()) {
return () => arguments[0];
}
var arguments = "world";
}

View File

@ -0,0 +1,9 @@
// @target: es5
function f() {
var { arguments } = { arguments: "hello" };
if (Math.random()) {
return () => arguments[0];
}
var arguments = "world";
}

View File

@ -0,0 +1,9 @@
// @target: es6
function f() {
var { arguments } = { arguments: "hello" };
if (Math.random()) {
return () => arguments[0];
}
var arguments = "world";
}

View File

@ -0,0 +1,8 @@
// @target: es5
function f() {
var { arguments: args } = { arguments };
if (Math.random()) {
return () => arguments;
}
}

View File

@ -0,0 +1,8 @@
// @target: es6
function f() {
var { arguments: args } = { arguments };
if (Math.random()) {
return () => arguments;
}
}

View File

@ -0,0 +1,15 @@
// @target: es5
function f() {
function g() {
var _arguments = 10; // No capture in 'g', so no conflict.
function h() {
var capture = () => arguments; // Should trigger an '_arguments' capture into function 'h'
foo(_arguments); // Error as this does not resolve to the user defined '_arguments'
}
}
function foo(x: any) {
return 100;
}
}

View File

@ -0,0 +1,15 @@
// @target: es6
function f() {
function g() {
var _arguments = 10; // No capture in 'g', so no conflict.
function h() {
var capture = () => arguments; // Should trigger an '_arguments' capture into function 'h'
foo(_arguments); // Error as this does not resolve to the user defined '_arguments'
}
}
function foo(x: any) {
return 100;
}
}