From 35038fdb100b060fa5c4908f54f42ee71b308185 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Sep 2015 14:51:11 +0800 Subject: [PATCH] update tests for arrow-function --- .../arrow-function/arrow/binding-tests-1.js | 14 ++++++++++++++ .../arrow-function/arrow/binding-tests-2.js | 14 ++++++++++++++ .../arrow-function/arrow/binding-tests-3.js | 14 ++++++++++++++ .../arrow/capturing-closure-variables-1.js | 15 +++++++++++++++ .../arrow/capturing-closure-variables-2.js | 17 +++++++++++++++++ ...cisebody-lookahead-assignmentexpression-1.js | 9 +++++++++ ...cisebody-lookahead-assignmentexpression-2.js | 9 +++++++++ 7 files changed, 92 insertions(+) create mode 100644 test/language/expressions/arrow-function/arrow/binding-tests-1.js create mode 100644 test/language/expressions/arrow-function/arrow/binding-tests-2.js create mode 100644 test/language/expressions/arrow-function/arrow/binding-tests-3.js create mode 100644 test/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js create mode 100644 test/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js create mode 100644 test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js create mode 100644 test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js diff --git a/test/language/expressions/arrow-function/arrow/binding-tests-1.js b/test/language/expressions/arrow-function/arrow/binding-tests-1.js new file mode 100644 index 0000000000..67b9e2642e --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/binding-tests-1.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: this binding tests +flags: [noStrict] +es6id: 14.2 +---*/ + +function foo(){ + return eval("()=>this"); + } + +assert.sameValue(foo()(), this, "This binding initialization was incorrect for arrow capturing this from closure."); diff --git a/test/language/expressions/arrow-function/arrow/binding-tests-2.js b/test/language/expressions/arrow-function/arrow/binding-tests-2.js new file mode 100644 index 0000000000..67b9e2642e --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/binding-tests-2.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: this binding tests +flags: [noStrict] +es6id: 14.2 +---*/ + +function foo(){ + return eval("()=>this"); + } + +assert.sameValue(foo()(), this, "This binding initialization was incorrect for arrow capturing this from closure."); diff --git a/test/language/expressions/arrow-function/arrow/binding-tests-3.js b/test/language/expressions/arrow-function/arrow/binding-tests-3.js new file mode 100644 index 0000000000..0610010b04 --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/binding-tests-3.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: this binding tests +flags: [noStrict] +es6id: 14.2 +---*/ + +function foo(){ + return ()=>eval("this"); + } + +assert.sameValue(eval("foo()()"), this, "This binding initialization was incorrect for arrow capturing this from closure."); diff --git a/test/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js b/test/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js new file mode 100644 index 0000000000..f5f7928647 --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js @@ -0,0 +1,15 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Capturing closure variables +es6id: 14.2 +---*/ + +var a; +function foo(){ + eval("a = 10"); + return ()=>a; + } + +assert.sameValue(foo()(), 10, "Closure variable was captured incorrectly."); diff --git a/test/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js b/test/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js new file mode 100644 index 0000000000..05800d46dc --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js @@ -0,0 +1,17 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Capturing closure variables - with +es6id: 14.2 +flags: [noStrict] +---*/ + +function foo(){ + var a = {a : 10}; + with(a){ + return () => a; + } + } + +assert.sameValue(foo()(), 10, "Closure variable was captured incorrectly."); diff --git a/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js b/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js new file mode 100644 index 0000000000..4777db00b8 --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js @@ -0,0 +1,9 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: "ConciseBody :[lookahead { { }] AssignmentExpression" +es6id: 14.2 +---*/ + +x => x => x diff --git a/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js b/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js new file mode 100644 index 0000000000..a7beb6bf19 --- /dev/null +++ b/test/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js @@ -0,0 +1,9 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: "ConciseBody :[lookahead { { }] AssignmentExpression" +es6id: 14.2 +---*/ + +x => function(){}