diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/arrow-function')
356 files changed, 17661 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/arrow-function/ArrowFunction_restricted-properties.js b/js/src/tests/test262/language/expressions/arrow-function/ArrowFunction_restricted-properties.js new file mode 100644 index 0000000000..fe3dfa61d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/ArrowFunction_restricted-properties.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions created using ArrowFunction syntactic form do not have + own properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +es6id: 16.1 +---*/ + +var arrowFn = () => {}; + +assert.sameValue(arrowFn.hasOwnProperty('caller'), false, 'Functions created using ArrowFunction syntactic form do not have own property "caller"'); +assert.sameValue(arrowFn.hasOwnProperty('arguments'), false, 'Functions created using ArrowFunction syntactic form do not have own property "arguments"'); + +assert.throws(TypeError, function() { + return arrowFn.caller; +}); + +assert.throws(TypeError, function() { + arrowFn.caller = {}; +}); + +assert.throws(TypeError, function() { + return arrowFn.arguments; +}); + +assert.throws(TypeError, function() { + arrowFn.arguments = {}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/arrow-function/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..491794f1b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/array-destructuring-param-strict-body.js @@ -0,0 +1,132 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +0, ([element]) => { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-1.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-1.js new file mode 100644 index 0000000000..7d7a0d3ed1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-1.js @@ -0,0 +1,16 @@ +// 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.");
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-2.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-2.js new file mode 100644 index 0000000000..7d7a0d3ed1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-2.js @@ -0,0 +1,16 @@ +// 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.");
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-3.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-3.js new file mode 100644 index 0000000000..5925e477f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/binding-tests-3.js @@ -0,0 +1,16 @@ +// 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.");
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/browser.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-1.js new file mode 100644 index 0000000000..237c76486d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-1.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
+es6id: 14.2
+---*/
+
+var a;
+function foo(){
+ eval("a = 10");
+ return ()=>a;
+ }
+
+assert.sameValue(foo()(), 10, "Closure variable was captured incorrectly.");
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js new file mode 100644 index 0000000000..76ecabb129 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/capturing-closure-variables-2.js @@ -0,0 +1,19 @@ +// 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.");
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js new file mode 100644 index 0000000000..8df3661ffa --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-1.js @@ -0,0 +1,11 @@ +// 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
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js new file mode 100644 index 0000000000..0365eebc2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/concisebody-lookahead-assignmentexpression-2.js @@ -0,0 +1,11 @@ +// 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(){}
+ +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/arrow/shell.js b/js/src/tests/test262/language/expressions/arrow-function/arrow/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/arrow/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/browser.js b/js/src/tests/test262/language/expressions/arrow-function/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/cannot-override-this-with-thisArg.js b/js/src/tests/test262/language/expressions/arrow-function/cannot-override-this-with-thisArg.js new file mode 100644 index 0000000000..0ed46492de --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/cannot-override-this-with-thisArg.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction `this` cannot be overridden by thisArg + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + ... + 9. If kind is Arrow, set the [[ThisMode]] internal slot of F to lexical. + ... + + 9.2.1.2 OrdinaryCallBindThis ( F, calleeContext, thisArgument ) + + 1. Let thisMode be the value of F’s [[ThisMode]] internal slot. + 2. If thisMode is lexical, return NormalCompletion(undefined). + ... + +---*/ + +var calls = 0; +var usurper = {}; +[1].forEach(value => { + calls++; + assert.notSameValue(this, usurper); +}, usurper); + +assert.sameValue(calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-abrupt.js new file mode 100644 index 0000000000..ea8633d42b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-abrupt.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/arrow-function.template +/*--- +description: Abrupt completion returned by evaluation of initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +var f; +f = (_ = (function() { throw new Test262Error(); }())) => { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..d2cb5aed3e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/arrow-function.template +/*--- +description: Use of initializer when argument value is not `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) => { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +ref(false, '', NaN, 0, null, obj); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..d217484582 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-arg-val-undefined.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/arrow-function.template +/*--- +description: Use of initializer when argument value is `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (fromLiteral = 23, fromExpr = 45, fromHole = 99) => { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +ref(undefined, void 0); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-duplicates.js new file mode 100644 index 0000000000..8ea9a7db3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-duplicates.js @@ -0,0 +1,61 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +0, (x = 0, x) => { + +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-later.js new file mode 100644 index 0000000000..ab20e63219 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-later.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/arrow-function.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +var f; +f = (x = y, y) => { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-prior.js new file mode 100644 index 0000000000..f796e60328 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-prior.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/arrow-function.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (x, y = x, z = y) => { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +ref(3); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-self.js new file mode 100644 index 0000000000..8188fc9662 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-ref-self.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/arrow-function.template +/*--- +description: Referencing a parameter from within its own initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +var f; +f = (x = x) => { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-rest.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-rest.js new file mode 100644 index 0000000000..fe388474d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-rest.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: RestParameter does not support an initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +0, (...x = []) => { + +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..64c4e17ebd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dflt-params-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a, b = 39,) => { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-close.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-close.js new file mode 100644 index 0000000000..321cab1592 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..4d93b550f9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +var f = ([x, y, z]) => {}; + +assert.throws(TypeError, function() { + f([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err.js new file mode 100644 index 0000000000..f27f9639ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-no-close.js new file mode 100644 index 0000000000..db1e6223ef --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-name-iter-val.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-name-iter-val.js new file mode 100644 index 0000000000..c6ef481967 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding with normal value iteration (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..fd39028d58 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]]) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..03d3115a9a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]]) => { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..03d4023908 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..fb718c5a8c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()]) => { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f([[]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..34669c2920 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; return iter; }()]) => { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..f39c5f7aca --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; }()]) => { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([[23]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..88095f1075 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = ([[...x] = values]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..cc6db8c8db --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = ([[...x] = function() { initCount += 1; }()]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([values]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..eb39ae0aee --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested array destructuring with a null value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var f = ([[x]]) => {}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..9080fc5f54 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with an exhausted iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..0d58b7ad47 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding does assign name to arrow functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([arrow = () => {}]) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..ba2a78eec7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..cbdb42bf81 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cover = (function () {}), xCover = (0, function() {})]) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..2ff2aa2ce0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([fn = function () {}, xFn = function x() {}]) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f9401d4b93 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +var f; +f = ([gen = function* () {}, xGen = function* x() {}]) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..c6d8e0041d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with a "hole" (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f([,]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..98d1e59a44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ([w = counter(), x = counter(), y = counter(), z = counter()]) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([null, 0, false, '']); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..714510a841 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var f = ([x = (function() { throw new Test262Error(); })()]) => {}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..66ac06f0e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with an undefined value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([undefined]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..cefa3ae1fa --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ([ x = unresolvableReference ]) => {}; + +assert.throws(ReferenceError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..e82552f3d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration completes (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..e7326f71e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([_, x]) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..844c7a1232 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..1c388b46e4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[Done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[Done]] to true. + iii. ReturnIfAbrupt(v). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +var f; +f = ([x, y, z]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..c10a9c26aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..6a2879f73f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..27e9abff2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) => { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..58f1d9e545 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) => { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..ac5eecaaa9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) => { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..37195d1069 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) => { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..a83d588223 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested object destructuring with a null value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }]) => {}; + +assert.throws(TypeError, function() { + f([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..b8deaaf648 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested object destructuring with a value of `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }]) => {}; + +assert.throws(TypeError, function() { + f([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..5b9aac53c9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Elision accepts exhausted iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = ([,]) => { + + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..0284275f23 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Elision advances iterator and forwards abrupt completions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var f = ([,]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision.js new file mode 100644 index 0000000000..4d25b9b979 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Elision advances iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([,]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-empty.js new file mode 100644 index 0000000000..645523cbf8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([]) => { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..6b5219a009 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an array BindingElementList pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([...[x, y, z]]) => { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f([3, 4, 5]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..8b3adc6d00 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an elision (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([...[,]]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..822b257545 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an "empty" array pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([...[]]) => { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..c8f18b1cd5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing a rest element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...[...x]]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..44a1a6a253 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-direct.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Lone rest element (direct binding) (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +var f; +f = ([...x]) => { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; + +f([1]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..111160243a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Rest element following elision elements (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var f = ([, ...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..7e8a579b4b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element following elision elements (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = ([ , , ...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..a721cbcb1d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: RestElement applied to an exhausted iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = ([, , ...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f([1, 2]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..c80c748b62 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var f = ([...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..6c5837bb54 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id.js new file mode 100644 index 0000000000..225fcb2f1c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Lone rest element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..821554578e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (nested array pattern) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...[ x ] = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..c78b2967b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (identifier) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...x = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..1d100d195a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-init-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (nested object pattern) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...{ x } = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..73e6a9a917 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...[x], y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..fbd913af33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (identifier) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...x, y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..f94da19b77 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...{ x }, y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..9834f42054 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ length }]) => { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..ec7b377b26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +var f; +f = ([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) => { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; + +f([7, 8, 9]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/browser.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..3fe5417e76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x] = iter) => { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..a4b808f0dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +var f = ([x, y, z] = [1, 2, 3]) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..bbcc8d0a53 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var f = ([x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..b3dd22db95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x] = iter) => { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..6398e3dd98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z] = [1, 2, 3]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..26a559610e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]] = []) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..c5849a3cac --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) => { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..2dac8f092b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()] = []) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..261631e424 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()] = [[]]) => { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..acbb15fb95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; return iter; }()] = []) => { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..6123c6211c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; }()] = [[23]]) => { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..a6ed320ef4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = ([[...x] = values] = []) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..5809569037 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = ([[...x] = function() { initCount += 1; }()] = [values]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..143b335cdf --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested array destructuring with a null value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var f = ([[x]] = [null]) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..f46dad8d7d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = []) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2bdceda9a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([arrow = () => {}] = []) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..0eb415b0c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..075eb5734f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cover = (function () {}), xCover = (0, function() {})] = []) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..9f5185f39e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([fn = function () {}, xFn = function x() {}] = []) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..d41c7da94f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +var f; +f = ([gen = function* () {}, xGen = function* x() {}] = []) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..6865014ca5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with a "hole" (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = [,]) => { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..f502fc771e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..6cfb421d94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var f = ([x = (function() { throw new Test262Error(); })()] = [undefined]) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..75b9fdc6ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with an undefined value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = [undefined]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..fe7be58cb0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ([ x = unresolvableReference ] = []) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..3cda97aac8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x] = []) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..1cd22fec2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([_, x] = []) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..e1d9a3a270 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var f = ([x] = g) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..6f06a1555a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[Done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[Done]] to true. + iii. ReturnIfAbrupt(v). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +var f; +f = ([x, y, z] = [1, 2, 3]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..3060690a78 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([x] = g) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..6c158b9115 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z] = [1, 2, 3]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0136cae13b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) => { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..b1ef1365cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) => { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1f09945685 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) => { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..9a6c3aa92b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) => { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..5c5670b99b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested object destructuring with a null value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }] = [null]) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..8275c6e5f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }] = []) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..ec2bc0d04e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Elision accepts exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = ([,] = iter) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..2ea6619ef3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var f = ([,] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..ecf3e29ca4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Elision advances iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([,] = g()) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..fb6a6995b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([] = iter) => { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..e11d10f92d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([...[x, y, z]] = [3, 4, 5]) => { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7bc00bdb3b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an elision (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([...[,]] = g()) => { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..88dff90e6f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([...[]] = iter) => { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..eba15c2907 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing a rest element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...[...x]] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..f43415887e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Lone rest element (direct binding) (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +var f; +f = ([...x] = [1]) => { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..25929d6a9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Rest element following elision elements (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var f = ([, ...x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..5761d9765c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element following elision elements (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = ([ , , ...x] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..b66689b26f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = ([, , ...x] = [1, 2]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..46a95f6441 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var f = ([...x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..58bf84d5ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([...x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..86b8b4a46a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Lone rest element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...x] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..ee2cbad23e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...[ x ] = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..09183d1e09 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...x = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..9943a471bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...{ x } = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..4020348a7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...[x], y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..f4540acd2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...x, y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0d019d01eb --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +var f; +f = ([...{ x }, y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..a8c83dc296 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ length }] = [1, 2, 3]) => { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..daaecca03a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +var f; +f = ([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) => { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-null.js new file mode 100644 index 0000000000..3d60e93133 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({} = null) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-undefined.js new file mode 100644 index 0000000000..0a77e7dcc1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({} = undefined) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..2b472ea4fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = ({} = obj) => { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..c0e7eedd07 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned } = poisonedProperty) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..231c1d8d2c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ arrow = () => {} } = {}) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4796f3f58e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..69d5069d16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cover = (function () {}), xCover = (0, function() {}) } = {}) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e82b1c4e1a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ fn = function () {}, xFn = function x() {} } = {}) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6d01512f3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +var f; +f = ({ gen = function* () {}, xGen = function* x() {} } = {}) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..2c186eff0c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..ce433e7b1c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x = thrower() } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..fa58f049e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x = unresolvableReference } = {}) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..93a4a7b91c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x, } = { x: 23 }) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..14f6ea519e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var f = ({ a, b = thrower(), c = ++initCount } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..e1028e1a0c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] } = {}) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..4cfd6eff2b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: [y], } = { x: [45] }) => { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..067363aafe --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: [x, y, z] = [4, 5, 6] } = { w: null }) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..126db86627 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) => { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..de4e1614db --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ [thrower()]: x } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..13b292e275 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned: x = ++initEvalCount } = poisonedProperty) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..b122345205 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) => { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..48f7063932 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x: y = thrower() } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..50c7e1b05a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x: y = unresolvableReference } = {}) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..15b471e2ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y = 33 } = { }) => { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..e634557516 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: y, } = { x: 23 }) => { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..0523ad60f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Binding as specified via property name and identifier (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y } = { x: 23 }) => { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..901bba3c87 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7b35c6de94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..5c8718acfc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = undefined } = { }) => {}; + +assert.throws(TypeError, function() { + f(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..247d72902c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) => { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..22147ee150 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = ({...x} = { get v() { count++; return 2; } }) => { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..e9aa58bde3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = ({...rest} = o) => { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..26045d23aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest object contains just unextracted data (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) => { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-null.js new file mode 100644 index 0000000000..056054dc18 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({}) => {}; + +assert.throws(TypeError, function() { + f(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-undefined.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-undefined.js new file mode 100644 index 0000000000..7424368136 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({}) => {}; + +assert.throws(TypeError, function() { + f(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-empty.js new file mode 100644 index 0000000000..85b5394c34 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: No property access occurs for an "empty" object binding pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = ({}) => { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(obj); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..773d9fadf8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned }) => {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..14f07118b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ arrow = () => {} }) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..96992e838f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..87132006d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cover = (function () {}), xCover = (0, function() {}) }) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0e02360064 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ fn = function () {}, xFn = function x() {} }) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..dcf2433d65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +var f; +f = ({ gen = function* () {}, xGen = function* x() {} }) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..59e18a0370 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ w = counter(), x = counter(), y = counter(), z = counter() }) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..81afe54335 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x = thrower() }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..db2d70c2c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x = unresolvableReference }) => {}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..d14d6837fc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x, }) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-list-err.js new file mode 100644 index 0000000000..66fcf2cf24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var f = ({ a, b = thrower(), c = ++initCount }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..3d51eca6ab --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..8ed63ded12 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: [y], }) => { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f({ x: [45] }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..a3734dc91c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: [x, y, z] = [4, 5, 6] }) => {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..f73422a22a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] }) => { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..59e84071b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Evaluation of property name returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ [thrower()]: x }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..a693b19fbf --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned: x = ++initEvalCount }) => {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..394f871b01 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) => { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..baba9898f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x: y = thrower() }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..92d4dd36ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x: y = unresolvableReference }) => {}; + +assert.throws(ReferenceError, function() { + f({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..3151838b23 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Binding as specified via property name, identifier, and initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y = 33 }) => { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..77adefdd33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: y, }) => { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id.js new file mode 100644 index 0000000000..05f396557b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Binding as specified via property name and identifier (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y }) => { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..92a8bf65f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: undefined }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..a1698400e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..1f3386f728 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = undefined }) => {}; + +assert.throws(TypeError, function() { + f({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..3d67c6e88e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..7c2b3f65ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-getter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = ({...x}) => { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; + +f({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..b67747fde2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest object doesn't contain non-enumerable properties (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = ({...rest}) => { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; +}; + +f(o); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..f99759ce0b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest object contains just unextracted data (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...rest}) => { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; +}; + +f({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/shell.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-break-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-break-escaped.js new file mode 100644 index 0000000000..a106097555 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-break-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/break-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: break is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ bre\u0061k }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-case-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-case-escaped.js new file mode 100644 index 0000000000..4c5babc290 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-case-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/case-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: case is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ c\u0061se }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-catch-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-catch-escaped.js new file mode 100644 index 0000000000..61fda7f16b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-catch-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/catch-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: catch is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ c\u0061tch }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-class-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-class-escaped.js new file mode 100644 index 0000000000..11250bf99f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-class-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/class-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: class is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ cl\u0061ss }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-const-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-const-escaped.js new file mode 100644 index 0000000000..2622ee8452 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-const-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/const-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: const is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0063onst }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-continue-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-continue-escaped.js new file mode 100644 index 0000000000..d792d507d9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-continue-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/continue-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: continue is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0063ontinue }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-debugger-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-debugger-escaped.js new file mode 100644 index 0000000000..f8769457d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-debugger-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/debugger-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: debugger is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0064ebugger }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped-ext.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped-ext.js new file mode 100644 index 0000000000..c0e9e8b7dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped-ext.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped-ext.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: default is a valid identifier name, using extended escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ def\u{61}ult }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped.js new file mode 100644 index 0000000000..3112f95245 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: default is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ def\u0061ult }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default.js new file mode 100644 index 0000000000..46b7e1e91d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-default.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/default.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: default is a valid identifier name (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ default }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-delete-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-delete-escaped.js new file mode 100644 index 0000000000..998fa94c79 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-delete-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/delete-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: delete is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0064elete }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-do-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-do-escaped.js new file mode 100644 index 0000000000..527b793c52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-do-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/do-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: do is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0064o }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-else-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-else-escaped.js new file mode 100644 index 0000000000..e8f077923c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-else-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/else-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: else is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0065lse }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-enum-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-enum-escaped.js new file mode 100644 index 0000000000..0ee70ae952 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-enum-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/enum-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: enum is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0065num }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-export-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-export-escaped.js new file mode 100644 index 0000000000..0de019125e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-export-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/export-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: export is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0065xport }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped-ext.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped-ext.js new file mode 100644 index 0000000000..2808d52969 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped-ext.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped-ext.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: extends is a valid identifier name, using extended escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u{65}xtends }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped.js new file mode 100644 index 0000000000..f4c7f3b022 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: extends is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0065xtends }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends.js new file mode 100644 index 0000000000..703cda1d59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-extends.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: extends is a valid identifier name (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ extends }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-finally-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-finally-escaped.js new file mode 100644 index 0000000000..a14f2a5ee0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-finally-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/finally-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: finally is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0066inally }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-for-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-for-escaped.js new file mode 100644 index 0000000000..7a88712df2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-for-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/for-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: for is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0066or }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-function-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-function-escaped.js new file mode 100644 index 0000000000..d10739f2f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-function-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/function-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: function is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0066unction }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-if-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-if-escaped.js new file mode 100644 index 0000000000..c9a516806d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-if-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/if-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: if is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ i\u0066 }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-implements-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-implements-escaped-strict.js new file mode 100644 index 0000000000..15c219977b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-implements-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/implements-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: implements is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0069mplements }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-import-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-import-escaped.js new file mode 100644 index 0000000000..b054ade352 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-import-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/import-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: import is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0069mport }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-in-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-in-escaped.js new file mode 100644 index 0000000000..e7bf02dd40 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-in-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/in-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: in is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0069n }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-instanceof-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-instanceof-escaped.js new file mode 100644 index 0000000000..dee1712ea6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-instanceof-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/instanceof-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: instanceof is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ \u0069nstanceof }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-interface-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-interface-escaped-strict.js new file mode 100644 index 0000000000..2a803e3e81 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-interface-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/interface-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: interface is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ interf\u0061ce }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-let-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-let-escaped-strict.js new file mode 100644 index 0000000000..4f36692f94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-let-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/let-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: let is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ l\u0065t }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-new-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-new-escaped.js new file mode 100644 index 0000000000..3483e1ced9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-new-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/new-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: new is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ n\u0065w }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-package-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-package-escaped-strict.js new file mode 100644 index 0000000000..8791ce7531 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-package-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/package-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: package is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ p\u0061ckage }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-private-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-private-escaped-strict.js new file mode 100644 index 0000000000..41d3b48a8d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-private-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/private-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: private is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ privat\u0065 }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-protected-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-protected-escaped-strict.js new file mode 100644 index 0000000000..431c601f32 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-protected-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/protected-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: protected is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ prot\u0065cted }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-public-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-public-escaped-strict.js new file mode 100644 index 0000000000..aa66fc2dd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-public-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/public-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: public is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ pu\u0062lic }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-return-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-return-escaped.js new file mode 100644 index 0000000000..bbd35ef11b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-return-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/return-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: return is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ r\u0065turn }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-static-escaped-strict.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-static-escaped-strict.js new file mode 100644 index 0000000000..e78d2b0ac5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-static-escaped-strict.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/identifier-names/static-escaped.case +// - src/identifier-names/future-reserved-words/arrow-fn-assignment-identifier.template +/*--- +description: static is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ st\u0061tic }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-super-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-super-escaped.js new file mode 100644 index 0000000000..e74c822858 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-super-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/super-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: super is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ sup\u0065r }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-switch-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-switch-escaped.js new file mode 100644 index 0000000000..798866c54d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-switch-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/switch-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: switch is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ sw\u0069tch }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-this-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-this-escaped.js new file mode 100644 index 0000000000..1a4e003598 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-this-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/this-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: this is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ th\u0069s }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-throw-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-throw-escaped.js new file mode 100644 index 0000000000..b4a90daa27 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-throw-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/throw-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: throw is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ t\u0068row }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-try-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-try-escaped.js new file mode 100644 index 0000000000..bfb3f14118 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-try-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/try-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: try is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ tr\u0079 }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-typeof-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-typeof-escaped.js new file mode 100644 index 0000000000..3ece74b589 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-typeof-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/typeof-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: typeof is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ typ\u0065of }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-var-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-var-escaped.js new file mode 100644 index 0000000000..7b74be7549 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-var-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/var-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: var is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ v\u0061r }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-void-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-void-escaped.js new file mode 100644 index 0000000000..577e67d5cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-void-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/void-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: void is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ voi\u0064 }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-while-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-while-escaped.js new file mode 100644 index 0000000000..de78b4db2b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-while-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/while-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: while is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ whil\u0065 }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-with-escaped.js b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-with-escaped.js new file mode 100644 index 0000000000..bf86e38754 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/dstr/syntax-error-ident-ref-with-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/identifier-names/with-escaped.case +// - src/identifier-names/default/arrow-fn-assignment-identifier.template +/*--- +description: with is a valid identifier name, using escape (IdentiferReference in ObjectAssignmentPattern (Arrow Function) cannot be a ReservedWord) +esid: prod-AssignmentPattern +features: [arrow-function, destructuring-assignment] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AssignmentPattern: + ObjectAssignmentPattern + + ObjectAssignmentPattern: + { AssignmentPropertyList } + + AssignmentPropertyList: + AssignmentProperty + AssignmentPropertyList , AssignmentProperty + + AssignmentProperty: + IdentifierReference Initializer_opt + PropertyName : AssignmentElement + + IdentifierReference: + Identifier + [~Yield]yield + [~Await]await + + Identifier: + IdentifierName but not ReservedWord + +---*/ + + +$DONOTEVALUATE(); + +var x = ({ w\u0069th }) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/empty-function-body-returns-undefined.js b/js/src/tests/test262/language/expressions/arrow-function/empty-function-body-returns-undefined.js new file mode 100644 index 0000000000..4e5bad8840 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/empty-function-body-returns-undefined.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Empty arrow function returns undefined +---*/ + +var empty = () => {}; +assert.sameValue(empty(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/arrow-function/eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..f28c7fb46d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/eval-var-scope-syntax-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/arrow-function.template +/*--- +description: sloppy direct eval in params introduces var (arrow function expression in sloppy code) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + +var callCount = 0; +var f; +f = (a = eval("var a = 42")) => { + + callCount = callCount + 1; +}; + +assert.throws(SyntaxError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/expression-body-implicit-return.js b/js/src/tests/test262/language/expressions/arrow-function/expression-body-implicit-return.js new file mode 100644 index 0000000000..dbb5da13b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/expression-body-implicit-return.js @@ -0,0 +1,11 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Expression Body implicit return +---*/ +var plusOne = v => v + 1; +assert.sameValue(plusOne(1), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..5fcfb8d6e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/arrow-function.template +/*--- +description: Forbidden extension, f.arguments (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [arrow-function] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +var f; +f = () => { + assert.sameValue(f.hasOwnProperty("arguments"), false); + callCount++; +}; + + + f(); +assert.sameValue(callCount, 1, 'arrow function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..a48d9328de --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/arrow-function-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/arrow-function.template +/*--- +description: Forbidden extension, o.caller (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [arrow-function] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +var f; +f = () => { + assert.sameValue(f.hasOwnProperty("caller"), false); + callCount++; +}; + + + f(); +assert.sameValue(callCount, 1, 'arrow function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b1/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..11fd3af5f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/arrow-function.template +/*--- +description: Forbidden extension, o.caller (arrow function expression) +esid: sec-arrow-definitions-runtime-semantics-evaluation +features: [arrow-function] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +var f; +f = () => { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..4a61c3147a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/arrow-function.template +/*--- +description: Forbidden extension, o.caller (arrow function expression) +esid: sec-arrow-definitions-runtime-semantics-evaluation +features: [arrow-function] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +var f; +f = () => { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..65d2f51cb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/arrow-function.template +/*--- +description: Forbidden extension, o.caller (arrow function expression) +esid: sec-arrow-definitions-runtime-semantics-evaluation +features: [arrow-function] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +var f; +f = () => { + "use strict"; + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + // the same templates. + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, f); + } + callCount++; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/browser.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/shell.js b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/length-dflt.js b/js/src/tests/test262/language/expressions/arrow-function/length-dflt.js new file mode 100644 index 0000000000..cff5e3ff1b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/length-dflt.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = (x = 42) => {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = (x = 42, y) => {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = (x, y = 42) => {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = (x, y = 42, z) => {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-arguments.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-arguments.js new file mode 100644 index 0000000000..3af9125bde --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-arguments.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + arguments + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +---*/ + +function f() { + var args = arguments; + + var af = _ => { + return arguments; + }; + + return args === af(); +} + +assert(f()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-bindings-overriden-by-formal-parameters-non-strict.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-bindings-overriden-by-formal-parameters-non-strict.js new file mode 100644 index 0000000000..5cdf078a46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-bindings-overriden-by-formal-parameters-non-strict.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + +flags: [noStrict] +---*/ +function f() { + return (arguments) => arguments; +} + +assert.sameValue(f(1)(2), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target-closure-returned.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target-closure-returned.js new file mode 100644 index 0000000000..175e6a828c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target-closure-returned.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + new.target + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +features: [arrow-function, new.target] +---*/ + +function F() { + this.af = _ => { + if (new.target) { + return 1; + } + return 2; + }; +} + +var f = new F(); + +assert.sameValue(f.af(), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target.js new file mode 100644 index 0000000000..271a71444b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-new.target.js @@ -0,0 +1,36 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + new.target + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +features: [arrow-function, new.target] +---*/ + +var functionInvocationCount = 0; +var newInvocationCount = 0; + +function F() { + if ((_ => new.target)() !== undefined) { + newInvocationCount++; + } + functionInvocationCount++; +} + +F(); +new F(); + +assert.sameValue(functionInvocationCount, 2); +assert.sameValue(newInvocationCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-super-call-from-within-constructor.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-call-from-within-constructor.js new file mode 100644 index 0000000000..43835d4479 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-call-from-within-constructor.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.3.5.1 +description: > + Runtime Semantics: Evaluation + + SuperCall : super Arguments + + ... + 7. Let result be Construct(func, argList, newTarget). + ... + 10. Return thisER.BindThisValue(result) + + + 8.1.1.3.1 BindThisValue(V) + + ... + 3. If envRec.[[thisBindingStatus]] is "initialized", throw a ReferenceError exception. + ... +---*/ + +var count = 0; + +class A { + constructor() { + count++; + } +} + +class B extends A { + constructor() { + super(); + // envRec.[[thisBindingStatus]] is "initialized" + this.af = _ => super(); + } +} + +var b = new B(); + +assert.throws(ReferenceError, function() { + b.af(); +}); + + +assert.sameValue(count, 2, "The value of `count` is `2`, because S7 of `SuperCall : super Arguments` will call the super constructor."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property-from-within-constructor.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property-from-within-constructor.js new file mode 100644 index 0000000000..b242efa84e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property-from-within-constructor.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + super + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +---*/ + +var count = 0; + +class A { + constructor() { + count++; + } + increment() { + count++; + } +} + +class B extends A { + constructor() { + super(); + (_ => super.increment())(); + } +} + + +var bar = new B(); + +assert.sameValue(count, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property.js new file mode 100644 index 0000000000..7aedb5245b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-super-property.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + super + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +---*/ + +var count = 0; + +class A { + increment() { + count++; + } +} + +class B extends A { + incrementer() { + (_ => super.increment())(); + } +} + + +var bar = new B(); + +bar.incrementer(); + +assert.sameValue(count, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-supercall-from-immediately-invoked-arrow.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-supercall-from-immediately-invoked-arrow.js new file mode 100644 index 0000000000..2b7525172d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-supercall-from-immediately-invoked-arrow.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + super + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +---*/ + +var count = 0; + +class A { + constructor() { + count++; + } +} + +class B extends A { + constructor() { + (_ => super())(); + } +} + +var bar = new B(); + +assert.sameValue(count, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/lexical-this.js b/js/src/tests/test262/language/expressions/arrow-function/lexical-this.js new file mode 100644 index 0000000000..caffcc9f6f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/lexical-this.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + this + + ... + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + ... + + The non-normative note elaborates on the "scope" argument: + + An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, or this within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 4 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction. +---*/ + +function F() { + this.af = _ => { + return this; + }; +} + +var usurper = {}; +var f = new F(); + +assert.sameValue(f.af(), f); +assert.sameValue(f.af.apply(usurper), f); +assert.sameValue(f.af.call(usurper), f); +assert.sameValue(f.af.bind(usurper)(), f); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/low-precedence-expression-body-no-parens.js b/js/src/tests/test262/language/expressions/arrow-function/low-precedence-expression-body-no-parens.js new file mode 100644 index 0000000000..98a4f162bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/low-precedence-expression-body-no-parens.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + No need for parentheses even for lower-precedence expression body +---*/ + +var square = x => x * x; +assert.sameValue(square(3), 9); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/name.js b/js/src/tests/test262/language/expressions/arrow-function/name.js new file mode 100644 index 0000000000..f4cbc8d41f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2019 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +description: Assignment of function `name` attribute +info: | + ArrowFunction : ArrowParameters => ConciseBody + + 1. Let scope be the LexicalEnvironment of the running execution context. + 2. Let parameters be CoveredFormalsList of ArrowParameters. + 3. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, ""). + ... + 5. Return closure. +includes: [propertyHelper.js] +---*/ + +verifyProperty(x => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +verifyProperty(() => {}, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/non-strict.js b/js/src/tests/test262/language/expressions/arrow-function/non-strict.js new file mode 100644 index 0000000000..f0319effd1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/non-strict.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + 1. If the function code for this ArrowFunction is strict mode code (10.2.1), + let strict be true. Otherwise let strict be false. + ... + +flags: [noStrict] +---*/ +var af = _ => { + foo = 1; +}; + +af(); + +assert.sameValue(foo, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/arrow-function/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..d6e11e3eb9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/object-destructuring-param-strict-body.js @@ -0,0 +1,132 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +0, ({property}) => { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/object-literal-return-requires-body-parens.js b/js/src/tests/test262/language/expressions/arrow-function/object-literal-return-requires-body-parens.js new file mode 100644 index 0000000000..500f17303c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/object-literal-return-requires-body-parens.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Parenthesize the body to return an object literal expression +---*/ + +var keyMaker = val => ({ key: val }); +assert.sameValue(keyMaker(1).key, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-expr.js b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-expr.js new file mode 100644 index 0000000000..c9cc21fc6f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-expr.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted contextually outside of strict mode +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + 14.2.1 Static Semantics: Early Errors# + + ArrowFunction : ArrowParameters=>ConciseBody + + - It is a Syntax Error if ArrowParameters Contains YieldExpression is true. +features: [generators, default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function *g() { + (x = yield) => {}; +} diff --git a/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js new file mode 100644 index 0000000000..2a6daf10cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted as an IdentifierReference outside of strict + mode and outside of generator function bodies. +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] +features: [default-parameters] +flags: [noStrict] +---*/ + +var yield = 23; +var f, paramValue; + +f = (x = yield) => { paramValue = x; }; + +f(); + +assert.sameValue(paramValue, 23); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-strict-strict.js b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-strict-strict.js new file mode 100644 index 0000000000..8b6662f6aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/param-dflt-yield-id-strict-strict.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted as a FutureReservedWord within strict mode +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] +features: [default-parameters] +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +(x = yield) => {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/params-duplicate.js b/js/src/tests/test262/language/expressions/arrow-function/params-duplicate.js new file mode 100644 index 0000000000..02ad57408d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/params-duplicate.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright 2019 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arrow-function-definitions +description: Formal parameters may not contain duplicates +info: | + # 14.2 Arrow Function Definitions + + When the production + + ArrowParameters:CoverParenthesizedExpressionAndArrowParameterList + + is recognized the following grammar is used to refine the interpretation + of CoverParenthesizedExpressionAndArrowParameterList: + + ArrowFormalParameters[Yield, Await]: + (UniqueFormalParameters[?Yield, ?Await]) + + # 14.1.2 Static Semantics: Early Errors + + UniqueFormalParameters:FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +0, (a, a) => { }; diff --git a/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..0460b1c7ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-multiple.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a, b,) => { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-single.js new file mode 100644 index 0000000000..e447de3eeb --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/params-trailing-comma-single.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a,) => { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/prototype-rules.js b/js/src/tests/test262/language/expressions/arrow-function/prototype-rules.js new file mode 100644 index 0000000000..66082b4b00 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/prototype-rules.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Arrow functions are like functions, except they throw when using the + "new" operator on them. +---*/ + +assert.sameValue(typeof (() => {}), "function"); +assert.sameValue(Object.getPrototypeOf(() => {}), Function.prototype); +assert.sameValue("prototype" in (() => {}), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/rest-param-strict-body.js b/js/src/tests/test262/language/expressions/arrow-function/rest-param-strict-body.js new file mode 100644 index 0000000000..d45e154d4b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/rest-param-strict-body.js @@ -0,0 +1,132 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +0, (a,...rest) => { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/arrow-function/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..35a3c6e657 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/rest-params-trailing-comma-early-error.js @@ -0,0 +1,57 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/arrow-function.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +0, (...a,) => { + +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-body-lex-distinct.js b/js/src/tests/test262/language/expressions/arrow-function/scope-body-lex-distinct.js new file mode 100644 index 0000000000..ae6ba116c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-body-lex-distinct.js @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new lexical environment (distinct from the variable + environment) for the function body outside of strict mode +info: | + [...] + 29. If strict is false, then + a. Let lexEnv be NewDeclarativeEnvironment(varEnv). + b. NOTE: Non-strict functions use a separate lexical Environment Record + for top-level lexical declarations so that a direct eval can + determine whether any var scoped declarations introduced by the eval + code conflict with pre-existing top-level lexically scoped + declarations. This is not needed for strict functions because a + strict direct eval always places all declarations into a new + Environment Record. + [...] + + 18.2.1.3 Runtime Semantics: EvalDeclarationInstantiation + + [...] + 5. If strict is false, then + [...] + b. Let thisLex be lexEnv. + c. Assert: The following loop will terminate. + d. Repeat while thisLex is not the same as varEnv, + i. Let thisEnvRec be thisLex's EnvironmentRecord. + ii. If thisEnvRec is not an object Environment Record, then + 1. NOTE: The environment of with statements cannot contain any + lexical declaration so it doesn't need to be checked for + var/let hoisting conflicts. + 2. For each name in varNames, do + a. If thisEnvRec.HasBinding(name) is true, then + i. Throw a SyntaxError exception. + ii. NOTE: Annex B.3.5 defines alternate semantics for the + above step. + b. NOTE: A direct eval will not hoist var declaration over a + like-named lexical declaration. + iii. Let thisLex be thisLex's outer environment reference. +flags: [noStrict] +features: [let] +---*/ + +var a = () => { let x; eval('var x;'); }; + +assert.throws(SyntaxError, a); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-close.js b/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-close.js new file mode 100644 index 0000000000..5e31628181 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-close.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2, probeBody; + +(( + _ = (eval('var x = "inside";'), probe1 = function() { return x; }), + __ = probe2 = function() { return x; } + ) => { + probeBody = function() { return x; }; +})(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-open.js b/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-open.js new file mode 100644 index 0000000000..5eae959c7d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-param-elem-var-open.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2; + +(( + _ = probe1 = function() { return x; }, + __ = (eval('var x = "inside";'), probe2 = function() { return x; }) + ) => { +})(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-close.js b/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-close.js new file mode 100644 index 0000000000..4d5a568021 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-close.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probeParam, probeBody; + +(( + ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })] + ) => { + probeBody = function() { return x; } +})(); + +assert.sameValue(probeParam(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-open.js b/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-open.js new file mode 100644 index 0000000000..5649098bad --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-param-rest-elem-var-open.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + sloppy direct evals in params introduce vars +info: | + [...] + 20. Else, + a. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared. + b. Let calleeEnv be the LexicalEnvironment of calleeContext. + c. Let env be NewDeclarativeEnvironment(calleeEnv). + d. Let envRec be env's EnvironmentRecord. + [...] +flags: [noStrict] +---*/ + +var x = 'outside'; +var probe1, probe2; + +(( + _ = probe1 = function() { return x; }, + ...[__ = (eval('var x = "inside";'), probe2 = function() { return x; })] + ) => { +})(); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-close.js b/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-close.js new file mode 100644 index 0000000000..97d33e95c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-close.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +// A parameter expression is necessary to trigger the creation of the scope +// under test. +((_ = null) => { + var x = 'inside'; + probe = function() { return x; }; +})(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-open.js b/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-open.js new file mode 100644 index 0000000000..6f6f12b23a --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/scope-paramsbody-var-open.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +((_ = probeParams = function() { return x; }) => { + var x = 'inside'; + probeBody = function() { return x; }; +})(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/shell.js b/js/src/tests/test262/language/expressions/arrow-function/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly-missing.js b/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly-missing.js new file mode 100644 index 0000000000..78c0ab018f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly-missing.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Statement body needs braces, must use 'return' explicitly if not void +---*/ +var plusOne = v => { + v + 1; +}; + +assert.sameValue(plusOne(1), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly.js b/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly.js new file mode 100644 index 0000000000..323a6188e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/statement-body-requires-braces-must-return-explicitly.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Statement body needs braces, must use 'return' explicitly if not void +---*/ +var plusOne = v => { + return v + 1; +}; + +assert.sameValue(plusOne(1), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/strict-strict.js b/js/src/tests/test262/language/expressions/arrow-function/strict-strict.js new file mode 100644 index 0000000000..7482b76d49 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/strict-strict.js @@ -0,0 +1,25 @@ +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.16 +description: > + Runtime Semantics: Evaluation + + 1. If the function code for this ArrowFunction is strict mode code (10.2.1), + let strict be true. Otherwise let strict be false. + ... + +flags: [onlyStrict] +---*/ +assert.throws(ReferenceError, function() { + var af = _ => { + foo = 1; + }; + + af(); +}); + +assert.sameValue(typeof foo, "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-arguments.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-arguments.js new file mode 100644 index 0000000000..b12c83bbef --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-arguments.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + Parameter named "arguments", non-strict + +flags: [noStrict] +---*/ +var af = arguments => arguments; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-assignmentexpression.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-assignmentexpression.js new file mode 100644 index 0000000000..03f04c63ad --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-assignmentexpression.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator not present + ArrowParameters[Yield] : BindingIdentifier + ConciseBody[In] : AssignmentExpression[?In] +---*/ +var af = x => x; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-functionbody.js new file mode 100644 index 0000000000..7cec13a842 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-concisebody-functionbody.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + ConciseBody[In] : + ... + { FunctionBody } +---*/ +var af = BindingIdentifier => { + return BindingIdentifier; +}; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-eval.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-eval.js new file mode 100644 index 0000000000..385fd4d096 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-eval.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + Parameter named "eval", non-strict + +flags: [noStrict] +---*/ +var af = eval => eval; + + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-assignmentexpression.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-assignmentexpression.js new file mode 100644 index 0000000000..8ed35e6169 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-assignmentexpression.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : AssignmentExpression[?In] +---*/ +var af = x => +x; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-functionbody.js new file mode 100644 index 0000000000..4a61c2e8bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-lineterminator-concisebody-functionbody.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody[?In] + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } +---*/ +var af = x => +{ return x }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-yield.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-yield.js new file mode 100644 index 0000000000..7cf558babc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-yield.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + Parameter named "yield", non-strict + +flags: [noStrict] +---*/ +var af = yield => 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-assignmentexpression.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-assignmentexpression.js new file mode 100644 index 0000000000..8856b010c5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-assignmentexpression.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator not present + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : [lookahead ≠ { ] AssignmentExpression[?In] +---*/ +var af = (x) => x; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-functionbody.js new file mode 100644 index 0000000000..97273dbf1b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-concisebody-functionbody.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } +---*/ +var af = (x) => { return x }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-arguments.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-arguments.js new file mode 100644 index 0000000000..90b766b93e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-arguments.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + Parameter named "arguments", non-strict + +flags: [noStrict] +---*/ +var af = (arguments) => arguments; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-eval.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-eval.js new file mode 100644 index 0000000000..e23a1e2131 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-eval.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + Parameter named "eval", non-strict + +flags: [noStrict] +---*/ +var af = (eval) => eval; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-yield.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-yield.js new file mode 100644 index 0000000000..b8281168bb --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-formalparameters-yield.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + Parameter named "yield", non-strict + +flags: [noStrict] +---*/ +var af = (yield) => 1; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-includes-rest-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-includes-rest-concisebody-functionbody.js new file mode 100644 index 0000000000..e6993c463e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-includes-rest-concisebody-functionbody.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody[?In] + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } + + Includes ...rest +---*/ +var af = (x, ...y) => { return [x, y.length]; }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1, 1, 1)[0], 1); +assert.sameValue(af(1, 1, 1)[1], 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-1.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-1.js new file mode 100644 index 0000000000..af0755053b --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-1.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + +---*/ +var af = (x = 1) => x; + + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(), 1); +assert.sameValue(af(2), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-2.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-2.js new file mode 100644 index 0000000000..a1a1989076 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-initialize-2.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + 12.14.5 + ---*/ +var af = ({x = 1}) => x; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af({}), 1); +assert.sameValue(af({x: 2}), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-assignmentexpression.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-assignmentexpression.js new file mode 100644 index 0000000000..50d8972a40 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-assignmentexpression.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator not present + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : [lookahead ≠ { ] AssignmentExpression[?In] +---*/ +var af = (x) => +x; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-functionbody.js new file mode 100644 index 0000000000..3b46652fbf --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-lineterminator-concisebody-functionbody.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody[?In] + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } +---*/ +var af = (x) => +{ return x }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-concisebody-functionbody.js new file mode 100644 index 0000000000..3900da74e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-concisebody-functionbody.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody[?In] + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } + + Includes ...rest +---*/ +var af = (...x) => { return x.length; }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1, 1, 1), 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-lineterminator-concisebody-functionbody.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-lineterminator-concisebody-functionbody.js new file mode 100644 index 0000000000..e55050789d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/arrowparameters-cover-rest-lineterminator-concisebody-functionbody.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + LineTerminator between arrow and ConciseBody[?In] + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList[?Yield] + ConciseBody[In] : { FunctionBody } + + Includes ...rest +---*/ +var af = (...x) => +{ return x.length; }; + +assert.sameValue(typeof af, "function"); +assert.sameValue(af(1, 1, 1), 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/browser.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-futurereservedword.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-futurereservedword.js new file mode 100644 index 0000000000..6cc74682f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-futurereservedword.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + + (12.1) + BindingIdentifier[Yield] : + Identifier[~Yield] yield + + Identifier : + IdentifierName but not ReservedWord + + ReservedWord : FutureReservedWord + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = enum => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-strict-futurereservedword-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-strict-futurereservedword-strict.js new file mode 100644 index 0000000000..0e6d8bdfe2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier-strict-futurereservedword-strict.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + + (12.1) + BindingIdentifier[Yield] : + Identifier[~Yield] yield + + Identifier : + IdentifierName but not ReservedWord + + ReservedWord : FutureReservedWord + + Strict Mode + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = package => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier.js new file mode 100644 index 0000000000..1d65d0e4cc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-identifier.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + + (12.1) + BindingIdentifier[Yield] : + Identifier[~Yield] yield + + Identifier : + IdentifierName but not ReservedWord + + ReservedWord : Keyword + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = switch => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-arguments-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-arguments-strict.js new file mode 100644 index 0000000000..05f1465dad --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-arguments-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + No parameter named "arguments" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = arguments => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-eval-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-eval-strict.js new file mode 100644 index 0000000000..79c081d343 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-eval-strict.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + + No parameter named "eval" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = eval => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-yield-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-yield-strict.js new file mode 100644 index 0000000000..ac5aa03501 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-no-yield-strict.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + BindingIdentifier[?Yield] + ... + + + No parameter named "yield" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = yield => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-rest.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-rest.js new file mode 100644 index 0000000000..5a58c57305 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-bindingidentifier-rest.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowParameters : BindingIdentifier[?Yield] + + Includes ...rest + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ...x => x; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-arguments-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-arguments-strict.js new file mode 100644 index 0000000000..3344c6a634 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-arguments-strict.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + No parameters named "arguments" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = (arguments) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-1.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-1.js new file mode 100644 index 0000000000..4cd5ca7a5e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-1.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ArrayBindingPattern + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = (x, [x]) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-2.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-2.js new file mode 100644 index 0000000000..003f249d87 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-2.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ArrayBindingPattern + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ([x, x]) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-3.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-3.js new file mode 100644 index 0000000000..9dece76314 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-array-3.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ArrayBindingPattern + + BindingRestElement + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ([x], ...x) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-1.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-1.js new file mode 100644 index 0000000000..41381e40bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-1.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = (x, {x}) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-2.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-2.js new file mode 100644 index 0000000000..575980a66d --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-2.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + BindingPropertyList + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = (x, {y: x}) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-3.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-3.js new file mode 100644 index 0000000000..b4168054e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-3.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + BindingPropertyList + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ({x}, {y: x}) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-4.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-4.js new file mode 100644 index 0000000000..995f13fc5c --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-4.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + BindingPropertyList + + BindingRestElement + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ({x}, ...x) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-5.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-5.js new file mode 100644 index 0000000000..7115a09a43 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-5.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + BindingPropertyList + + BindingRestElement + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ({y: x}, ...x) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-6.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-6.js new file mode 100644 index 0000000000..a6814bd5cc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-binding-object-6.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + ObjectBindingPattern + + BindingPropertyList + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = ({y: x, x}) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-rest.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-rest.js new file mode 100644 index 0000000000..e281cf838f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates-rest.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + No duplicates, rest + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = (x, ...x) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates.js new file mode 100644 index 0000000000..d6e51befbc --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-duplicates.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + No duplicates + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = (x, x) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-eval-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-eval-strict.js new file mode 100644 index 0000000000..d2e701663f --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-eval-strict.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + CoverParenthesizedExpressionAndArrowParameterList, refined by: + + ArrowFormalParameters[Yield, GeneratorParameter] : + ( StrictFormalParameters[?Yield, ?GeneratorParameter] ) + + No parameters named "eval" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = (eval) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-yield-strict.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-yield-strict.js new file mode 100644 index 0000000000..2befc4eb73 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/arrowparameters-cover-no-yield-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2.1 +description: > + ArrowParameters[Yield] : + ... + CoverParenthesizedExpressionAndArrowParameterList[?Yield] + + No parameter named "yield" + +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); +var af = (yield) => 1; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters-expression-body.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters-expression-body.js new file mode 100644 index 0000000000..d8dd947b51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters-expression-body.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = x +=> x; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters.js new file mode 100644 index 0000000000..9a36c388c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid-parenless-parameters.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + No parens around ArrowParameters + +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = x +=> {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid.js new file mode 100644 index 0000000000..fa3eb353e1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/asi-restriction-invalid.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + ArrowFunction[In, Yield] : + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var af = () +=> {}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/browser.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/browser.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/shell.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/use-strict-with-non-simple-param.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/use-strict-with-non-simple-param.js new file mode 100644 index 0000000000..c8871d9add --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/early-errors/use-strict-with-non-simple-param.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arrow-function-definitions-static-semantics-early-errors +description: > + A SyntaxError is thrown if an arrow function contains a non-simple parameter list and a UseStrict directive. +info: | + Static Semantics: Early Errors + + It is a Syntax Error if ContainsUseStrict of ConciseBody is true and IsSimpleParameterList of ArrowParameters is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var f = (a = 0) => { + "use strict"; +}; diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/shell.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/shell.js diff --git a/js/src/tests/test262/language/expressions/arrow-function/syntax/variations.js b/js/src/tests/test262/language/expressions/arrow-function/syntax/variations.js new file mode 100644 index 0000000000..0b11f13494 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/syntax/variations.js @@ -0,0 +1,16 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.2 +description: > + Syntax variations of valid Arrow Functions +---*/ + +assert.sameValue((() => 1)(), 1); +assert.sameValue((a => a + 1)(1), 2); +assert.sameValue((() => { return 3; })(), 3); +assert.sameValue((a => { return a + 3; })(1), 4); +assert.sameValue(((a, b) => a + b)(1, 4), 5); +assert.sameValue(((a, b) => { return a + b; })(1, 5), 6); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/throw-new.js b/js/src/tests/test262/language/expressions/arrow-function/throw-new.js new file mode 100644 index 0000000000..a1070a5572 --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/throw-new.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.3.3.1.1 +description: > + Runtime Semantics: EvaluateNew(constructProduction, arguments) + + ... + 8. If IsConstructor (constructor) is false, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { new (() => {}); }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/unscopables-with-in-nested-fn.js b/js/src/tests/test262/language/expressions/arrow-function/unscopables-with-in-nested-fn.js new file mode 100644 index 0000000000..3a2ed073ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/unscopables-with-in-nested-fn.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with-in-nested-fn.case +// - src/function-forms/default/arrow-function.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [globalThis, Symbol.unscopables] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (x) => { + (function() { + count++; + with (globalThis) { + count++; + assert.sameValue(v, 1, 'The value of `v` is 1'); + } + })(); + (function() { + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + })(); + assert.sameValue(v, 1, 'The value of `v` is 1'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/arrow-function/unscopables-with.js b/js/src/tests/test262/language/expressions/arrow-function/unscopables-with.js new file mode 100644 index 0000000000..7d9f27548e --- /dev/null +++ b/js/src/tests/test262/language/expressions/arrow-function/unscopables-with.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/unscopables-with.case +// - src/function-forms/default/arrow-function.template +/*--- +description: Symbol.unscopables behavior across scope boundaries (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +features: [globalThis, Symbol.unscopables] +flags: [generated, noStrict] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + ... + Let envRec be lex's EnvironmentRecord. + Let exists be ? envRec.HasBinding(name). + + HasBinding + + ... + If the withEnvironment flag of envRec is false, return true. + Let unscopables be ? Get(bindings, @@unscopables). + If Type(unscopables) is Object, then + Let blocked be ToBoolean(? Get(unscopables, N)). + If blocked is true, return false. + + (The `with` Statement) Runtime Semantics: Evaluation + + ... + Set the withEnvironment flag of newEnv’s EnvironmentRecord to true. + ... + +---*/ +let count = 0; +var v = 1; +globalThis[Symbol.unscopables] = { + v: true, +}; + +{ + count++; + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (x) => { + count++; + with (globalThis) { + count++; + assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`'); + } + count++; + var v = x; + with (globalThis) { + count++; + assert.sameValue(v, 10, 'The value of `v` is 10'); + v = 20; + } + assert.sameValue(v, 20, 'The value of `v` is 20'); + assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); + callCount = callCount + 1; +}; + +ref(10); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + + count++; +} +assert.sameValue(count, 6, 'The value of `count` is 6'); + +reportCompare(0, 0); |