diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/object')
1181 files changed, 63792 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/object/11.1.5-0-1.js b/js/src/tests/test262/language/expressions/object/11.1.5-0-1.js new file mode 100644 index 0000000000..e0211308e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5-0-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + it isn't clear what specific requirements of the specificaiton are being tested here. This test should + probably be replaced by some more targeted tests. AllenWB +es5id: 11.1.5-0-1 +description: Object literal - get set property +---*/ + + var s1 = "In getter"; + var s2 = "In setter"; + var s3 = "Modified by setter"; + var o; + eval("o = {get foo(){ return s1;},set foo(arg){return s2 = s3}};"); + +assert.sameValue(o.foo, s1, 'o.foo'); + + o.foo=10; + +assert.sameValue(s2, s3, 's2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5-0-2.js b/js/src/tests/test262/language/expressions/object/11.1.5-0-2.js new file mode 100644 index 0000000000..7b814cea8d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5-0-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + it isn't clear what specific requirements of the specificaiton are being tested here. This test should + probably be replaced by some more targeted tests. AllenWB +es5id: 11.1.5-0-2 +description: Object literal - multiple get set properties +---*/ + + var s1 = "First getter"; + var s2 = "First setter"; + var s3 = "Second getter"; + var o; + eval("o = {get foo(){ return s1;},set foo(arg){return s2 = s3}, get bar(){ return s3}, set bar(arg){ s3 = arg;}};"); + +assert.sameValue(o.foo, s1, 'o.foo'); + + o.foo = 10; + +assert.sameValue(s2, s3, 's2'); +assert.sameValue(o.bar, s3, 'o.bar'); + + o.bar = "Second setter"; + +assert.sameValue(o.bar, "Second setter", 'o.bar'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5-1gs-strict.js b/js/src/tests/test262/language/expressions/object/11.1.5-1gs-strict.js new file mode 100644 index 0000000000..9a074ade4c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5-1gs-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5-1gs +description: > + Strict Mode - SyntaxError is thrown when 'eval' occurs as the + Identifier in a PropertySetParameterList of a PropertyAssignment + that is contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +var obj = { set _11_1_5_1_fun(eval) {}}; diff --git a/js/src/tests/test262/language/expressions/object/11.1.5-2gs.js b/js/src/tests/test262/language/expressions/object/11.1.5-2gs.js new file mode 100644 index 0000000000..93e30cd5d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5-2gs.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5-2gs +description: > + Duplicate definitions of data properties are allowed in ObjectLiterals. +---*/ + +var obj = { _11_1_5_2_gs: 10, _11_1_5_2_gs: 20 }; +assert.sameValue(obj._11_1_5_2_gs, 20); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_3-3-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_3-3-1.js new file mode 100644 index 0000000000..0459867921 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_3-3-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyNameAndValueList : PropertyAssignment + 3.Call the [[DefineOwnProperty]] internal method of obj with arguments propId.name, propId.descriptor, and false. +es5id: 11.1.5_3-3-1 +description: > + Object initialization using PropertyNameAndValueList + (PropertyAssignment) when property (read-only) exists in + Object.prototype (step 3) +---*/ + + Object.defineProperty(Object.prototype, "prop", { + value: 100, + writable: false, + configurable: true + }); + var obj = { prop: 12 }; + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, 12, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_4-4-a-3.js b/js/src/tests/test262/language/expressions/object/11.1.5_4-4-a-3.js new file mode 100644 index 0000000000..e6b7e29509 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_4-4-a-3.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment + 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + a. This production is contained in strict code and IsDataDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true +es5id: 11.1.5_4-4-a-3 +description: > + Object literal - Duplicate data property name allowed gets last + defined value +---*/ + + var o = eval("({foo:0,foo:1});"); + +assert.sameValue(o.foo, 1, 'o.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_4-4-b-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_4-4-b-1.js new file mode 100644 index 0000000000..4eb10c542a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_4-4-b-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-b-1 +description: > + Object literal - No SyntaxError if a data property definition is + followed by get accessor definition with the same name +---*/ + + eval("({foo : 1, get foo(){}});"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_4-5-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_4-5-1.js new file mode 100644 index 0000000000..e4857ae9f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_4-5-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment + 5.Call the [[DefineOwnProperty]] internal method of obj with arguments propId.name, propId.descriptor, and false. +es5id: 11.1.5_4-5-1 +description: > + Object initialization using PropertyNameAndValueList + (PropertyNameAndValueList , PropertyAssignment) when property + (read-only) exists in Object.prototype (Step 5) +---*/ + + Object.defineProperty(Object.prototype, "prop2", { + value: 100, + writable: false, + configurable: true + }); + + var obj = { prop1: 101, prop2: 12 }; + +assert(obj.hasOwnProperty("prop2"), 'obj.hasOwnProperty("prop2") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_5-4-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_5-4-1.js new file mode 100644 index 0000000000..360509f4a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_5-4-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyAssignment : PropertyName : AssignmentExpression + 4.Let desc be the Property Descriptor{[[Value]]: propValue, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true} +es5id: 11.1.5_5-4-1 +description: Object literal - property descriptor for assignment expression +---*/ + + var o = {foo : 1}; + var desc = Object.getOwnPropertyDescriptor(o,"foo"); + +assert.sameValue(desc.value, 1, 'desc.value'); +assert.sameValue(desc.writable, true, 'desc.writable'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_6-3-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_6-3-1.js new file mode 100644 index 0000000000..17fd5462aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_6-3-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyAssignment : get PropertyName ( ) { FunctionBody } + 3.Let desc be the Property Descriptor{[[Get]]: closure, [[Enumerable]]: true, [[Configurable]]: true} +es5id: 11.1.5_6-3-1 +description: Object literal - property descriptor for get property assignment +---*/ + + var o; + eval("o = {get foo(){return 1;}};"); + var desc = Object.getOwnPropertyDescriptor(o,"foo"); + +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_6-3-2.js b/js/src/tests/test262/language/expressions/object/11.1.5_6-3-2.js new file mode 100644 index 0000000000..a5afa1e0c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_6-3-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyAssignment : get PropertyName ( ) { FunctionBody } + 3.Let desc be the Property Descriptor{[[Get]]: closure, [[Enumerable]]: true, [[Configurable]]: true} +es5id: 11.1.5_6-3-2 +description: > + Object literal - property descriptor for get property assignment + should not create a set function +---*/ + + var o; + eval("o = {get foo(){return 1;}};"); + var desc = Object.getOwnPropertyDescriptor(o,"foo"); + +assert.sameValue(desc.set, undefined, 'desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_7-3-1.js b/js/src/tests/test262/language/expressions/object/11.1.5_7-3-1.js new file mode 100644 index 0000000000..ad09c800fd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_7-3-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyAssignment : set PropertyName( PropertySetParameterList ) { FunctionBody } + 3.Let desc be the Property Descriptor{[[Set]]: closure, [[Enumerable]]: true, [[Configurable]]: true} +es5id: 11.1.5_7-3-1 +description: Object literal - property descriptor for set property assignment +---*/ + + var o; + eval("o = {set foo(arg){return 1;}};"); + var desc = Object.getOwnPropertyDescriptor(o,"foo"); + +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/11.1.5_7-3-2.js b/js/src/tests/test262/language/expressions/object/11.1.5_7-3-2.js new file mode 100644 index 0000000000..954f45f87e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/11.1.5_7-3-2.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyAssignment : get PropertyName ( ) { FunctionBody } + 3.Let desc be the Property Descriptor{[[Get]]: closure, [[Enumerable]]: true, [[Configurable]]: true} +es5id: 11.1.5_7-3-2 +description: > + Object literal - property descriptor for set property assignment + should not create a get function +---*/ + + var o; + eval("o = {set foo(arg){}};"); + var desc = Object.getOwnPropertyDescriptor(o,"foo"); + +assert.sameValue(desc.get, undefined, 'desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A1.1.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.1.js new file mode 100644 index 0000000000..a4c27bd345 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ObjectLiteral: { }" +es5id: 11.1.5_A1.1 +description: > + Checking various properteis of the object defined with "var object + = {}" +---*/ + +var object = {}; + +//CHECK#1 +if (typeof object !== "object") { + throw new Test262Error('#1: var object = {}; typeof object === "object". Actual: ' + (typeof object)); +} + +//CHECK#2 +if (object instanceof Object !== true) { + throw new Test262Error('#2: var object = {}; object instanceof Object === true'); +} + +//CHECK#3 +if (object.toString !== Object.prototype.toString) { + throw new Test262Error('#3: var object = {}; object.toString === Object.prototype.toString. Actual: ' + (object.toString)); +} + +//CHECK#4 +if (object.toString() !== "[object Object]") { + throw new Test262Error('#4: var object = {}; object.toString === "[object Object]". Actual: ' + (object.toString)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A1.2.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.2.js new file mode 100644 index 0000000000..0156e45f19 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.2.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ObjectLiteral: { NumericLiteral : + AssignmentExpression} +es5id: 11.1.5_A1.2 +description: > + Checking various properteis and contents of the object defined + with "var object = {1 : true}" +---*/ + +var object = {1 : true}; + +//CHECK#1 +if (typeof object !== "object") { + throw new Test262Error('#1: var object = {1 : true}; typeof object === "object". Actual: ' + (typeof object)); +} + +//CHECK#2 +if (object instanceof Object !== true) { + throw new Test262Error('#2: var object = {1 : true}; object instanceof Object === true'); +} + +//CHECK#3 +if (object.toString !== Object.prototype.toString) { + throw new Test262Error('#3: var object = {1 : true}; object.toString === Object.prototype.toString. Actual: ' + (object.toString)); +} + +//CHECK#4 +if (object[1] !== true) { + throw new Test262Error('#4: var object = {1 : true}; object[1] === true'); +} + +//CHECK#5 +if (object["1"] !== true) { + throw new Test262Error('#5: var object = {1 : true}; object["1"] === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A1.3.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.3.js new file mode 100644 index 0000000000..43574f5daa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.3.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ObjectLiteral: { StringLiteral : + AssignmentExpression} +es5id: 11.1.5_A1.3 +description: > + Checking various properteis and contents of the object defined + with "var object = {"x" : true}" +---*/ + +var object = {"x" : true}; + +//CHECK#1 +if (typeof object !== "object") { + throw new Test262Error('#1: var object = {"x" : true}; typeof object === "object". Actual: ' + (typeof object)); +} + +//CHECK#2 +if (object instanceof Object !== true) { + throw new Test262Error('#2: var object = {"x" : true}; object instanceof Object === true'); +} + +//CHECK#3 +if (object.toString !== Object.prototype.toString) { + throw new Test262Error('#3: var object = {"x" : true}; object.toString === Object.prototype.toString. Actual: ' + (object.toString)); +} + +//CHECK#4 +if (object["x"] !== true) { + throw new Test262Error('#4: var object = {"x" : true}; object["x"] === true'); +} + +//CHECK#5 +if (object.x !== true) { + throw new Test262Error('#5: var object = {"x" : true}; object.x === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A1.4.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.4.js new file mode 100644 index 0000000000..055b4597bf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A1.4.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ObjectLiteral: { Identifier : + AssignmentExpression} +es5id: 11.1.5_A1.4 +description: > + Checking various properteis and contents of the object defined + with "var object = {prop : true}" +---*/ + +var object = {prop : true}; + +//CHECK#1 +if (typeof object !== "object") { + throw new Test262Error('#1: var object = {prop : true}; typeof object === "object". Actual: ' + (typeof object)); +} + +//CHECK#2 +if (object instanceof Object !== true) { + throw new Test262Error('#2: var object = {prop : true}; object instanceof Object === true'); +} + +//CHECK#3 +if (object.toString !== Object.prototype.toString) { + throw new Test262Error('#3: var object = {prop : true}; object.toString === Object.prototype.toString. Actual: ' + (object.toString)); +} + +//CHECK#4 +if (object["prop"] !== true) { + throw new Test262Error('#4: var object = {prop : true}; object["prop"] === true'); +} + +//CHECK#5 +if (object.prop !== true) { + throw new Test262Error('#5: var object = {prop : true}; object.prop === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A2.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A2.js new file mode 100644 index 0000000000..543c481149 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A2.js @@ -0,0 +1,96 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Evaluate the production ObjectLiteral: { PropertyName : + AssignmentExpression } +es5id: 11.1.5_A2 +description: Creating property "prop" of various types(boolean, number and etc.) +---*/ + +//CHECK#1 +var x = true; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#1: var x = true; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#2 +var x = new Boolean(true); +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#2: var x = new Boolean(true); var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#3 +var x = 1; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#3: var x = 1; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#4 +var x = new Number(1); +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#4: var x = new Number(1); var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#5 +var x = "1"; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#5: var x = "1"; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#6 +var x = new String(1); +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#6: var x = new String(1); var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#7 +var x = undefined; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#7: var x = undefined; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#8 +var x = null; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#8: var x = null; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#9 +var x = {}; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#9: var x = {}; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#10 +var x = [1,2]; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#10: var x = [1,2]; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#11 +var x = function() {}; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#11: var x = function() {}; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +//CHECK#12 +var x = this; +var object = {prop : x}; +if (object.prop !== x) { + throw new Test262Error('#12: var x = this; var object = {prop : x}; object.prop === x. Actual: ' + (object.prop)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A3.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A3.js new file mode 100644 index 0000000000..bd8a673074 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A3.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Evaluate the production ObjectLiteral: { PropertyNameAndValueList }" +es5id: 11.1.5_A3 +description: > + Creating the object defined with "var object = {0 : 1, "1" : "x", + o : {}}" +---*/ + +var object = {0 : 1, "1" : "x", o : {}}; + +//CHECK#1 +if (object[0] !== 1) { + throw new Test262Error('#1: var object = {0 : 1; "1" : "x"; o : {}}; object[0] === 1. Actual: ' + (object[0])); +} + +//CHECK#2 +if (object["1"] !== "x") { + throw new Test262Error('#2: var object = {0 : 1; "1" : "x"; o : {}}; object["1"] === "x". Actual: ' + (object["1"])); +} + +//CHECK#3 +if (typeof object.o !== "object") { + throw new Test262Error('#1: var object = {0 : 1; "1" : "x"; o : {}}; typeof object.o === "object". Actual: ' + (typeof object.o)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A4.1.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.1.js new file mode 100644 index 0000000000..c4f19a24b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.1.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The PropertyName is not really a BooleanLiteral +es5id: 11.1.5_A4.1 +description: "Checking if execution of \"var object = {true : 1}\" does not fail" +---*/ + +//CHECK#1 +var object = {true : 1}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A4.2.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.2.js new file mode 100644 index 0000000000..132c41b4c5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.2.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The PropertyName is not really a nullLiteral +es5id: 11.1.5_A4.2 +description: "Checking if execution of \"var object = {null : true}\" does not fail" +---*/ + +//CHECK#1 +var object = {null : true}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/S11.1.5_A4.3.js b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.3.js new file mode 100644 index 0000000000..dd5334f3e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/S11.1.5_A4.3.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The PropertyName is undefined, ToString(BooleanLiteral), + ToString(nullLiteral) +es5id: 11.1.5_A4.3 +description: "Creating properties with following names: undefined, 'true', 'null'" +---*/ + +//CHECK#1 +var object = {undefined : true}; +if (object.undefined !== true) { + throw new Test262Error('#1: var object = {undefined : true}; object.undefined === true'); +} + +//CHECK#2 +var object = {undefined : true}; +if (object["undefined"] !== true) { + throw new Test262Error('#2: var object = {undefined : true}; object["undefined"] === true'); +} + +//CHECK#3 +var object = {"true" : true}; +if (object["true"] !== true) { + throw new Test262Error('#3: var object = {"true" : true}; object["true"] === true'); +} + +//CHECK#4 +var object = {"null" : true}; +if (object["null"] !== true) { + throw new Test262Error('#4: var object = {"null" : true}; object["null"] === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-duplicate-computed.js b/js/src/tests/test262/language/expressions/object/__proto__-duplicate-computed.js new file mode 100644 index 0000000000..99ac9e1374 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-duplicate-computed.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-__proto__-property-names-in-object-initializers +es6id: B.3.1 +description: > + The syntax error for duplicate `__proto__` property is not valid if the duplicate is a + ComputedPropertyName +info: | + B.3.1__proto__ Property Names in Object Initializers + + It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate + entries for "__proto__" and at least two of those entries were obtained from productions of + the form + PropertyDefinition : PropertyName : AssignmentExpression . + + 12.2.6.6 Static Semantics: PropertyNameList + + ... + 3. Append PropName of PropertyDefinition to the end of list. + ... + + 12.2.6.5 Static Semantics: PropName + + ComputedPropertyName : [ AssignmentExpression ] + 1. Return empty. +---*/ + +var obj; +var proto = {}; +var ownProp = {}; + +obj = { + __proto__: proto, + ['__proto__']: {}, + ['__proto__']: ownProp +}; + +assert.sameValue( + Object.getPrototypeOf(obj), + proto, + 'prototype is defined' +); + +assert( + Object.prototype.hasOwnProperty.call(obj, '__proto__'), + 'has own property __proto__' +); + +assert.sameValue( + obj.__proto__, + ownProp, + 'own property value' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-duplicate.js b/js/src/tests/test262/language/expressions/object/__proto__-duplicate.js new file mode 100644 index 0000000000..3506c2819c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-duplicate.js @@ -0,0 +1,24 @@ +// |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-__proto__-property-names-in-object-initializers +es6id: B.3.1 +description: Duplicate `__proto__` property +info: | + It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains + any duplicate entries for "__proto__" and at least two of those entries + were obtained from productions of the form + PropertyDefinition : PropertyName : AssignmentExpression . +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + __proto__: null, + other: null, + '__proto__': null +}); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-fn-name.js b/js/src/tests/test262/language/expressions/object/__proto__-fn-name.js new file mode 100644 index 0000000000..57a654afd7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-fn-name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.3.1 +description: Function name is not assigned based on the property name +info: | + [...] + 6. If propKey is the String value "__proto__" and if + IsComputedPropertyKey(propKey) is false, then + a. If Type(propValue) is either Object or Null, then + i. Return object.[[SetPrototypeOf]](propValue). + b. Return NormalCompletion(empty). + 7. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, propKey). +---*/ + +var o; + +o = { + __proto__: function() {} +}; + +assert(o.__proto__.name !== '__proto__'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup-shorthand.js b/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup-shorthand.js new file mode 100644 index 0000000000..e22f33e83e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup-shorthand.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer +description: Permitted duplicate `__proto__` property (shorthand) +info: | + Annex B defines an early error for duplicate PropertyName of `__proto__`, + but this does not apply to properties created from other productions. + + B.3.1 __proto__ Property Names in Object Initializers + + It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains + any duplicate entries for "__proto__" and at least two of those entries + were obtained from productions of the form + PropertyDefinition : PropertyName : AssignmentExpression . +---*/ + +var __proto__ = 2; +var obj = { + __proto__, + __proto__, +}; + +assert(obj.hasOwnProperty("__proto__")); +assert.sameValue(obj.__proto__, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup.js b/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup.js new file mode 100644 index 0000000000..778b7aef71 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-permitted-dup.js @@ -0,0 +1,39 @@ +// 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-object-initializer +description: Permitted duplicate `__proto__` property +info: | + Annex B defines an early error for duplicate PropertyName of `__proto__`, + but this does not apply to properties created from other productions. + + B.3.1 __proto__ Property Names in Object Initializers + + It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains + any duplicate entries for "__proto__" and at least two of those entries + were obtained from productions of the form + PropertyDefinition : PropertyName : AssignmentExpression . +features: [generators, async-functions, async-iteration, __proto__] +---*/ + +var obj = { + __proto__: null, + __proto_: null, + __proto: null, + _proto__: null, + proto__: null, + ['__proto__']: null, + __proto__() {}, + * __proto__() {}, + async __proto__() {}, + async * __proto__() {}, + get __proto__() { return 33; }, + set __proto__(_) { return 44; } +}; + +var desc = Object.getOwnPropertyDescriptor(obj, '__proto__'); + +assert.sameValue(desc.get(), 33); +assert.sameValue(desc.set(), 44); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-poisoned-object-prototype.js b/js/src/tests/test262/language/expressions/object/__proto__-poisoned-object-prototype.js new file mode 100644 index 0000000000..962353cf83 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-poisoned-object-prototype.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-__proto__-property-names-in-object-initializers +description: > + The value of the `__proto__` property key is assigned to the [[Prototype]]. + Object.prototype.__proto__ setter should not be called. +info: | + __proto__ Property Names in Object Initializers + + PropertyDefinition : PropertyName : AssignmentExpression + + [...] + 7. If isProtoSetter is true, then + a. If Type(propValue) is either Object or Null, then + i. Return object.[[SetPrototypeOf]](propValue). +---*/ + +Object.defineProperty(Object.prototype, '__proto__', { + set: function() { + throw new Test262Error('should not be called'); + }, +}); + +var proto = {}; + +var object = { + __proto__: proto +}; + +assert(!object.hasOwnProperty('__proto__')); +assert.sameValue(Object.getPrototypeOf(object), proto); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-value-non-object.js b/js/src/tests/test262/language/expressions/object/__proto__-value-non-object.js new file mode 100644 index 0000000000..0b5733a7bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-value-non-object.js @@ -0,0 +1,92 @@ +// 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-__proto__-property-names-in-object-initializers +es6id: B.3.1 +description: > + The value of the `__proto__` property key is not assigned to the + [[Prototype]] internal slot, nor to a property named "__proto__" (non-Object, + non-null value) +info: | + ... + 6. If propKey is the String value "__proto__" and if + IsComputedPropertyKey(propKey) is false, then + a. If Type(propValue) is either Object or Null, then + [...] + b. Return NormalCompletion(empty). +features: [Symbol] +---*/ + +var object; + +object = { + __proto__: undefined +}; +assert.sameValue( + Object.getPrototypeOf(object), + Object.prototype, + 'prototype (undefined)' +); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), + undefined, + 'property (undefined)' +); + +object = { + __proto__: 1 +}; +assert.sameValue( + Object.getPrototypeOf(object), + Object.prototype, + 'prototype (numeric primitive)' +); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), + undefined, + 'property (numeric primitive)' +); + +object = { + __proto__: false +}; +assert.sameValue( + Object.getPrototypeOf(object), + Object.prototype, + 'prototype (boolean primitive)' +); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), + undefined, + 'property (boolean primitive)' +); + +object = { + __proto__: 'string literal' +}; +assert.sameValue( + Object.getPrototypeOf(object), + Object.prototype, + 'prototype (string primitive)' +); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), + undefined, + 'property (string primitive)' +); + +object = { + __proto__: Symbol('') +}; +assert.sameValue( + Object.getPrototypeOf(object), + Object.prototype, + 'prototype (symbol)' +); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), + undefined, + 'property (symbol)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-value-null.js b/js/src/tests/test262/language/expressions/object/__proto__-value-null.js new file mode 100644 index 0000000000..eb00e102d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-value-null.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-__proto__-property-names-in-object-initializers +es6id: B.3.1 +description: > + The value of the `__proto__` property key is assigned to the [[Prototype]] + internal slot (null value) +info: | + ... + 6. If propKey is the String value "__proto__" and if + IsComputedPropertyKey(propKey) is false, then + a. If Type(propValue) is either Object or Null, then + i. Return object.[[SetPrototypeOf]](propValue). +---*/ + +var object = { + __proto__: null +}; + +assert.sameValue(Object.getPrototypeOf(object), null); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), undefined +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/__proto__-value-obj.js b/js/src/tests/test262/language/expressions/object/__proto__-value-obj.js new file mode 100644 index 0000000000..45cb2dcf84 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/__proto__-value-obj.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-__proto__-property-names-in-object-initializers +es6id: B.3.1 +description: > + The value of the `__proto__` property key is assigned to the [[Prototype]] + internal slot (Object value) +info: | + __proto__ Property Names in Object Initializers + + ... + 6. If propKey is the String value "__proto__" and if IsComputedPropertyKey(propKey) is false, then + a. If Type(propValue) is either Object or Null, then + i. Return object.[[SetPrototypeOf]](propValue). + b. Return NormalCompletion(empty). + ... +---*/ + +var proto = {}; + +var object = { + __proto__: proto +}; + +assert.sameValue(Object.getPrototypeOf(object), proto); +assert.sameValue( + Object.getOwnPropertyDescriptor(object, '__proto__'), undefined +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-evaluation.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-evaluation.js new file mode 100644 index 0000000000..379b3926a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-evaluation.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-evaluation.case +// - src/accessor-names/error/obj.template +/*--- +description: Abrupt completion when evaluating expression (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ +var thrower = function() { + throw new Test262Error(); +}; + + +assert.throws(Test262Error, function() { + ({ + get [thrower()]() {} + }); +}, '`get` accessor'); + +assert.throws(Test262Error, function() { + ({ + set [thrower()](_) {} + }); +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-to-prop-key.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-to-prop-key.js new file mode 100644 index 0000000000..9e733e1fa0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-to-prop-key.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-to-prop-key.case +// - src/accessor-names/error/obj.template +/*--- +description: Abrupt completion when coercing to property key value (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + + 7.1.14 ToPropertyKey + + 1. Let key be ? ToPrimitive(argument, hint String). + + 7.1.1 ToPrimitive + + [...] + 7. Return ? OrdinaryToPrimitive(input, hint). + + 7.1.1.1 OrdinaryToPrimitive + + 5. For each name in methodNames in List order, do + [...] + 6. Throw a TypeError exception. +---*/ +var badKey = Object.create(null); + + +assert.throws(TypeError, function() { + ({ + get [badKey]() {} + }); +}, '`get` accessor'); + +assert.throws(TypeError, function() { + ({ + set [badKey](_) {} + }); +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-unresolvable.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-unresolvable.js new file mode 100644 index 0000000000..2100584729 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-err-unresolvable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-unresolvable.case +// - src/accessor-names/error/obj.template +/*--- +description: Abrupt completion when resolving reference value (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ + +assert.throws(ReferenceError, function() { + ({ + get [test262unresolvable]() {} + }); +}, '`get` accessor'); + +assert.throws(ReferenceError, function() { + ({ + set [test262unresolvable](_) {} + }); +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-in.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-in.js new file mode 100644 index 0000000000..5a74e16fee --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-in.js @@ -0,0 +1,37 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: > + AssignmentExpression may contain `in` keyword regardless of outer context +info: | + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var empty = Object.create(null); +var obj, value; + +for (obj = { get ['x' in empty]() { return 'via get'; } }; ; ) { + value = obj.false; + break; +} + +assert.sameValue(value, 'via get'); + +for (obj = { set ['x' in empty](param) { value = param; } }; ; ) { + obj.false = 'via set'; + break; +} + +assert.sameValue(value, 'via set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-expr.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-expr.js new file mode 100644 index 0000000000..b1d64c522e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-expr.js @@ -0,0 +1,41 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: > + The `yield` keyword behaves as a YieldExpression within a generator function +info: | + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +features: [generators] +---*/ + +var yieldSet, obj, iter; +function* g() { + obj = { + get [yield]() { return 'get yield'; }, + set [yield](param) { yieldSet = param; } + }; +} + +iter = g(); + +iter.next(); +iter.next('first'); +iter.next('second'); + +assert.sameValue(obj.first, 'get yield'); + +obj.second = 'set yield'; + +assert.sameValue(yieldSet, 'set yield'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-id.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-id.js new file mode 100644 index 0000000000..4c3a43b6c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed-yield-id.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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: > + The `yield` keyword behaves as an Identifier outside of a generator function +info: | + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +flags: [noStrict] +---*/ + +var yield = 'y'; +var yieldSet; +var obj = { + get [yield]() { return 'get yield'; }, + set [yield](param) { yieldSet = param; } +}; + +assert.sameValue(obj.y, 'get yield'); + +obj.y = 'set yield'; + +assert.sameValue(yieldSet, 'set yield'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-computed.js b/js/src/tests/test262/language/expressions/object/accessor-name-computed.js new file mode 100644 index 0000000000..c42ff64358 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-computed.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (AssignmentExpression) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ +var _; + + +var stringSet; +var obj = { + get [[_ = 'str' + 'ing']]() { return 'get string'; }, + set [[_ = 'str' + 'ing']](param) { stringSet = param; } +}; + +assert.sameValue(obj['string'], 'get string'); + +obj['string'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-binary.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-binary.js new file mode 100644 index 0000000000..1eb39223d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-binary.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-binary.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal in binary notation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [0b10]() { return 'get string'; }, + set [0b10](param) { stringSet = param; } +}; + +assert.sameValue(obj['2'], 'get string'); + +obj['2'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-exponent.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-exponent.js new file mode 100644 index 0000000000..30b76fd373 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-exponent.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-exponent.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal in exponent notation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [1E+9]() { return 'get string'; }, + set [1E+9](param) { stringSet = param; } +}; + +assert.sameValue(obj['1000000000'], 'get string'); + +obj['1000000000'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-hex.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-hex.js new file mode 100644 index 0000000000..852119ec08 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-hex.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-hex.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal in hexadecimal notation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [0x10]() { return 'get string'; }, + set [0x10](param) { stringSet = param; } +}; + +assert.sameValue(obj['16'], 'get string'); + +obj['16'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-leading-decimal.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-leading-decimal.js new file mode 100644 index 0000000000..002d0b215a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-leading-decimal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-leading-decimal.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal with leading decimal point) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [.1]() { return 'get string'; }, + set [.1](param) { stringSet = param; } +}; + +assert.sameValue(obj['0.1'], 'get string'); + +obj['0.1'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-non-canonical.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-non-canonical.js new file mode 100644 index 0000000000..78a293c9fb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-non-canonical.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-non-canonical.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal with non-canonical representation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [0.0000001]() { return 'get string'; }, + set [0.0000001](param) { stringSet = param; } +}; + +assert.sameValue(obj['1e-7'], 'get string'); + +obj['1e-7'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-octal.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-octal.js new file mode 100644 index 0000000000..a637032860 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-octal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-octal.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal in octal notation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [0o10]() { return 'get string'; }, + set [0o10](param) { stringSet = param; } +}; + +assert.sameValue(obj['8'], 'get string'); + +obj['8'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-zero.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-zero.js new file mode 100644 index 0000000000..7d4b7b5981 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-numeric-zero.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-zero.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (numeric literal zero) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get [0]() { return 'get string'; }, + set [0](param) { stringSet = param; } +}; + +assert.sameValue(obj['0'], 'get string'); + +obj['0'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-char-escape.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-char-escape.js new file mode 100644 index 0000000000..e59e0c7c7e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-char-escape.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-char-escape.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal containing a character escape sequence) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['character\tescape']() { return 'get string'; }, + set ['character\tescape'](param) { stringSet = param; } +}; + +assert.sameValue(obj['character escape'], 'get string'); + +obj['character escape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped-ext.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped-ext.js new file mode 100644 index 0000000000..b064df0327 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped-ext.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped-ext.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal 'default' w/ extended escape) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['def\u{61}ult']() { return 'get string'; }, + set ['def\u{61}ult'](param) { stringSet = param; } +}; + +assert.sameValue(obj['default'], 'get string'); + +obj['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped.js new file mode 100644 index 0000000000..5d3ae79251 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default-escaped.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal 'default' escaped) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['def\u0061ult']() { return 'get string'; }, + set ['def\u0061ult'](param) { stringSet = param; } +}; + +assert.sameValue(obj['default'], 'get string'); + +obj['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default.js new file mode 100644 index 0000000000..51390630f6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-default.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal 'default') (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['default']() { return 'get string'; }, + set ['default'](param) { stringSet = param; } +}; + +assert.sameValue(obj['default'], 'get string'); + +obj['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-double-quote.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-double-quote.js new file mode 100644 index 0000000000..32e393eae3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-double-quote.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-double-quote.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal using double quotes) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ["doubleQuote"]() { return 'get string'; }, + set ["doubleQuote"](param) { stringSet = param; } +}; + +assert.sameValue(obj["doubleQuote"], 'get string'); + +obj["doubleQuote"] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-empty.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-empty.js new file mode 100644 index 0000000000..2e55ecc9cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-empty.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-empty.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal, the empty string) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['']() { return 'get string'; }, + set [''](param) { stringSet = param; } +}; + +assert.sameValue(obj[''], 'get string'); + +obj[''] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-hex-escape.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-hex-escape.js new file mode 100644 index 0000000000..60f856c981 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-hex-escape.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-hex-escape.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal containing a hexadecimal escape sequence) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['hex\x45scape']() { return 'get string'; }, + set ['hex\x45scape'](param) { stringSet = param; } +}; + +assert.sameValue(obj['hexEscape'], 'get string'); + +obj['hexEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-line-continuation.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-line-continuation.js new file mode 100644 index 0000000000..7c72aa4884 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-line-continuation.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-line-continuation.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal containing LineContinuation) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['line\ +Continuation']() { return 'get string'; }, + set ['line\ +Continuation'](param) { stringSet = param; } +}; + +assert.sameValue(obj['lineContinuation'], 'get string'); + +obj['lineContinuation'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-single-quote.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-single-quote.js new file mode 100644 index 0000000000..f71aaa300a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-single-quote.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-single-quote.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal using single quotes) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['singleQuote']() { return 'get string'; }, + set ['singleQuote'](param) { stringSet = param; } +}; + +assert.sameValue(obj['singleQuote'], 'get string'); + +obj['singleQuote'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-unicode-escape.js b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-unicode-escape.js new file mode 100644 index 0000000000..1ea68b6ddf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/accessor-name-literal-string-unicode-escape.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-unicode-escape.case +// - src/accessor-names/default/obj.template +/*--- +description: Computed values as accessor property names (string literal containing a Unicode escape sequence) (Object initializer) +esid: sec-object-initializer-runtime-semantics-evaluation +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; +var obj = { + get ['unicod\u{000065}Escape']() { return 'get string'; }, + set ['unicod\u{000065}Escape'](param) { stringSet = param; } +}; + +assert.sameValue(obj['unicodeEscape'], 'get string'); + +obj['unicodeEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/browser.js b/js/src/tests/test262/language/expressions/object/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/browser.js diff --git a/js/src/tests/test262/language/expressions/object/computed-__proto__.js b/js/src/tests/test262/language/expressions/object/computed-__proto__.js new file mode 100644 index 0000000000..b50b1ec901 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/computed-__proto__.js @@ -0,0 +1,180 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: prod-PropertyDefinition +description: > + computed __proto__ property key is assigned to an own property +info: | + 12.2.6 Object Initializer + + PropertyDefinition[Yield, Await] : + PropertyName[?Yield, ?Await] : AssignmentExpression[+In, ?Yield, ?Await] + + PropertyName[Yield, Await] : + LiteralPropertyName + ComputedPropertyName[?Yield, ?Await] + + ComputedPropertyName[Yield, Await] : + [ AssignmentExpression[+In, ?Yield, ?Await] ] + + B.3.1__proto__ Property Names in Object Initializers + + ... + 5. If propKey is the String value "__proto__" and if IsComputedPropertyKey(propKey) + is false, then + a. If Type(propValue) is either Object or Null, then + i. Return object.[[SetPrototypeOf]](propValue). + b. Return NormalCompletion(empty). +features: [Symbol] +---*/ + +var obj; +var sample = {}; + +obj = { + ['__proto__']: sample +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (ordinary object)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (ordinary object)' +); +assert.sameValue( + obj.__proto__, + sample, + 'value is properly defined (ordinary object)' +); + +obj = { + ['__proto__']: null +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (null)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (null)' +); +assert.sameValue( + obj.__proto__, + null, + 'value is properly defined (null)' +); + +obj = { + ['__proto__']: undefined +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (undefined)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (undefined)' +); +assert.sameValue( + obj.__proto__, + undefined, + 'value is properly defined (undefined)' +); + +var func = function() {}; +obj = { + ['__proto__']: func +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (func)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (func)' +); +assert.sameValue( + obj.__proto__, + func, + 'value is properly defined (func)' +); + +var symbol = Symbol('Leo'); +obj = { + ['__proto__']: symbol +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (symbol)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (symbol)' +); +assert.sameValue( + obj.__proto__, + symbol, + 'value is properly defined (symbol)' +); + +obj = { + ['__proto__']: 42 +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (number)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (number)' +); +assert.sameValue( + obj.__proto__, + 42, + 'value is properly defined (number)' +); + +obj = { + ['__proto__']: '' +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (string)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (string)' +); +assert.sameValue( + obj.__proto__, + '', + 'value is properly defined (string)' +); + +obj = { + ['__proto__']: false +}; +assert.sameValue( + Object.getPrototypeOf(obj), + Object.prototype, + 'does not change the object prototype (boolean)' +); +assert( + obj.hasOwnProperty('__proto__'), + 'computed __proto__ property is set as an own property (boolean)' +); +assert.sameValue( + obj.__proto__, + false, + 'value is properly defined (boolean)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/computed-property-evaluation-order.js b/js/src/tests/test262/language/expressions/object/computed-property-evaluation-order.js new file mode 100644 index 0000000000..0a76ced416 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/computed-property-evaluation-order.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-propertydefinitionevaluation +description: > + Evaluation of PropertyDefinitionList occurs in order, and each + PropertyDefinition's PropertyName is evaluated before its + AssignmentExpression. +---*/ + +var counter = 0; +var o = { + [++counter]: ++counter, + [++counter]: ++counter, + [++counter]: ++counter, +} + +var keys = Object.getOwnPropertyNames(o); + +assert.sameValue(keys.length, 3, '3 PropertyDefinitions should result in 3 properties'); +assert.sameValue(keys[0], '1'); +assert.sameValue(o[keys[0]], 2); +assert.sameValue(keys[1], '3'); +assert.sameValue(o[keys[1]], 4); +assert.sameValue(keys[2], '5'); +assert.sameValue(o[keys[2]], 6); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/concise-generator.js b/js/src/tests/test262/language/expressions/object/concise-generator.js new file mode 100644 index 0000000000..eac0a596b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/concise-generator.js @@ -0,0 +1,29 @@ +// 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.2.5 +description: > + super method calls in object literal concise generator +features: [generators] +---*/ +var proto = { + method() { + return 42; + } +}; + +var object = { + *g() { + yield super.method(); + } +}; + +Object.setPrototypeOf(object, proto); + +assert.sameValue( + object.g().next().value, + 42, + "The value of `object.g().next().value` is `42`, after executing `Object.setPrototypeOf(object, proto);`, where `object " + String(object) + "`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cover-initialized-name.js b/js/src/tests/test262/language/expressions/object/cover-initialized-name.js new file mode 100644 index 0000000000..dadf23f952 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cover-initialized-name.js @@ -0,0 +1,33 @@ +// |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-object-initializer-static-semantics-early-errors +es6id: 12.2.6.1 +description: Initialized name is explicitly barred from object initializers +info: | + PropertyDefinition : CoverInitializedName + + - Always throw a Syntax Error if code matches this production. + + NOTE This production exists so that ObjectLiteral can serve as a cover + grammar for ObjectAssignmentPattern. It cannot occur in an actual object + initializer. + + 12.2.6 Object Initializer + + Syntax + + [...] + + CoverInitializedName[Yield]: + + IdentifierReference[?Yield] Initializer[+In, ?Yield] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ a = 1 }); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-break-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-break-escaped.js new file mode 100644 index 0000000000..ca96dd776e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-break-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/break-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: break is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ bre\u0061k: 42 }); + +assert.sameValue(obj['break'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-case-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-case-escaped.js new file mode 100644 index 0000000000..312914aaac --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-case-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/case-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: case is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ c\u0061se: 42 }); + +assert.sameValue(obj['case'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-catch-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-catch-escaped.js new file mode 100644 index 0000000000..3b70c779e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-catch-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/catch-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: catch is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ c\u0061tch: 42 }); + +assert.sameValue(obj['catch'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-class-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-class-escaped.js new file mode 100644 index 0000000000..69cb3ef4f1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-class-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/class-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: class is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ cl\u0061ss: 42 }); + +assert.sameValue(obj['class'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-const-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-const-escaped.js new file mode 100644 index 0000000000..0223f5ce46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-const-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/const-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: const is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0063onst: 42 }); + +assert.sameValue(obj['const'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-continue-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-continue-escaped.js new file mode 100644 index 0000000000..b696766bc7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-continue-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/continue-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: continue is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0063ontinue: 42 }); + +assert.sameValue(obj['continue'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-debugger-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-debugger-escaped.js new file mode 100644 index 0000000000..9dad19cf98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-debugger-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/debugger-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: debugger is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0064ebugger: 42 }); + +assert.sameValue(obj['debugger'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped-ext.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped-ext.js new file mode 100644 index 0000000000..f1c7476e5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped-ext.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped-ext.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: default is a valid identifier name, using extended escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ def\u{61}ult: 42 }); + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped.js new file mode 100644 index 0000000000..c5ab6a03f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: default is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ def\u0061ult: 42 }); + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default.js new file mode 100644 index 0000000000..f7ded1b7b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-default.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: default is a valid identifier name (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ default: 42 }); + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-delete-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-delete-escaped.js new file mode 100644 index 0000000000..3e60549d24 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-delete-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/delete-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: delete is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0064elete: 42 }); + +assert.sameValue(obj['delete'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-do-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-do-escaped.js new file mode 100644 index 0000000000..353eab7328 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-do-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/do-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: do is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0064o: 42 }); + +assert.sameValue(obj['do'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-else-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-else-escaped.js new file mode 100644 index 0000000000..6b38f37a0a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-else-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/else-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: else is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0065lse: 42 }); + +assert.sameValue(obj['else'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-enum-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-enum-escaped.js new file mode 100644 index 0000000000..d53662c4e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-enum-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/enum-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: enum is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0065num: 42 }); + +assert.sameValue(obj['enum'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-export-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-export-escaped.js new file mode 100644 index 0000000000..5b85460300 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-export-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/export-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: export is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0065xport: 42 }); + +assert.sameValue(obj['export'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped-ext.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped-ext.js new file mode 100644 index 0000000000..0709ac416b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped-ext.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped-ext.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: extends is a valid identifier name, using extended escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u{65}xtends: 42 }); + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped.js new file mode 100644 index 0000000000..146047df51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: extends is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0065xtends: 42 }); + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends.js new file mode 100644 index 0000000000..d7ea054935 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-extends.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: extends is a valid identifier name (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ extends: 42 }); + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-finally-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-finally-escaped.js new file mode 100644 index 0000000000..3e7e85d48a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-finally-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/finally-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: finally is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0066inally: 42 }); + +assert.sameValue(obj['finally'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-for-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-for-escaped.js new file mode 100644 index 0000000000..86ec45196f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-for-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/for-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: for is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0066or: 42 }); + +assert.sameValue(obj['for'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-function-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-function-escaped.js new file mode 100644 index 0000000000..11a4f44214 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-function-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/function-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: function is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0066unction: 42 }); + +assert.sameValue(obj['function'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-if-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-if-escaped.js new file mode 100644 index 0000000000..549e97c714 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-if-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/if-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: if is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ i\u0066: 42 }); + +assert.sameValue(obj['if'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-implements-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-implements-escaped.js new file mode 100644 index 0000000000..52b4625343 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-implements-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/implements-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: implements is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0069mplements: 42 }); + +assert.sameValue(obj['implements'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-import-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-import-escaped.js new file mode 100644 index 0000000000..6dbfbdd730 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-import-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/import-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: import is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0069mport: 42 }); + +assert.sameValue(obj['import'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-in-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-in-escaped.js new file mode 100644 index 0000000000..6fa00ec665 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-in-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/in-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: in is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0069n: 42 }); + +assert.sameValue(obj['in'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-instanceof-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-instanceof-escaped.js new file mode 100644 index 0000000000..472996dbec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-instanceof-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/instanceof-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: instanceof is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ \u0069nstanceof: 42 }); + +assert.sameValue(obj['instanceof'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-interface-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-interface-escaped.js new file mode 100644 index 0000000000..2f12ec569f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-interface-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/interface-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: interface is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ interf\u0061ce: 42 }); + +assert.sameValue(obj['interface'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-let-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-let-escaped.js new file mode 100644 index 0000000000..50a1a8a8a2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-let-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/let-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: let is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ l\u0065t: 42 }); + +assert.sameValue(obj['let'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-new-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-new-escaped.js new file mode 100644 index 0000000000..a924055ff5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-new-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/new-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: new is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ n\u0065w: 42 }); + +assert.sameValue(obj['new'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-package-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-package-escaped.js new file mode 100644 index 0000000000..3200b53d7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-package-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/package-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: package is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ p\u0061ckage: 42 }); + +assert.sameValue(obj['package'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-private-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-private-escaped.js new file mode 100644 index 0000000000..2285d9d5ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-private-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/private-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: private is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ privat\u0065: 42 }); + +assert.sameValue(obj['private'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-protected-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-protected-escaped.js new file mode 100644 index 0000000000..4d60c414dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-protected-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/protected-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: protected is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ prot\u0065cted: 42 }); + +assert.sameValue(obj['protected'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-public-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-public-escaped.js new file mode 100644 index 0000000000..37f214579e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-public-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/public-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: public is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ pu\u0062lic: 42 }); + +assert.sameValue(obj['public'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-return-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-return-escaped.js new file mode 100644 index 0000000000..3b9d525d44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-return-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/return-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: return is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ r\u0065turn: 42 }); + +assert.sameValue(obj['return'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-static-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-static-escaped.js new file mode 100644 index 0000000000..bb334f7df5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-static-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/static-escaped.case +// - src/identifier-names/future-reserved-words/covered-obj-prop-name.template +/*--- +description: static is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ st\u0061tic: 42 }); + +assert.sameValue(obj['static'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-super-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-super-escaped.js new file mode 100644 index 0000000000..e8a1e00e2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-super-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/super-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: super is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ sup\u0065r: 42 }); + +assert.sameValue(obj['super'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-switch-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-switch-escaped.js new file mode 100644 index 0000000000..3a35885ad0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-switch-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/switch-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: switch is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ sw\u0069tch: 42 }); + +assert.sameValue(obj['switch'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-this-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-this-escaped.js new file mode 100644 index 0000000000..673b6e0c49 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-this-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/this-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: this is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ th\u0069s: 42 }); + +assert.sameValue(obj['this'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-throw-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-throw-escaped.js new file mode 100644 index 0000000000..7f70c262ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-throw-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/throw-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: throw is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ t\u0068row: 42 }); + +assert.sameValue(obj['throw'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-try-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-try-escaped.js new file mode 100644 index 0000000000..dfa5596132 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-try-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/try-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: try is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ tr\u0079: 42 }); + +assert.sameValue(obj['try'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-typeof-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-typeof-escaped.js new file mode 100644 index 0000000000..63de6021a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-typeof-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/typeof-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: typeof is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ typ\u0065of: 42 }); + +assert.sameValue(obj['typeof'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-var-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-var-escaped.js new file mode 100644 index 0000000000..8511ef73e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-var-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/var-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: var is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ v\u0061r: 42 }); + +assert.sameValue(obj['var'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-void-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-void-escaped.js new file mode 100644 index 0000000000..48e72592d7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-void-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/void-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: void is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ voi\u0064: 42 }); + +assert.sameValue(obj['void'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-while-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-while-escaped.js new file mode 100644 index 0000000000..381db509e4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-while-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/while-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: while is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ whil\u0065: 42 }); + +assert.sameValue(obj['while'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-with-escaped.js b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-with-escaped.js new file mode 100644 index 0000000000..ef519e3644 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/covered-ident-name-prop-name-literal-with-escaped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/with-escaped.case +// - src/identifier-names/default/covered-obj-prop-name.template +/*--- +description: with is a valid identifier name, using escape (PropertyName in a CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = ({ w\u0069th: 42 }); + +assert.sameValue(obj['with'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-add.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-add.js new file mode 100644 index 0000000000..b6be636fec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-add.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-add.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from additive expression "add" (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1 + 1]: 2 +}; + +assert.sameValue( + o[1 + 1], + 2 +); +assert.sameValue( + o[String(1 + 1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-subtract.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-subtract.js new file mode 100644 index 0000000000..e7e8b75062 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-additive-expression-subtract.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-subtract.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from additive expression "subtract" (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1 - 1]: 0 +}; + +assert.sameValue( + o[1 - 1], + 0 +); +assert.sameValue( + o[String(1 - 1)], + 0 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-arrow-function-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-arrow-function-expression.js new file mode 100644 index 0000000000..57d24a5626 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-arrow-function-expression.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-arrow-function-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from arrow function (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [() => { }]: 1 +}; + +assert.sameValue( + o[() => { }], + 1 +); +assert.sameValue( + o[String(() => { })], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-assignment.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-assignment.js new file mode 100644 index 0000000000..a00745a3c5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-assignment.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-assignment.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from assignment expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x = 1]: 2 +}; + +assert.sameValue( + o[x = 1], + 2 +); +assert.sameValue( + o[String(x = 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-bitwise-or.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-bitwise-or.js new file mode 100644 index 0000000000..8dd7af566a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-bitwise-or.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-bitwise-or.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from assignment expression bitwise or (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x |= 1]: 2 +}; + +assert.sameValue( + o[x |= 1], + 2 +); +assert.sameValue( + o[String(x |= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-coalesce.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-coalesce.js new file mode 100644 index 0000000000..efca27d110 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-coalesce.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-coalesce.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from assignment expression coalesce (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = null; + + +let o = { + [x ??= 1]: 2 +}; + +assert.sameValue( + o[x ??= 1], + 2 +); +assert.sameValue( + o[String(x ??= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-and.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-and.js new file mode 100644 index 0000000000..ca03a6e4cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-and.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-and.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from assignment expression logical and (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x &&= 1]: 2 +}; + +assert.sameValue( + o[x &&= 1], + 2 +); +assert.sameValue( + o[String(x &&= 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-or.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-or.js new file mode 100644 index 0000000000..8ee6670626 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-assignment-expression-logical-or.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-or.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from assignment expression logical or (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x ||= 1]: 2 +}; + +assert.sameValue( + o[x ||= 1], + 2 +); +assert.sameValue( + o[String(x ||= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-async-arrow-function-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-async-arrow-function-expression.js new file mode 100644 index 0000000000..c6effaf60e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-async-arrow-function-expression.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-async-arrow-function-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [async () => {}]: 1 +}; + +assert.sameValue( + o[async () => {}], + 1 +); +assert.sameValue( + o[String(async () => {})], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-await-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-await-expression.js new file mode 100644 index 0000000000..2f67620acf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-await-expression.js @@ -0,0 +1,45 @@ +// |reftest| module async +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-await-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, top-level-await] +flags: [generated, async, module] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +try { + + +let o = { + [await 9]: 9 +}; + +assert.sameValue( + o[await 9], + 9 +); +assert.sameValue( + o[String(await 9)], + 9 +); + +} catch (e) { + $DONE(e); +} +$DONE(); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-false.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-false.js new file mode 100644 index 0000000000..a144480aed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-false.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-false.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [false ? 1 : 2]: 1 +}; + +assert.sameValue( + o[false ? 1 : 2], + 1 +); +assert.sameValue( + o[String(false ? 1 : 2)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-true.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-true.js new file mode 100644 index 0000000000..4d64b15186 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-condition-expression-true.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-true.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [true ? 1 : 2]: 2 +}; + +assert.sameValue( + o[true ? 1 : 2], + 2 +); +assert.sameValue( + o[String(true ? 1 : 2)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-e-notational-literal.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-e-notational-literal.js new file mode 100644 index 0000000000..0d920abec1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-e-notational-literal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-e-notational-literal.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from decimal e notational literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1.e1]: 2 +}; + +assert.sameValue( + o[1.e1], + 2 +); +assert.sameValue( + o[String(1.e1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-literal.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-literal.js new file mode 100644 index 0000000000..27dad519d0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-decimal-literal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-literal.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from decimal literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1.1]: 2 +}; + +assert.sameValue( + o[1.1], + 2 +); +assert.sameValue( + o[String(1.1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-exponetiation-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-exponetiation-expression.js new file mode 100644 index 0000000000..78edffafa0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-exponetiation-expression.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-exponetiation-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from exponentiation expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [2 ** 2]: 4 +}; + +assert.sameValue( + o[2 ** 2], + 4 +); +assert.sameValue( + o[String(2 ** 2)], + 4 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-coalesce.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-coalesce.js new file mode 100644 index 0000000000..01d0332c73 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-coalesce.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-coalesce.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from coalesce (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x; + + +let o = { + [x ?? 1]: 2 +}; + +assert.sameValue( + o[x ?? 1], + 2 +); +assert.sameValue( + o[String(x ?? 1)], + 2 +); + +assert.sameValue(x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-and.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-and.js new file mode 100644 index 0000000000..8383211b5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-and.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-and.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from logical and (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x && 1]: 2 +}; + +assert.sameValue( + o[x && 1], + 2 +); +assert.sameValue( + o[String(x && 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-or.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-or.js new file mode 100644 index 0000000000..e8620cb336 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-expression-logical-or.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-or.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from logical or (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let o = { + [x || 1]: 2 +}; + +assert.sameValue( + o[x || 1], + 2 +); +assert.sameValue( + o[String(x || 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-declaration.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-declaration.js new file mode 100644 index 0000000000..e18efd7a9a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-declaration.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-declaration.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from function (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function f() {} + + +let o = { + [f()]: 1 +}; + +assert.sameValue( + o[f()], + 1 +); +assert.sameValue( + o[String(f())], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-expression.js new file mode 100644 index 0000000000..8cdce94277 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-function-expression.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [function () {}]: 1 +}; + +assert.sameValue( + o[function () {}], + 1 +); +assert.sameValue( + o[String(function () {})], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-generator-function-declaration.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-generator-function-declaration.js new file mode 100644 index 0000000000..78efff178d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-generator-function-declaration.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-generator-function-declaration.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from generator function (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { return 1; } + + +let o = { + [g()]: 1 +}; + +assert.sameValue( + o[g()], + 1 +); +assert.sameValue( + o[String(g())], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-identifier.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-identifier.js new file mode 100644 index 0000000000..51efa3483c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-identifier.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-identifier.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 1; + + + +let o = { + [x]: '2' +}; + +assert.sameValue( + o[x], + '2' +); +assert.sameValue( + o[String(x)], + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-e-notational-literal.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-e-notational-literal.js new file mode 100644 index 0000000000..424d40a57b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-e-notational-literal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-e-notational-literal.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1]: 2 +}; + +assert.sameValue( + o[1], + 2 +); +assert.sameValue( + o[String(1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js new file mode 100644 index 0000000000..1ea00ce76a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-separators.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from integer with separators (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1_2_3_4_5_6_7_8]: 1_2_3_4_5_6_7_8 +}; + +assert.sameValue( + o[1_2_3_4_5_6_7_8], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + o[String(1_2_3_4_5_6_7_8)], + 1_2_3_4_5_6_7_8 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-math.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-math.js new file mode 100644 index 0000000000..4b270b1ed1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-math.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-math.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from math (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1 + 2 - 3 * 4 / 5 ** 6]: 2.999232 +}; + +assert.sameValue( + o[1 + 2 - 3 * 4 / 5 ** 6], + 2.999232 +); +assert.sameValue( + o[String(1 + 2 - 3 * 4 / 5 ** 6)], + 2.999232 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-div.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-div.js new file mode 100644 index 0000000000..9d76e91b18 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-div.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-div.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from multiplicative expression "divide" (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1 / 1]: 1 +}; + +assert.sameValue( + o[1 / 1], + 1 +); +assert.sameValue( + o[String(1 / 1)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-mult.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-mult.js new file mode 100644 index 0000000000..e2ce39374a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-multiplicative-expression-mult.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-mult.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from multiplicative expression "multiply" (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1 * 1]: 1 +}; + +assert.sameValue( + o[1 * 1], + 1 +); +assert.sameValue( + o[String(1 * 1)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-null.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-null.js new file mode 100644 index 0000000000..38a2494046 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-null.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-null.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [null]: null +}; + +assert.sameValue( + o[null], + null +); +assert.sameValue( + o[String(null)], + null +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-numeric-literal.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-numeric-literal.js new file mode 100644 index 0000000000..256698909e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-numeric-literal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-numeric-literal.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + [1]: 2 +}; + +assert.sameValue( + o[1], + 2 +); +assert.sameValue( + o[String(1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-string-literal.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-string-literal.js new file mode 100644 index 0000000000..941baa0246 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-string-literal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-string-literal.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let o = { + ['1']: '2' +}; + +assert.sameValue( + o['1'], + '2' +); +assert.sameValue( + o[String('1')], + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-yield-expression.js b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-yield-expression.js new file mode 100644 index 0000000000..0051ee14d7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/cpn-obj-lit-computed-property-name-from-yield-expression.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-yield-expression.case +// - src/computed-property-names/evaluation/object-literal.template +/*--- +description: Computed property name from yield expression (ComputedPropertyName in ObjectLiteral) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ObjectLiteral: + { PropertyDefinitionList } + + PropertyDefinitionList: + PropertyDefinition + + PropertyDefinition: + PropertyName: AssignmentExpression + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { + + +let o = { + [yield 9]: 9 +}; + +assert.sameValue( + o[yield 9], + 9 +); +assert.sameValue( + o[String(yield 9)], + 9 +); + +} +var iter = g(); +while (iter.next().done === false) ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..445b32dccf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-close.js @@ -0,0 +1,60 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..34cf9ba494 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x, y, z]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..a75fe4b06a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..6b1655c6a5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,60 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..37d5087822 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-name-iter-val.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..1571aa1cdd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..41edcb09ca --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..74428cd5cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..3fd4d8539b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..422cbf2bc6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..6728fd9233 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..49db355013 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[...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; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..35647ccc7b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[...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; + } +}; + +obj.method([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..536d23910e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested array destructuring with a null value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([[x]]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..16621af6bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..0ce3e4a35d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,51 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..ffbd1fa1f3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,53 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([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; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e4611e257a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,52 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..a69903661d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,52 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..3ce24ed443 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,53 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..ae2b23ca3a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..8a92db1237 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([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; + } +}; + +obj.method([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..7595b0d9ea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..e7c48a0343 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..0c82a896f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([ x = unresolvableReference ]) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..35bd1e7592 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..b969cba31d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..dbbf608f49 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..af5e806d81 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,69 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..96eff1b382 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..80baaf9b3d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..6dfaf2b62a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..3fa1eb383a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..8e52b8a7dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ 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; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..5517e53429 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ 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; + } +}; + +obj.method([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..2e9d134734 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested object destructuring with a null value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([{ x }]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..846b328819 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([{ x }]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b8dce4eacd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([,]) { + + callCount = callCount + 1; + } +}; + +obj.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..8c7a042725 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([,]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..fd4a27fb89 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Elision advances iterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..b3b34f475e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +var obj = { + async *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..6dedaae9cc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7ece624afb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing an elision (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..02ad467b29 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..854f80ec27 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing a rest element (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[...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; + } +}; + +obj.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..65b8896bb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Lone rest element (direct binding) (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..b3c8da3fd0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Rest element following elision elements (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([, ...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e846f1d6f1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element following elision elements (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([ , , ...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; + } +}; + +obj.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..430af6f12e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..4a1b728c83 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(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/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..5ed5256434 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([...x]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..3a7bca8908 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Lone rest element (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...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; + } +}; + +obj.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..9ffa7bae6d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..42aabe669c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..6b95782f79 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..d3113cd58e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..3febcb231c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..23add62dc7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,47 @@ +// |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/async-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..19264140f3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..79eeef8c1d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ 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; + } +}; + +obj.method([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..b632c5ab1e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,60 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..ab415ea116 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x, y, z] = [1, 2, 3]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..c92b63a4af --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..488e49e226 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,60 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..13ae31e28e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..dcfb499fed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..d8c9c61c3e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..63af1638cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..c52fbba1e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..2d5d26d36e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..1f9c272622 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..883f94937e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..87a4d0dc51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,58 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([[...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..4507141bf7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested array destructuring with a null value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([[x]] = [null]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..b0929c2700 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..ce5f0b8a2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,51 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..b99a2f42b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,53 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a095d5bbb6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,52 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..bfed895241 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,52 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..2091d20564 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,53 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..d6cfd806a6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer with a "hole" (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..c50d67bb47 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..a05748ce09 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..adfd19ec28 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer with an undefined value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..d8397e38ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([ x = unresolvableReference ] = []) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..310a626877 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..7df8b15849 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..7f32c663d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x] = g) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..8bac06c0c0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,69 @@ +// |reftest| async +// 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/async-gen-method-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..f1ad8cfb95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([x] = g) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..a571292584 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..00faf943be --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..5f22182209 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..e232f89375 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..7609c65d02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([{ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..8f9e2fb98a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested object destructuring with a null value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([{ x }] = [null]) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..5a7d27d827 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([{ x }] = []) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..f6b1324baf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Elision accepts exhausted iterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..8319649768 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([,] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..520d0d483a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Elision advances iterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..99dc097546 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +var obj = { + async *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..20d56cb4b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..9031d1dd9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing an elision (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6e1d6ac640 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..5d81697005 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing a rest element (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..3266e120ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Lone rest element (direct binding) (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..44e3600713 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Rest element following elision elements (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([, ...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..b0288606bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element following elision elements (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([ , , ...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..fdc1d70cd7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..0fa93e0ad2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +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/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..d2b57dbd3f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method([...x] = iter) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..33b69e8fd6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Lone rest element (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..2344b7e41c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..55869540a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..8064dddad1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..3f5762ba19 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..c083a246db --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b6d4f8b187 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,47 @@ +// |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/async-gen-method-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..625bd12836 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..9947b356ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method([...{ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..ea117b90d0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({} = null) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..b03809d547 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({} = undefined) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..df51c68303 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +var obj = { + async *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..22057ed6e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ poisoned } = poisonedProperty) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c4672d843e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..92a932965d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..ce42c0214c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..ea800001ea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..9696ee0659 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..6d5ea9d5cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..ec4459bd45 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x = thrower() } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..dd71a75b4d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x = unresolvableReference } = {}) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..2bbf0e4b78 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..b0e58e7f36 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..8f86168e36 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..42f9e396a9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..30885fd1f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..0e2d03f3e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..5dc66473ee --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ [thrower()]: x } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..58f010e9b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..96e66deaf6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..bf668b1a75 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Error thrown when evaluating the initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x: y = thrower() } = {}) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..5b1163729d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ef604b362e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..d13c4d01ce --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..839e32578f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Binding as specified via property name and identifier (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..99001ebdd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..f07ad0ee4c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..cb50ea279d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..53c25d5d08 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..0cca99bb65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var obj = { + async *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..b505639ad1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var obj = { + async *method({...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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..69400ddf16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/async-gen-method-dflt.template +/*--- +description: Rest object contains just unextracted data (async generator method (default parameter)) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +var obj = { + async *method({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; + } +}; + +obj.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-null.js new file mode 100644 index 0000000000..e9178d4b38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({}) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..a344862ecd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-init-undefined.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +var obj = { + async *method({}) { + + } +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..81a1259775 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +var obj = { + async *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..69a94e745b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ poisoned }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..b089f2ec26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..1e7a2fe91f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..c42bea0bea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..dc38cacc55 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..7a118acc48 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..feaebc8ea8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..c369c9834f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x = thrower() }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..1f2fd590f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x = unresolvableReference }) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..dc9cfa3905 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..4a25c4d6e6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..98279dfddf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..86fef04f36 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..def344eb1f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..e7728507ae --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..8ceff22366 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ [thrower()]: x }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..7da1f0ca04 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..17d379c4be --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..8cfbd46606 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x: y = thrower() }) { + + } +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..1ffc86f326 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ x: y = unresolvableReference }) { + + } +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..348e9a4afd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..b0999ed775 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..10eb051d8e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +var obj = { + async *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..550aef8f5e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..9fc9a9fa16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..4e8e85a6ae --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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 obj = { + async *method({ w: { x, y, z } = undefined }) { + + } +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..339c9664b8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method({ 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; + } +}; + +obj.method({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..3987d6d23f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +var obj = { + async *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..3df62c76c6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +var obj = { + async *method({...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; + } +}; + +obj.method(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..908ceaaa2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/async-gen-meth.template +/*--- +description: Rest object contains just unextracted data (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +var obj = { + async *method({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; + } +}; + +obj.method({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/dstr/browser.js b/js/src/tests/test262/language/expressions/object/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/browser.js diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..d4446c7f7b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-close.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..bc8de18bfa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z]) {} +}; + +assert.throws(TypeError, function() { + obj.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..a77269f3fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..1f6fd1fb11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..d2d689003c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-name-iter-val.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..df4c1c9996 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..d3489c2d7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1e3c7be9a9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..6a151bda23 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[]]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..286780d95e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..62288e2526 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[23]]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..6730243c63 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[...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; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..afb7d58b82 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[...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; + } +}; + +obj.method([values]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..de1f4ce8be --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested array destructuring with a null value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x]]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..54222ed1c7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..660b5e3979 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,71 @@ +// 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/gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..db4dc7d1b8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,73 @@ +// 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/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([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; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..fe3b565901 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,72 @@ +// 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/gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..11f3d14d3f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,72 @@ +// 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/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..e143bc856e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,73 @@ +// 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/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..3ff88e4501 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method([,]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..99299429f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([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; + } +}; + +obj.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..6d2ed7c86e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..beef9ac99a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([undefined]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..2a5f27536e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..54b09fb1a6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..255a43e17d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..60887b032c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..3cffa9398a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,89 @@ +// 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/gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..c412ae85e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..6c1066b14c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..6a4c1d1074 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..0afd65ab4b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..0fac6db3ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ 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; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..2a4a685d00 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ 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; + } +}; + +obj.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..e041b401cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested object destructuring with a null value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..8b054b92f1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..2aeee05583 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Elision accepts exhausted iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,]) { + + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..2739592f3e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..ca759b79cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elision.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Elision advances iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(g()).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..eeaed566b5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-empty.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..7771d0ffbb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..2bdce4d742 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an elision (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(g()).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..b1e725f5ef --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..36325d7622 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing a rest element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[...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; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..9973a7bc31 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Lone rest element (direct binding) (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method([1]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..74dbc3658b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Rest element following elision elements (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..07419963e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element following elision elements (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([ , , ...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; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..9a4f9fef75 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..7c136c2854 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(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/object/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..7b0212d95e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f61700cc96 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Lone rest element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...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; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..fbd9bcb111 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..0892afd843 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..2f18190af1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..7a2aec3f91 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..58e86ede1a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..4c3daf88df --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,66 @@ +// |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/gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..d4d2a7d613 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an object binding pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..8bcf5880d0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an object binding pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ 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; + } +}; + +obj.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..41f523b846 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..9c7d758ffb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z] = [1, 2, 3]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..49dd5f627a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..b9b4a5be02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..8c8f28b468 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..d4c0b68f29 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..2bca98495d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..0f73cbed43 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..2b99b3956f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..2c7104ce66 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..2112ac03c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..656b0596bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..f434cbb0f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..87bc902370 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..7170bc3b70 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..5bc1e2edc3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,71 @@ +// 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/gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..d2dd773ce8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,73 @@ +// 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/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..4597b349ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,72 @@ +// 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/gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..63afbc17f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,72 @@ +// 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/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..748903d9e6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,73 @@ +// 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/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..f891759cb9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with a "hole" (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..a66b57b0cc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..e94d1d3a92 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..0c4cb9a6cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with an undefined value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..78f1dc13b3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..86f9e7ca9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..569c4b3f3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..eea2c94d71 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..c31909d97c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,89 @@ +// 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/gen-method-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..896fce4ecd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..cb742d9c33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..7aeedf62f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..4d8bb96d2f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..59bba12112 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..b8473e0bc0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..9288406bbc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a9594189c0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b11d5bc033 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Elision accepts exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..8b2bfdbdd7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..8494b10c61 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Elision advances iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..370a417963 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..a06c36a3dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..e00f62b303 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an elision (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..1568a4387e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..89cacd3e3a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing a rest element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..cc8a9c1452 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Lone rest element (direct binding) (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..9608e98fdf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Rest element following elision elements (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..6b71db6ed0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element following elision elements (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([ , , ...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..388dc241f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..3e8ead7911 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +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/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..df0449f8d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..347e87b518 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Lone rest element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..69c855f796 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..fa49afacfa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..74fb01a6f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..7de4027513 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..2214e6d4e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..9c1958cd78 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,66 @@ +// |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/gen-method-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..1adb4712ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a9d5b41230 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method([...{ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..b69f977328 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({} = null) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..08da959943 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..a21997f148 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..a50eecf27b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..85e089e650 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..d7e5d1eee0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0ece48cf4c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..4f196fa02b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..40177da01a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..8432ceb139 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..aa73e48739 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..b6f7928760 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..c16bc4045b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..ba35b95cdf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..d70c93951e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..2edcc779d0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..a5e61d4b1c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..9a380b3682 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..1ff3038876 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b01c5106ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..3abc511622 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..059e7085a7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..d0a8dabd58 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..af90f89782 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..a6fe228877 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..6b1ba42cf3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Binding as specified via property name and identifier (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..705382b97f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..9269410716 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..fc6f42a8dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..e817b90a8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..32822764a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..1bcebf2a67 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({...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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..c112ac8f77 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest object contains just unextracted data (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({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; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-null.js new file mode 100644 index 0000000000..228bc3fcf0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..7dbc82a2db --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-init-undefined.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..6e4f19c0fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-empty.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(obj).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..a4d7f3316a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..a9ba02da76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..3189719c9f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a2b659cfe0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..16f3566717 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..bda385d965 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..a89cad491b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..b39983052d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..dcd4dbf50e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..4e5c839799 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..00dab1ebde --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..3e821fe3da --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..9a2b2a1edd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..7a2170af0e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..278d0d6d6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..f7acc44ac1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..4fa9ab78ec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..42737b3ed8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..c417a288fb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..eb733b46ea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..bbb8ac60ba --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..fa20ad7461 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..3f4b38d093 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Binding as specified via property name and identifier (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..37d743aab4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..ae854495d9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..d30afb0413 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..b55d6f748e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({ 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; + } +}; + +obj.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..f2d085eae1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..56d8329ebb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({...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; + } +}; + +obj.method(o).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..7025357c2e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest object contains just unextracted data (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method({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; + } +}; + +obj.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-close.js new file mode 100644 index 0000000000..f7150d4869 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..141d31ee65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/meth.template +/*--- +description: Abrupt completion returned by GetIterator (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z]) {} +}; + +assert.throws(TypeError, function() { + obj.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..7e2fbcaa9b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-get-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Abrupt completion returned by GetIterator (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..b26434e779 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-name-iter-val.js new file mode 100644 index 0000000000..117c1a4123 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding with normal value iteration (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..31a0a485f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..d36fd64d95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..33d9c07fb8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..a4e926c2cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..48e58942c9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..e9180a9a4d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..ae883855fa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[...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; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..6f2f4f6b99 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[...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; + } +}; + +obj.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..ab0f5a2247 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested array destructuring with a null value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x]]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..a7a6c63b07 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f48d25dfe8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// 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/meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..e7237beceb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// 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/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([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; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..d22df33c94 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// 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/meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..9c555e9edb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// 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/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..7bc3107067 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// 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/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..f39019b9d8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with a "hole" (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..5fe1545b13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([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; + } +}; + +obj.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..e217c7674d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..64cbc563fc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with an undefined value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..bf7beaaf38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..a13c2cd57a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration completes (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..6832665c39 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..2ced7cebf6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..66afefa92e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,86 @@ +// 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/meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..09a143e4a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..edaf6fc897 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..4a5d388e4c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..c7ff05c652 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..15b984ae02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ 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; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..65a5355b88 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ 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; + } +}; + +obj.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..f9b2316c2d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested object destructuring with a null value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..49f0fb6a64 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..00e00589bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: Elision accepts exhausted iterator (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,]) { + + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..0e99944d2d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..d38bcabaac --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Elision advances iterator (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..638b60b33d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..4df7465e63 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..ff4d0cded1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an elision (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..2f1b789631 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an "empty" array pattern (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..2e1aa691a9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing a rest element (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[...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; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..a91f042ea5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/meth.template +/*--- +description: Lone rest element (direct binding) (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method([1]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..35b4587c12 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Rest element following elision elements (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e6abfbf3be --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element following elision elements (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([ , , ...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; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..8a6d9e96bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: RestElement applied to an exhausted iterator (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..dc49b042f3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(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/object/dstr/meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..9e074f254a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..ceac42e7d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Lone rest element (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...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; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..89e2ce8b08 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..c27e27d158 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (identifier) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..384cc10515 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..822c293b75 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..9c023ce230 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..60e715a551 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// |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/meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..96ec9707fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an object binding pattern (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..598b980a95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an object binding pattern (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ 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; + } +}; + +obj.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..6ca15b4d10 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..c724a6be4d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z] = [1, 2, 3]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..c5a1b662fa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..d41957a8bb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..5d098a5a5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..d916a0504c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..8818a7f52b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..5095d4455e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..8cb2980fe6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..cb45ff95d7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..70fec72bff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..5649ff13a3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..96db9e2bbe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d2b9227d59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested array destructuring with a null value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..100f1fa210 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..de8ed9e82e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// 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/meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..dbe529dee3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// 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/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..bd60800496 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// 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/meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..3ada21e19d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// 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/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..937ecda98f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// 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/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..33832bd7e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..ef6b543c55 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..94f24a2af9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..35cc01cd1a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..2c56439abe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..2cc42a41f9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..2046b25432 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..28c2f1d35b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..83776c885e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,86 @@ +// 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/meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..badc235ab0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..a7637c5fce --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..7c62bc999f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..d3ebc3d751 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..99af7ffdd9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..cd339c6b91 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..e4eff071db --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested object destructuring with a null value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..b3652b96f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..5478a59e2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,] = iter) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..345b6d6106 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..5e5c3d2e5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Elision advances iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..940d4f68d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..cff0fa07da --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..812967a9d3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an elision (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..ff91afe991 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..08108bffae --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing a rest element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..3d4ccc2a67 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Lone rest element (direct binding) (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..3ec93113e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Rest element following elision elements (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..27fb7d17b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element following elision elements (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([ , , ...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..5a88904c68 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..f58a6ccba8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +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/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..1226e30b53 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..efdc543dd3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Lone rest element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..8d4011c374 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..15cd784164 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..450504a835 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..6c8e701776 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..775197f9e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..f9e91625f9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// |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/meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..1d1db328ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..416d3e2538 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method([...{ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..d54e0a4511 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-null.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({} = null) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..44fde05ab9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-init-undefined.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..217e5d3ca4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..145580449b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..4642c55050 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..2367bf4b59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..3a411a697d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b82157aa93 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..9425ccf83e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..33f9676770 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..9504d85f4d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..94635dd086 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..7653d3dc9b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..4a1a12e8e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..0653f4cc46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..28b3e703c1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..021cae51b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..2ef66e8ab7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..38beacc2a3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b780c25486 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..2b6b2609ad --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..81145a03c1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..ad3335eda1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..e149efded8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..489d474e2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..ee2bb3009e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..c4bafc252d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..69cb712780 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..19d0ae1d98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..0e23b496aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b0c38c21d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..d2b5f5953c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({...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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..09efc88d3d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest object contains just unextracted data (method (default parameter)) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({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; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-null.js new file mode 100644 index 0000000000..1d0ce524a3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-null.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-undefined.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-undefined.js new file mode 100644 index 0000000000..da29633c06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-init-undefined.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-empty.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..498e502768 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-empty.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..5b41bbedce --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..92e08f1ec8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..efbb4d77d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5b33aea910 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8f8f9b9c26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..e9c9fc312d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method) +esid: sec-runtime-semantics-definemethod +features: [generators, destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..39f2ac7073 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..0779e8bbc0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when evaluating the initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..7b1190e910 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..bdc2d6f662 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..ceb7b0ecec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-list-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..205b1e14a2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..deb06f6f36 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..18a5159fe3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..11ffd81d81 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-ary.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..74939fd2c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..c3d9972f63 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..dc97068ead --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..93c1361425 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when evaluating the initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6a9cd4a683 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..696cf4cd46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..99d9bb6ef1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..6a838f2203 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Binding as specified via property name and identifier (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a9422f13c5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..c6c1910ac9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..73a4484456 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..f27a59f925 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-prop-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (method) +esid: sec-runtime-semantics-definemethod +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({ 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; + } +}; + +obj.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..9ef7a2cf73 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-getter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (method) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +obj.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..356349aa02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (method) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({...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; + } +}; + +obj.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..24d4ed754a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest object contains just unextracted data (method) +esid: sec-runtime-semantics-definemethod +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method({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; + } +}; + +obj.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-get-not-called-on-dontenum-keys.js b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-get-not-called-on-dontenum-keys.js new file mode 100644 index 0000000000..56494a2c1e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-get-not-called-on-dontenum-keys.js @@ -0,0 +1,71 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-restbindinginitialization +description: > + Proxy's "get" trap is not invoked for non-enumerable keys. +info: | + BindingRestProperty : ... BindingIdentifier + + [...] + 3. Perform ? CopyDataProperties(restObj, value, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + [...] + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + ii. If desc is not undefined and desc.[[Enumerable]] is true, then + 1. Let propValue be ? Get(from, nextKey). + 2. Perform ! CreateDataPropertyOrThrow(target, nextKey, propValue). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-rest, destructuring-binding, Proxy, Symbol] +includes: [compareArray.js, propertyHelper.js] +---*/ + +var VALUE_GOPD = "VALUE_GOPD"; +var VALUE_GET = "VALUE_GET"; + +var dontEnumSymbol = Symbol("dont_enum_symbol"); +var enumerableSymbol = Symbol("enumerable_symbol"); + +var dontEnumKeys = [dontEnumSymbol, "dontEnumString", "0"]; +var enumerableKeys = [enumerableSymbol, "enumerableString", "1"]; +var ownKeysResult = [...dontEnumKeys, ...enumerableKeys]; + +var getOwnKeys = []; +var getKeys = []; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + var isEnumerable = enumerableKeys.indexOf(key) !== -1; + return {value: VALUE_GOPD, writable: false, enumerable: isEnumerable, configurable: true}; + }, + get: function(_target, key) { + getKeys.push(key); + return VALUE_GET; + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +var {...rest} = proxy; +assert.compareArray(getOwnKeys, ownKeysResult); +assert.compareArray(getKeys, enumerableKeys); + +verifyProperty(rest, enumerableSymbol, {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); +verifyProperty(rest, "enumerableString", {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); +verifyProperty(rest, "1", {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-gopd-not-called-on-excluded-keys.js b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-gopd-not-called-on-excluded-keys.js new file mode 100644 index 0000000000..679c3a4032 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-gopd-not-called-on-excluded-keys.js @@ -0,0 +1,55 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-restbindinginitialization +description: > + Proxy's "getOwnPropertyDescriptor" trap is not invoked for excluded keys. +info: | + BindingRestProperty : ... BindingIdentifier + + [...] + 3. Perform ? CopyDataProperties(restObj, value, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + b. For each element e of excludedItems, do + i. If SameValue(e, nextKey) is true, then + 1. Set excluded to true. + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-rest, destructuring-binding, Proxy, Symbol] +includes: [compareArray.js] +---*/ + +var excludedSymbol = Symbol("excluded_symbol"); +var includedSymbol = Symbol("included_symbol"); + +var excludedKeys = [excludedSymbol, "excludedString", "0"]; +var includedKeys = [includedSymbol, "includedString", "1"]; +var ownKeysResult = [...excludedKeys, ...includedKeys]; + +var getOwnKeys = []; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +var {[excludedSymbol]: _, excludedString, 0: excludedIndex, ...rest} = proxy; +assert.compareArray(getOwnKeys, includedKeys); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-ownkeys-returned-keys-order.js b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-ownkeys-returned-keys-order.js new file mode 100644 index 0000000000..eed087e728 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/object-rest-proxy-ownkeys-returned-keys-order.js @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-restbindinginitialization +description: > + Proxy keys are iterated in order they were provided by "ownKeys" trap. +info: | + BindingRestProperty : ... BindingIdentifier + + [...] + 3. Perform ? CopyDataProperties(restObj, value, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + [...] + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-rest, destructuring-binding, Proxy, Symbol] +includes: [compareArray.js] +---*/ + +var getOwnKeys = []; +var ownKeysResult = [Symbol(), "foo", "0"]; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +let {...$} = proxy; +assert.compareArray(getOwnKeys, ownKeysResult); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/dstr/shell.js b/js/src/tests/test262/language/expressions/object/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/dstr/shell.js diff --git a/js/src/tests/test262/language/expressions/object/fn-name-accessor-get.js b/js/src/tests/test262/language/expressions/object/fn-name-accessor-get.js new file mode 100644 index 0000000000..002bdfc242 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-accessor-get.js @@ -0,0 +1,44 @@ +// 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.3.9 +description: Assignment of function `name` attribute ("get" accessor) +info: | + MethodDefinition : get PropertyName ( ) { FunctionBody } + + [...] + 8. Perform SetFunctionName(closure, propKey, "get"). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o, getter; + +o = { + get id() {}, + get [anonSym]() {}, + get [namedSym]() {} +}; + +getter = Object.getOwnPropertyDescriptor(o, 'id').get; +assert.sameValue(getter.name, 'get id'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(o, anonSym).get; +assert.sameValue(getter.name, 'get '); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(o, namedSym).get; +assert.sameValue(getter.name, 'get [test262]'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-accessor-set.js b/js/src/tests/test262/language/expressions/object/fn-name-accessor-set.js new file mode 100644 index 0000000000..56f0f65563 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-accessor-set.js @@ -0,0 +1,45 @@ +// 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.3.9 +description: Assignment of function `name` attribute ("set" accessor) +info: | + MethodDefinition : + set PropertyName ( PropertySetParameterList ) { FunctionBody } + + [...] + 7. Perform SetFunctionName(closure, propKey, "set"). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o, setter; + +o = { + set id(_) {}, + set [anonSym](_) {}, + set [namedSym](_) {} +}; + +setter = Object.getOwnPropertyDescriptor(o, 'id').set; +assert.sameValue(setter.name, 'set id'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(o, anonSym).set; +assert.sameValue(setter.name, 'set '); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(o, namedSym).set; +assert.sameValue(setter.name, 'set [test262]'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-arrow.js b/js/src/tests/test262/language/expressions/object/fn-name-arrow.js new file mode 100644 index 0000000000..76ba90ac3a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-arrow.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: 12.2.6.9 +description: Assignment of function `name` attribute (ArrowFunction) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + id: () => {}, + [anonSym]: () => {}, + [namedSym]: () => {} +}; + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-class.js b/js/src/tests/test262/language/expressions/object/fn-name-class.js new file mode 100644 index 0000000000..2069749f1a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-class.js @@ -0,0 +1,45 @@ +// 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.2.6.9 +description: Assignment of function `name` attribute (ClassExpression) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [class, Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + xId: class x {}, + id: class {}, + [anonSym]: class {}, + [namedSym]: class {} +}; + +assert(o.xId.name !== 'xId'); + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-cover.js b/js/src/tests/test262/language/expressions/object/fn-name-cover.js new file mode 100644 index 0000000000..996ffbb075 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-cover.js @@ -0,0 +1,46 @@ +// 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.2.6.9 +description: > + Assignment of function `name` attribute (CoverParenthesizedExpression) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + xId: (0, function() {}), + id: (function() {}), + [anonSym]: (function() {}), + [namedSym]: (function() {}) +}; + +assert(o.xId.name !== 'xId'); + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-fn.js b/js/src/tests/test262/language/expressions/object/fn-name-fn.js new file mode 100644 index 0000000000..f1ca9a3ad8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-fn.js @@ -0,0 +1,45 @@ +// 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.2.6.9 +description: Assignment of function `name` attribute (FunctionExpression) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + xId: function x() {}, + id: function() {}, + [anonSym]: function() {}, + [namedSym]: function() {} +}; + +assert(o.xId.name !== 'xId'); + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/fn-name-gen.js b/js/src/tests/test262/language/expressions/object/fn-name-gen.js new file mode 100644 index 0000000000..d63bc6c64b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/fn-name-gen.js @@ -0,0 +1,46 @@ +// 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.2.6.9 +description: > + Assignment of function `name` attribute (GeneratorExpression) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [generators, Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + xId: function* x() {}, + id: function*() {}, + [anonSym]: function*() {}, + [namedSym]: function*() {} +}; + +assert(o.xId.name !== 'xId'); + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/getter-body-strict-inside.js b/js/src/tests/test262/language/expressions/object/getter-body-strict-inside.js new file mode 100644 index 0000000000..3e37f09baa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/getter-body-strict-inside.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5_6-2-2-s +description: > + Strict Mode - SyntaxError is thrown when an assignment to a + reserved word or a future reserved word is made inside a strict + mode FunctionBody of a PropertyAssignment +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +void { + get x() { + "use strict"; + public = 42; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/getter-body-strict-outside-strict.js b/js/src/tests/test262/language/expressions/object/getter-body-strict-outside-strict.js new file mode 100644 index 0000000000..3af4e0b9e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/getter-body-strict-outside-strict.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5_6-2-1-s +description: > + Strict Mode - SyntaxError is thrown when an assignment to a + reserved word or a future reserved word is contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +void { + get x() { + public = 42; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/getter-param-dflt.js b/js/src/tests/test262/language/expressions/object/getter-param-dflt.js new file mode 100644 index 0000000000..d58503cc33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/getter-param-dflt.js @@ -0,0 +1,24 @@ +// |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-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +0, { get a(param = null) {} }; diff --git a/js/src/tests/test262/language/expressions/object/getter-prop-desc.js b/js/src/tests/test262/language/expressions/object/getter-prop-desc.js new file mode 100644 index 0000000000..ac1b2df273 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/getter-prop-desc.js @@ -0,0 +1,39 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: Property descriptor of "set" accessor methods +info: | + ObjectLiteral: + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + 3. ReturnIfAbrupt(status). + 4. Return obj. + + 14.3.8 Runtime Semantics: PropertyDefinitionEvaluation + + MethodDefinition : get PropertyName ( ) { FunctionBody} + + [...] + 9. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + [...] +includes: [propertyHelper.js] +---*/ + +var obj = { get m() { return 1234; } }; +var desc = Object.getOwnPropertyDescriptor(obj, 'm'); + +verifyEnumerable(obj, 'm'); +verifyConfigurable(obj, 'm'); +assert.sameValue(desc.value, undefined, '`value` field'); +assert.sameValue(desc.set, undefined, '`set` field'); +assert.sameValue(typeof desc.get, 'function', 'type of `get` field'); +assert.sameValue(desc.get(), 1234, '`get` function return value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/getter-super-prop.js b/js/src/tests/test262/language/expressions/object/getter-super-prop.js new file mode 100644 index 0000000000..713d51af23 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/getter-super-prop.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: 12.2.5 +description: > + super method calls in object literal getter +---*/ +var proto = { + _x: 42, + get x() { + return 'proto' + this._x; + } +}; + +var object = { + get x() { + return super.x; + } +}; + +Object.setPrototypeOf(object, proto); + +assert.sameValue(object.x, 'proto42', "The value of `object.x` is `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue(object._x, 42, "The value of `object._x` is `42`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue( + Object.getPrototypeOf(object)._x, + 42, + "The value of `Object.getPrototypeOf(object)._x` is `42`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-break-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-break-escaped.js new file mode 100644 index 0000000000..c12ecbd6b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-break-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/break-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: break is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + bre\u0061k() { return 42; } +}; + +assert.sameValue(obj['break'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-case-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-case-escaped.js new file mode 100644 index 0000000000..6733a4c3fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-case-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/case-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: case is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + c\u0061se() { return 42; } +}; + +assert.sameValue(obj['case'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-catch-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-catch-escaped.js new file mode 100644 index 0000000000..de4050fc46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-catch-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/catch-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: catch is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + c\u0061tch() { return 42; } +}; + +assert.sameValue(obj['catch'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-class-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-class-escaped.js new file mode 100644 index 0000000000..7936a16e4c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-class-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/class-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: class is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + cl\u0061ss() { return 42; } +}; + +assert.sameValue(obj['class'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-const-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-const-escaped.js new file mode 100644 index 0000000000..a8dbb7110c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-const-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/const-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: const is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0063onst() { return 42; } +}; + +assert.sameValue(obj['const'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-continue-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-continue-escaped.js new file mode 100644 index 0000000000..9b3f9f24f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-continue-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/continue-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: continue is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0063ontinue() { return 42; } +}; + +assert.sameValue(obj['continue'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-debugger-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-debugger-escaped.js new file mode 100644 index 0000000000..a7d84c067d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-debugger-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/debugger-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: debugger is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0064ebugger() { return 42; } +}; + +assert.sameValue(obj['debugger'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped-ext.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped-ext.js new file mode 100644 index 0000000000..6ea6269ede --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped-ext.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped-ext.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: default is a valid identifier name, using extended escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + def\u{61}ult() { return 42; } +}; + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped.js new file mode 100644 index 0000000000..a07947ce9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: default is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + def\u0061ult() { return 42; } +}; + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-default.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default.js new file mode 100644 index 0000000000..15fbcf1594 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-default.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: default is a valid identifier name (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + default() { return 42; } +}; + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-delete-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-delete-escaped.js new file mode 100644 index 0000000000..3a63cf1734 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-delete-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/delete-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: delete is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0064elete() { return 42; } +}; + +assert.sameValue(obj['delete'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-do-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-do-escaped.js new file mode 100644 index 0000000000..ae52e41aa2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-do-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/do-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: do is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0064o() { return 42; } +}; + +assert.sameValue(obj['do'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-else-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-else-escaped.js new file mode 100644 index 0000000000..9e828a438c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-else-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/else-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: else is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0065lse() { return 42; } +}; + +assert.sameValue(obj['else'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-enum-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-enum-escaped.js new file mode 100644 index 0000000000..5044ebd8fb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-enum-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/enum-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: enum is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0065num() { return 42; } +}; + +assert.sameValue(obj['enum'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-export-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-export-escaped.js new file mode 100644 index 0000000000..3edb5c88e6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-export-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/export-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: export is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0065xport() { return 42; } +}; + +assert.sameValue(obj['export'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped-ext.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped-ext.js new file mode 100644 index 0000000000..e421e6bdbc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped-ext.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped-ext.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: extends is a valid identifier name, using extended escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u{65}xtends() { return 42; } +}; + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped.js new file mode 100644 index 0000000000..f8e3797d0c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: extends is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0065xtends() { return 42; } +}; + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends.js new file mode 100644 index 0000000000..081541edc3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-extends.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: extends is a valid identifier name (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + extends() { return 42; } +}; + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-finally-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-finally-escaped.js new file mode 100644 index 0000000000..c3d5a0b9c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-finally-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/finally-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: finally is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0066inally() { return 42; } +}; + +assert.sameValue(obj['finally'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-for-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-for-escaped.js new file mode 100644 index 0000000000..1f310a77e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-for-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/for-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: for is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0066or() { return 42; } +}; + +assert.sameValue(obj['for'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-function-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-function-escaped.js new file mode 100644 index 0000000000..1ec61b4465 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-function-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/function-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: function is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0066unction() { return 42; } +}; + +assert.sameValue(obj['function'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-if-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-if-escaped.js new file mode 100644 index 0000000000..ab03d1f301 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-if-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/if-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: if is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + i\u0066() { return 42; } +}; + +assert.sameValue(obj['if'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-implements-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-implements-escaped.js new file mode 100644 index 0000000000..ae82493e5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-implements-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/implements-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: implements is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0069mplements() { return 42; } +}; + +assert.sameValue(obj['implements'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-import-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-import-escaped.js new file mode 100644 index 0000000000..59ac8a5120 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-import-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/import-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: import is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0069mport() { return 42; } +}; + +assert.sameValue(obj['import'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-in-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-in-escaped.js new file mode 100644 index 0000000000..4f4c2f57ab --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-in-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/in-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: in is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0069n() { return 42; } +}; + +assert.sameValue(obj['in'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-instanceof-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-instanceof-escaped.js new file mode 100644 index 0000000000..ff1855ad04 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-instanceof-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/instanceof-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: instanceof is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + \u0069nstanceof() { return 42; } +}; + +assert.sameValue(obj['instanceof'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-interface-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-interface-escaped.js new file mode 100644 index 0000000000..82a52a4c72 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-interface-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/interface-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: interface is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + interf\u0061ce() { return 42; } +}; + +assert.sameValue(obj['interface'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-let-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-let-escaped.js new file mode 100644 index 0000000000..cfd9610b98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-let-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/let-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: let is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + l\u0065t() { return 42; } +}; + +assert.sameValue(obj['let'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-new-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-new-escaped.js new file mode 100644 index 0000000000..63d9968d06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-new-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/new-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: new is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + n\u0065w() { return 42; } +}; + +assert.sameValue(obj['new'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-package-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-package-escaped.js new file mode 100644 index 0000000000..ac5feaa238 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-package-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/package-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: package is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + p\u0061ckage() { return 42; } +}; + +assert.sameValue(obj['package'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-private-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-private-escaped.js new file mode 100644 index 0000000000..cf11ba5118 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-private-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/private-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: private is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + privat\u0065() { return 42; } +}; + +assert.sameValue(obj['private'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-protected-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-protected-escaped.js new file mode 100644 index 0000000000..5575cf0dd3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-protected-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/protected-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: protected is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + prot\u0065cted() { return 42; } +}; + +assert.sameValue(obj['protected'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-public-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-public-escaped.js new file mode 100644 index 0000000000..813764b241 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-public-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/public-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: public is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + pu\u0062lic() { return 42; } +}; + +assert.sameValue(obj['public'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-return-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-return-escaped.js new file mode 100644 index 0000000000..833ee194f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-return-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/return-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: return is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + r\u0065turn() { return 42; } +}; + +assert.sameValue(obj['return'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-static-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-static-escaped.js new file mode 100644 index 0000000000..b43163df38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-static-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/static-escaped.case +// - src/identifier-names/future-reserved-words/obj-method-definition.template +/*--- +description: static is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + st\u0061tic() { return 42; } +}; + +assert.sameValue(obj['static'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-super-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-super-escaped.js new file mode 100644 index 0000000000..0aaf71880a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-super-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/super-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: super is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + sup\u0065r() { return 42; } +}; + +assert.sameValue(obj['super'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-switch-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-switch-escaped.js new file mode 100644 index 0000000000..a334391c78 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-switch-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/switch-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: switch is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + sw\u0069tch() { return 42; } +}; + +assert.sameValue(obj['switch'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-this-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-this-escaped.js new file mode 100644 index 0000000000..587bb84366 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-this-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/this-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: this is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + th\u0069s() { return 42; } +}; + +assert.sameValue(obj['this'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-throw-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-throw-escaped.js new file mode 100644 index 0000000000..18dab852b3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-throw-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/throw-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: throw is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + t\u0068row() { return 42; } +}; + +assert.sameValue(obj['throw'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-try-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-try-escaped.js new file mode 100644 index 0000000000..2adcb239db --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-try-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/try-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: try is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + tr\u0079() { return 42; } +}; + +assert.sameValue(obj['try'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-typeof-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-typeof-escaped.js new file mode 100644 index 0000000000..d4972feb2c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-typeof-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/typeof-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: typeof is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + typ\u0065of() { return 42; } +}; + +assert.sameValue(obj['typeof'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-var-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-var-escaped.js new file mode 100644 index 0000000000..696151f577 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-var-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/var-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: var is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + v\u0061r() { return 42; } +}; + +assert.sameValue(obj['var'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-void-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-void-escaped.js new file mode 100644 index 0000000000..9e7985ab3f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-void-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/void-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: void is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + voi\u0064() { return 42; } +}; + +assert.sameValue(obj['void'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-while-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-while-escaped.js new file mode 100644 index 0000000000..e30b1823de --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-while-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/while-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: while is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + whil\u0065() { return 42; } +}; + +assert.sameValue(obj['while'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-method-def-with-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-method-def-with-escaped.js new file mode 100644 index 0000000000..7fa20511a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-method-def-with-escaped.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/with-escaped.case +// - src/identifier-names/default/obj-method-definition.template +/*--- +description: with is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + + +var obj = { + w\u0069th() { return 42; } +}; + +assert.sameValue(obj['with'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-await-static-init.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-await-static-init.js new file mode 100644 index 0000000000..4b0a4f25f4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-await-static-init.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The restriction on `await` does not apply to IdentifierName +info: | + BindingIdentifier : Identifier + + [...] + - It is a Syntax Error if the code matched by this production is nested, + directly or indirectly (but not crossing function or static initialization + block boundaries), within a ClassStaticBlock and the StringValue of + Identifier is "await". +features: [class-static-block] +---*/ + +class C { + static { + ({ await: 0 }); + } +} + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-break-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-break-escaped.js new file mode 100644 index 0000000000..7f44c42ced --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-break-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/break-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: break is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + bre\u0061k: 42 +}; + +assert.sameValue(obj['break'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-case-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-case-escaped.js new file mode 100644 index 0000000000..6a5b8adb45 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-case-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/case-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: case is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + c\u0061se: 42 +}; + +assert.sameValue(obj['case'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-catch-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-catch-escaped.js new file mode 100644 index 0000000000..2a291a52fd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-catch-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/catch-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: catch is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + c\u0061tch: 42 +}; + +assert.sameValue(obj['catch'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-class-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-class-escaped.js new file mode 100644 index 0000000000..43622c5191 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-class-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/class-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: class is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + cl\u0061ss: 42 +}; + +assert.sameValue(obj['class'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-const-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-const-escaped.js new file mode 100644 index 0000000000..7ee280fa99 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-const-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/const-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: const is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0063onst: 42 +}; + +assert.sameValue(obj['const'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-continue-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-continue-escaped.js new file mode 100644 index 0000000000..91d2d800d8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-continue-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/continue-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: continue is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0063ontinue: 42 +}; + +assert.sameValue(obj['continue'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-debugger-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-debugger-escaped.js new file mode 100644 index 0000000000..e8f7e3cb48 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-debugger-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/debugger-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: debugger is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0064ebugger: 42 +}; + +assert.sameValue(obj['debugger'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped-ext.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped-ext.js new file mode 100644 index 0000000000..1bbf17b2e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped-ext.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped-ext.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: default is a valid identifier name, using extended escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + def\u{61}ult: 42 +}; + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped.js new file mode 100644 index 0000000000..66b63a8c8e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: default is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + def\u0061ult: 42 +}; + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default.js new file mode 100644 index 0000000000..ee5842a6f7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-default.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: default is a valid identifier name (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + default: 42 +}; + +assert.sameValue(obj['default'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-delete-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-delete-escaped.js new file mode 100644 index 0000000000..2a24bf6689 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-delete-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/delete-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: delete is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0064elete: 42 +}; + +assert.sameValue(obj['delete'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-do-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-do-escaped.js new file mode 100644 index 0000000000..86dc6c0d9f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-do-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/do-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: do is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0064o: 42 +}; + +assert.sameValue(obj['do'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-else-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-else-escaped.js new file mode 100644 index 0000000000..a361eaab52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-else-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/else-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: else is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0065lse: 42 +}; + +assert.sameValue(obj['else'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-enum-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-enum-escaped.js new file mode 100644 index 0000000000..d328c2a00b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-enum-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/enum-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: enum is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0065num: 42 +}; + +assert.sameValue(obj['enum'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-export-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-export-escaped.js new file mode 100644 index 0000000000..91a6a832fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-export-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/export-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: export is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0065xport: 42 +}; + +assert.sameValue(obj['export'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped-ext.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped-ext.js new file mode 100644 index 0000000000..edf247f0c2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped-ext.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped-ext.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: extends is a valid identifier name, using extended escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u{65}xtends: 42 +}; + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped.js new file mode 100644 index 0000000000..9ac59a11b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: extends is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0065xtends: 42 +}; + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends.js new file mode 100644 index 0000000000..f1263dea4a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-extends.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: extends is a valid identifier name (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + extends: 42 +}; + +assert.sameValue(obj['extends'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-finally-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-finally-escaped.js new file mode 100644 index 0000000000..3942b5783a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-finally-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/finally-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: finally is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0066inally: 42 +}; + +assert.sameValue(obj['finally'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-for-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-for-escaped.js new file mode 100644 index 0000000000..e3be4e0e53 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-for-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/for-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: for is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0066or: 42 +}; + +assert.sameValue(obj['for'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-function-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-function-escaped.js new file mode 100644 index 0000000000..bf53fd163e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-function-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/function-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: function is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0066unction: 42 +}; + +assert.sameValue(obj['function'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-if-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-if-escaped.js new file mode 100644 index 0000000000..81f7328597 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-if-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/if-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: if is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + i\u0066: 42 +}; + +assert.sameValue(obj['if'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-implements-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-implements-escaped.js new file mode 100644 index 0000000000..d715f14a06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-implements-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/implements-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: implements is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0069mplements: 42 +}; + +assert.sameValue(obj['implements'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-import-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-import-escaped.js new file mode 100644 index 0000000000..61e696a9f7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-import-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/import-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: import is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0069mport: 42 +}; + +assert.sameValue(obj['import'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-in-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-in-escaped.js new file mode 100644 index 0000000000..334a719eaf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-in-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/in-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: in is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0069n: 42 +}; + +assert.sameValue(obj['in'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-instanceof-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-instanceof-escaped.js new file mode 100644 index 0000000000..61fbe06591 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-instanceof-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/instanceof-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: instanceof is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + \u0069nstanceof: 42 +}; + +assert.sameValue(obj['instanceof'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-interface-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-interface-escaped.js new file mode 100644 index 0000000000..1d054d30c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-interface-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/interface-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: interface is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + interf\u0061ce: 42 +}; + +assert.sameValue(obj['interface'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-let-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-let-escaped.js new file mode 100644 index 0000000000..b6ce475f57 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-let-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/let-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: let is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + l\u0065t: 42 +}; + +assert.sameValue(obj['let'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-new-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-new-escaped.js new file mode 100644 index 0000000000..def5e42d91 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-new-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/new-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: new is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + n\u0065w: 42 +}; + +assert.sameValue(obj['new'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-package-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-package-escaped.js new file mode 100644 index 0000000000..7342a3fce5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-package-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/package-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: package is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + p\u0061ckage: 42 +}; + +assert.sameValue(obj['package'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-private-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-private-escaped.js new file mode 100644 index 0000000000..deabe2145a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-private-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/private-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: private is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + privat\u0065: 42 +}; + +assert.sameValue(obj['private'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-protected-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-protected-escaped.js new file mode 100644 index 0000000000..d9c011746e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-protected-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/protected-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: protected is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + prot\u0065cted: 42 +}; + +assert.sameValue(obj['protected'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-public-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-public-escaped.js new file mode 100644 index 0000000000..ae0372c0cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-public-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/public-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: public is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + pu\u0062lic: 42 +}; + +assert.sameValue(obj['public'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-return-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-return-escaped.js new file mode 100644 index 0000000000..51bb7f7e0e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-return-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/return-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: return is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + r\u0065turn: 42 +}; + +assert.sameValue(obj['return'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-static-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-static-escaped.js new file mode 100644 index 0000000000..ac3ef28e57 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-static-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/static-escaped.case +// - src/identifier-names/future-reserved-words/obj-prop-name.template +/*--- +description: static is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + st\u0061tic: 42 +}; + +assert.sameValue(obj['static'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-super-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-super-escaped.js new file mode 100644 index 0000000000..10b5eee9bf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-super-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/super-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: super is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + sup\u0065r: 42 +}; + +assert.sameValue(obj['super'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-switch-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-switch-escaped.js new file mode 100644 index 0000000000..699208b612 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-switch-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/switch-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: switch is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + sw\u0069tch: 42 +}; + +assert.sameValue(obj['switch'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-this-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-this-escaped.js new file mode 100644 index 0000000000..0b9d403d32 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-this-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/this-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: this is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + th\u0069s: 42 +}; + +assert.sameValue(obj['this'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-throw-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-throw-escaped.js new file mode 100644 index 0000000000..2987f9cd41 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-throw-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/throw-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: throw is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + t\u0068row: 42 +}; + +assert.sameValue(obj['throw'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-try-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-try-escaped.js new file mode 100644 index 0000000000..d85205adb3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-try-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/try-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: try is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + tr\u0079: 42 +}; + +assert.sameValue(obj['try'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-typeof-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-typeof-escaped.js new file mode 100644 index 0000000000..bbd40a432f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-typeof-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/typeof-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: typeof is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + typ\u0065of: 42 +}; + +assert.sameValue(obj['typeof'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-var-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-var-escaped.js new file mode 100644 index 0000000000..4bbfa26cf3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-var-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/var-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: var is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + v\u0061r: 42 +}; + +assert.sameValue(obj['var'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-void-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-void-escaped.js new file mode 100644 index 0000000000..9a0c99fd21 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-void-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/void-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: void is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + voi\u0064: 42 +}; + +assert.sameValue(obj['void'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-while-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-while-escaped.js new file mode 100644 index 0000000000..e52ede12d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-while-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/while-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: while is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + whil\u0065: 42 +}; + +assert.sameValue(obj['while'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-with-escaped.js b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-with-escaped.js new file mode 100644 index 0000000000..8bcc439f59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/ident-name-prop-name-literal-with-escaped.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/with-escaped.case +// - src/identifier-names/default/obj-prop-name.template +/*--- +description: with is a valid identifier name, using escape (PropertyName) +esid: prod-PropertyDefinition +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + IdentifierReference + PropertyName : AssignmentExpression + MethodDefinition + ... AssignmentExpression + ... + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. +---*/ + +var obj = { + w\u0069th: 42 +}; + +assert.sameValue(obj['with'], 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-await-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-await-strict-mode.js new file mode 100644 index 0000000000..23dd4af93a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-await-strict-mode.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. await is valid in non-module strict mode code. +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + Identifier : IdentifierName but not ReservedWord + +---*/ + +var await = 1; +(function() { + "use strict"; + ({ + await + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-implements-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-implements-invalid-strict-mode.js new file mode 100644 index 0000000000..d197a4b639 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-implements-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (implements) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var implements = 1; +(function() { + "use strict"; + ({ + implements + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-interface-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-interface-invalid-strict-mode.js new file mode 100644 index 0000000000..0ed4b73162 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-interface-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (interface) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var interface = 1; +(function() { + "use strict"; + ({ + interface + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-computed-name.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-computed-name.js new file mode 100644 index 0000000000..a323ddad33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-computed-name.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are only valid with identifier references, + not computed property names. +esid: sec-object-initializer +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + PropertyName: + LiteralPropertyName + ComputedPropertyName +negative: + phase: parse + type: SyntaxError +---*/ + +var x = "y"; +var y = 42; + +$DONOTEVALUATE(); + +({[x]}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-zero.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-zero.js new file mode 100644 index 0000000000..77b619b624 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-invalid-zero.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 The V8 Project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are only valid with identifier references, + not property names. (0) +esid: sec-object-initializer +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({0}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-let-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-let-invalid-strict-mode.js new file mode 100644 index 0000000000..0ec29c8fe1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-let-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (let) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var let = 1; +(function() { + "use strict"; + ({ + let + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-package-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-package-invalid-strict-mode.js new file mode 100644 index 0000000000..74f37c120f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-package-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (package) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var package = 1; +(function() { + "use strict"; + ({ + package + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-private-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-private-invalid-strict-mode.js new file mode 100644 index 0000000000..3cbbb7d0d4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-private-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (private) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var private = 1; +(function() { + "use strict"; + ({ + private + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-protected-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-protected-invalid-strict-mode.js new file mode 100644 index 0000000000..350d47b8e7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-protected-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (protected) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var protected = 1; +(function() { + "use strict"; + ({ + protected + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-public-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-public-invalid-strict-mode.js new file mode 100644 index 0000000000..d47fcd7848 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-public-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (public) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var public = 1; +(function() { + "use strict"; + ({ + public + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-invalid.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-invalid.js new file mode 100644 index 0000000000..7cecd72f2b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-invalid.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: IdentifierReference may not be `await` within class static blocks +info: | + IdentifierReference : Identifier + + - It is a Syntax Error if the code matched by this production is nested, + directly or indirectly (but not crossing function or static initialization + block boundaries), within a ClassStaticBlock and the StringValue of + Identifier is "arguments" or "await". +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + ({ await }); + } +} + diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-valid.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-valid.js new file mode 100644 index 0000000000..0fca54dde8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-init-await-valid.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within the body of arrow functions +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + (() => ({ await })); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-invalid-strict-mode.js new file mode 100644 index 0000000000..3084a924dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-static-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (static) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var static = 1; +(function() { + "use strict"; + ({ + static + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/identifier-shorthand-yield-invalid-strict-mode.js b/js/src/tests/test262/language/expressions/object/identifier-shorthand-yield-invalid-strict-mode.js new file mode 100644 index 0000000000..bdfe427b71 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/identifier-shorthand-yield-invalid-strict-mode.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object literal shorthands are limited to valid identifier references. Future Reserved Words are disallowed in Strict Mode. (yield) +esid: sec-object-initializer +flags: [noStrict] +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + Identifier : IdentifierName but not ReservedWord + It is a Syntax Error if this phrase is contained in strict mode code and + the StringValue of IdentifierName is: "implements", "interface", "let", + "package", "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var yield = 1; +(function() { + "use strict"; + ({ + yield + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/let-non-strict-access.js b/js/src/tests/test262/language/expressions/object/let-non-strict-access.js new file mode 100644 index 0000000000..e9c23ff8b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/let-non-strict-access.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: 12.2.5 +description: > + In non-strict mode, let is a valid Identifier. +flags: [noStrict] +---*/ +var let = 1; +var object = {let}; + +assert.sameValue(object.let, 1, "The value of `object.let` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/let-non-strict-syntax.js b/js/src/tests/test262/language/expressions/object/let-non-strict-syntax.js new file mode 100644 index 0000000000..da6d49f2aa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/let-non-strict-syntax.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: 12.2.5 +description: > + In non-strict mode, let is a valid Identifier. +flags: [noStrict] +---*/ +var let = 1; +var object = {let}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/literal-property-name-bigint.js b/js/src/tests/test262/language/expressions/object/literal-property-name-bigint.js new file mode 100644 index 0000000000..ad502cbdb0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/literal-property-name-bigint.js @@ -0,0 +1,56 @@ +// Copyright (C) 2020 Igalia S.L, Toru Nagashima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + BigInt in LiteralPropertyName must be valid and the property name must be + the string representation of the numeric value. +esid: prod-PropertyName +info: | + PropertyName[Yield, Await]: + LiteralPropertyName + ComputedPropertyName[?Yield, ?Await] + + LiteralPropertyName: + IdentifierName + StringLiteral + NumericLiteral + + NumericLiteral: + DecimalLiteral + DecimalBigIntegerLiteral + + LiteralPropertyName: NumericLiteral + 1. Let _nbr_ be the NumericValue of |NumericLiteral|. + 1. Return ! ToString(_nbr_). +features: [BigInt, class, destructuring-binding, let] +---*/ + +// Property + +let o = { 999999999999999999n: true }; // greater than max safe integer + +assert.sameValue(o["999999999999999999"], true, + "the property name must be the string representation of the numeric value."); + +// MethodDeclaration + +o = { 1n() { return "bar"; } }; +assert.sameValue(o["1"](), "bar", + "the property name must be the string representation of the numeric value."); + +class C { + 1n() { return "baz"; } +} + +let c = new C(); +assert.sameValue(c["1"](), "baz", + "the property name must be the string representation of the numeric value."); + +// Destructuring + +let { 1n: a } = { "1": "foo" }; +assert.sameValue(a, "foo", + "the property name must be the string representation of the numeric value."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c141013d17 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier-escaped.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + var \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier.js new file mode 100644 index 0000000000..c747d0aaef --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-binding-identifier.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + var await; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..b1dcb105e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference-escaped.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + void \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference.js new file mode 100644 index 0000000000..3c7a6ef6cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-identifier-reference.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + void await; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..043ec046a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier-escaped.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + \u0061wait: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier.js new file mode 100644 index 0000000000..eda037cc56 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-await-as-label-identifier.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +var obj = { + async method() { + await: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..aadcbb8e76 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + var \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier.js new file mode 100644 index 0000000000..65a8faee06 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + var await; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..74d04cb2e3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + void \u0061wait; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference.js new file mode 100644 index 0000000000..a34ef5a980 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + void await; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..8e3645db40 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + \u0061wait: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier.js new file mode 100644 index 0000000000..1f28dc3581 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-await-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + await: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..a5b1aacd0f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-array-destructuring-param-strict-body.js @@ -0,0 +1,119 @@ +// |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/async-gen-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, { + async *method([element]) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-abrupt.js new file mode 100644 index 0000000000..71ee18569a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-abrupt.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/async-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..d82f55230c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-not-undefined.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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; +var obj = { + async *method(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; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +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'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..10eb13b33d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-arg-val-undefined.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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; +var obj = { + async *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-duplicates.js new file mode 100644 index 0000000000..bcfe752728 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-duplicates.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/async-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, { + async *method(x = 0, x) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-later.js new file mode 100644 index 0000000000..4b9feeafd9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-later.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/async-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-prior.js new file mode 100644 index 0000000000..cbf1d7b093 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-prior.js @@ -0,0 +1,53 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method(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; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-self.js new file mode 100644 index 0000000000..cc64c81ffb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-ref-self.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/async-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 obj = { + async *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-rest.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-rest.js new file mode 100644 index 0000000000..c0fb63602f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-rest.js @@ -0,0 +1,52 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/async-gen-meth.template +/*--- +description: RestParameter does not support an initializer (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +0, { + async *method(...x = []) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-trailing-comma.js new file mode 100644 index 0000000000..d3410ff852 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-dflt-params-trailing-comma.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var obj = { + async *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-escaped-async.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-escaped-async.js new file mode 100644 index 0000000000..93ee4852ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-escaped-async.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `async` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +({ + \u0061sync* m(){} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..60fcc0e75e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-eval-var-scope-syntax-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/async-gen-meth.template +/*--- +description: sloppy direct eval in params introduces var (async generator method in sloppy code) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [default-parameters, async-iteration] +flags: [generated, noStrict] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + +var callCount = 0; +var obj = { + async *method(a = eval("var a = 42")) { + + callCount = callCount + 1; + } +}; + +assert.throws(SyntaxError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..056bbc4bda --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-object-destructuring-param-strict-body.js @@ -0,0 +1,119 @@ +// |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/async-gen-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, { + async *method({property}) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-multiple.js new file mode 100644 index 0000000000..587d350e52 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-multiple.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var obj = { + async *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-single.js new file mode 100644 index 0000000000..270581a6f6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-params-trailing-comma-single.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +var obj = { + async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'generator method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-param-strict-body.js new file mode 100644 index 0000000000..1352903427 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-param-strict-body.js @@ -0,0 +1,119 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/async-gen-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, { + async *method(a,...rest) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..60cbef5707 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-meth-rest-params-trailing-comma-early-error.js @@ -0,0 +1,45 @@ +// |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/async-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, { + async *method(...a,) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..181fa2e7a9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + var yi\u0065ld; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier.js new file mode 100644 index 0000000000..4b78e8b854 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + var yield; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..b0f36a3161 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + void yi\u0065ld; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference.js new file mode 100644 index 0000000000..fbe97d4c7c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + void yield; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..37f8f3f724 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + yi\u0065ld: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier.js new file mode 100644 index 0000000000..5e5a8093c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + async *method() { + yield: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js new file mode 100644 index 0000000000..168caf2778 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-obj-method.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) + } +}.method; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..c8818c3423 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-obj-method.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-AsyncGeneratorMethod +features: [object-spread, Symbol, async-iteration] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +var s = Symbol('s'); + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } + } +}.method; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); +iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(value[s], 42); + assert.sameValue(Object.keys(value).length, 5); + assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..6c9a911b62 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict-strict.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-strict-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-strict-strict.js new file mode 100644 index 0000000000..20f631cbd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-identifier-strict-strict.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..2420ffc691 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..b1fd5591b3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..3e439e389d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..b2b4d23311 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,48 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield * readFile(); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..155cb88be9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield * iterable; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js new file mode 100644 index 0000000000..aabbef284e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..557a65fcf6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js @@ -0,0 +1,50 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a array spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield [...yield yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js new file mode 100644 index 0000000000..7c6a3c9756 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a array spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield [...yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-obj.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-obj.js new file mode 100644 index 0000000000..1b97523c2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-spread-obj.js @@ -0,0 +1,52 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a object spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } +}.method; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-next.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-next.js new file mode 100644 index 0000000000..7f42750757 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-next.js @@ -0,0 +1,219 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-return.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-return.js new file mode 100644 index 0000000000..7b973e6c99 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-return.js @@ -0,0 +1,235 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: execution order for yield* with async iterator and return() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-throw.js new file mode 100644 index 0000000000..5a4b987537 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-async-throw.js @@ -0,0 +1,243 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-expr-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-expr-abrupt.js new file mode 100644 index 0000000000..a27c3dcfdd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-expr-abrupt.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting yield* operand (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..d5fe0a2a6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..2b204d708d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..636dbf8c65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..e6ffbbc2e4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..eb55185fcb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..dd8467be8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..87ec41d1c9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..e5d8933e26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..87adae9fc1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..fd736a66cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..98426837ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..d6dc2fa960 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..c574cd81b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..4da3ce8c99 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..c8e41e3e02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..250c246c9d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..fa1211cc87 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..c8cc4833d8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..a84b10fbd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..53d7f15758 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..8a9fba7b53 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..417ff749f1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..aaf00787b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..9603b31462 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..2dc6af0faa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..2decf2215d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..5105a46f85 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..d813a40142 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..fcd886cadd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting done (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..ba89de4d9d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while calling next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..95e03c5299 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..b069bce40a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..a85cb45bb5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,85 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..184a6d2035 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..b73b0cff40 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..3c4cba5654 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..70435b939f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..e7811e6852 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..ca2851b102 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..c96f1dd536 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..769d12ab18 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..8f23847cc2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..d06d699c91 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..018c8e579f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..33872eca33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..088e7a754c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..e968750365 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..6c6908110c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..f95d2b7a8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-next.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-next.js new file mode 100644 index 0000000000..890159024e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-next.js @@ -0,0 +1,222 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-return.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-return.js new file mode 100644 index 0000000000..4916e13b02 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-return.js @@ -0,0 +1,197 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-throw.js b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-throw.js new file mode 100644 index 0000000000..27647e55db --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-gen-yield-star-sync-throw.js @@ -0,0 +1,203 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } +}.method; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..bda831cfe2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-array-destructuring-param-strict-body.js @@ -0,0 +1,112 @@ +// |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/async-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async method) +esid: sec-async-function-definitions +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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(); + + +({ + async *method([element]) { + "use strict"; + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-abrupt.js new file mode 100644 index 0000000000..960f9d70a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-abrupt.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/async-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +obj.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, Test262Error)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..9c3a1c280a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-not-undefined.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/async-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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; +var __obj = { + async method(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; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(false, '', NaN, 0, null, obj).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); + +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'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..882b1ef52e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-arg-val-undefined.js @@ -0,0 +1,49 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/async-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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; +var __obj = { + async method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(undefined, void 0).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-duplicates.js new file mode 100644 index 0000000000..7f19edbca6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-duplicates.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/async-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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(); + + +({ + async *method(x = 0, x) { + + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-later.js new file mode 100644 index 0000000000..df76b9caf0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-later.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/async-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method(x = y, y) { + + callCount = callCount + 1; + } +}; + +obj.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-prior.js new file mode 100644 index 0000000000..37a264d40b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-prior.js @@ -0,0 +1,46 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/async-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 __obj = { + async method(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; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(3).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-self.js new file mode 100644 index 0000000000..c8ad2e5e8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-ref-self.js @@ -0,0 +1,47 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/async-meth.template +/*--- +description: Referencing a parameter from within its own initializer (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method(x = x) { + + callCount = callCount + 1; + } +}; + +obj.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-rest.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-rest.js new file mode 100644 index 0000000000..241c48840c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-rest.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/async-meth.template +/*--- +description: RestParameter does not support an initializer (async method) +esid: sec-async-function-definitions +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +({ + async *method(...x = []) { + + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-trailing-comma.js new file mode 100644 index 0000000000..779f5c7db0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-dflt-params-trailing-comma.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (async method) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +var __obj = { + async method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(42, undefined, 1).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-escaped-async.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-escaped-async.js new file mode 100644 index 0000000000..c5f5fe31c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-escaped-async.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `async` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +({ + \u0061sync m(){} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..002a1a643d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-eval-var-scope-syntax-err.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/async-meth.template +/*--- +description: sloppy direct eval in params introduces var (async method in sloppy code) +esid: sec-async-function-definitions +features: [default-parameters, async-functions] +flags: [generated, async, noStrict] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + + Runtime Semantics: IteratorBindingInitialization + FormalParameter : BindingElement + + 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment. + +---*/ + + +var callCount = 0; + +var obj = { + async method(a = eval("var a = 42")) { + + callCount = callCount + 1; + } +}; + +obj.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, SyntaxError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..db358683bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-object-destructuring-param-strict-body.js @@ -0,0 +1,112 @@ +// |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/async-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async method) +esid: sec-async-function-definitions +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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(); + + +({ + async *method({property}) { + "use strict"; + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-multiple.js new file mode 100644 index 0000000000..8a740f78d3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-multiple.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (async method) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +var __obj = { + async method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(42, 39, 1).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-single.js new file mode 100644 index 0000000000..701eaf4a09 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-params-trailing-comma-single.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (async method) +esid: sec-async-function-definitions +features: [async-functions] +flags: [generated, async] +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +var __obj = { + async method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(42, 39).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-param-strict-body.js new file mode 100644 index 0000000000..ea1142fa98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-param-strict-body.js @@ -0,0 +1,112 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/async-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (async method) +esid: sec-async-function-definitions +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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(); + + +({ + async *method(a,...rest) { + "use strict"; + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..5ae9534599 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-meth-rest-params-trailing-comma-early-error.js @@ -0,0 +1,38 @@ +// |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/async-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async method) +esid: sec-async-function-definitions +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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(); + + +({ + async *method(...a,) { + + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..0aee873d77 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,35 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + let a = arguments; + return async () => a === arguments; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..c3c594c8b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow-returns-newtarget.js @@ -0,0 +1,34 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + return async () => new.target; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow.js new file mode 100644 index 0000000000..039441ad8b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-arrow.js @@ -0,0 +1,34 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + return async () => x; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..9426a566ae --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,35 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..564b648dd6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function-returns-newtarget.js @@ -0,0 +1,34 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + return async function() { return new.target; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function.js b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function.js new file mode 100644 index 0000000000..7d1e6eba11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-returns-async-function.js @@ -0,0 +1,34 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-obj-method.template +/*--- +description: Async function returns an async function. (Async method) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +var obj = { + async method(x) { + return async function() { return x; }; + } +}; +// Stores a reference `asyncFn` for case evaluation +let asyncFn = obj.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-body.js b/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-body.js new file mode 100644 index 0000000000..4ed22c55b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-body.js @@ -0,0 +1,28 @@ +// |reftest| async +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: > + Super calls work in body of async methods +flags: [async] +---*/ + +var sup = { + method() { + return 'sup'; + } +} + +var child = { + async method() { + var x = await super.method(); + assert.sameValue(x, 'sup'); + } +} + +Object.setPrototypeOf(child, sup); + +child.method().then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-param.js b/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-param.js new file mode 100644 index 0000000000..86fe1307bc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/async-super-call-param.js @@ -0,0 +1,29 @@ +// |reftest| async +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: > + Super calls work in parameter list of async methods +flags: [async] +---*/ + +var sup = { + method() { + return 'sup'; + } +} + +var child = { + async method(x = super.method()) { + var y = await x; + assert.sameValue(y, 'sup'); + } +} + +Object.setPrototypeOf(child, sup); + +child.method().then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/expressions/object/method-definition/browser.js b/js/src/tests/test262/language/expressions/object/method-definition/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/browser.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/computed-property-name-yield-expression.js b/js/src/tests/test262/language/expressions/object/method-definition/computed-property-name-yield-expression.js new file mode 100644 index 0000000000..77ea65c1da --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/computed-property-name-yield-expression.js @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + When the `yield` keyword occurs within the PropertyName of a + non-generator MethodDefinition within a generator function, it behaves as a + YieldExpression. +info: | + ComputedPropertyName: + [ AssignmentExpression ] + + AssignmentExpression[In, Yield, Await]: + [+Yield]YieldExpression[?In, ?Await] + +features: [computed-property-names, generators] +flags: [noStrict] +---*/ + +function * g() { + let o = { + [yield 10]: 1, + a: 'a' + }; + + yield 20; + return o; +} + +let iter = g(); +assert.sameValue(iter.next().value, 10); +assert.sameValue(iter.next().value, 20); + +let outcome = iter.next().value; + +assert.sameValue(outcome[undefined], 1); +assert.sameValue(outcome.a, 'a'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-async-method-duplicate-parameters.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-async-method-duplicate-parameters.js new file mode 100644 index 0000000000..62eec9d285 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-async-method-duplicate-parameters.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: sec-async-function-definitions +description: Formal parameters may not contain duplicates +info: | + # 14.7 Async Function Definitions + + AsyncMethod[Yield, Await]: + async[no LineTerminator here]PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, +Await]){AsyncFunctionBody} + + # 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(); +({ + async foo(a, a) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js new file mode 100644 index 0000000000..7bc49b870c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: > + It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is *true* and IsSimpleParameterList of ArrowParameters is *false*. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +({ + foo(x = 1) {"use strict"} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters-strict.js new file mode 100644 index 0000000000..0ffffe32dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if FormalParameters contains arguments +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-functions] +---*/ + +$DONOTEVALUATE(); +({ + async foo (arguments) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js new file mode 100644 index 0000000000..11aec56407 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-AsyncMethod +description: async methods cannot have a line terminator between "async" and the property name +info: | + 14.6 Async Function Definitions + + AsyncMethod: + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + async + foo() { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js new file mode 100644 index 0000000000..7c7cdcf4c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if FormalParameters' default expressions contains await +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); +({ + async foo (x = await) { } +}) + diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js new file mode 100644 index 0000000000..d6b03faa9c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if FormalParameters contains await +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); +({ + async foo (await) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js new file mode 100644 index 0000000000..cb2fe94af5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if AsyncFunctionBody contains SuperCall is true +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); +({ + async foo () { super() } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js new file mode 100644 index 0000000000..b815f86088 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js @@ -0,0 +1,28 @@ +// |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-method-definitions +description: Formal parameters may not contain duplicates +info: | + # 14.3 Method Definitions + + MethodDefinition[Yield, Await]: + PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, ~Await]){FunctionBody[~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(); +({ + foo(a, a) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters-strict.js new file mode 100644 index 0000000000..818a542b6c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters-strict.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if FormalParameters contains eval in strict mode +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +features: [async-functions] +---*/ + +$DONOTEVALUATE(); +({ + async foo(eval) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js new file mode 100644 index 0000000000..7b0b092ea0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a SyntaxError if BoundNames of FormalParameters also occurs in the LexicallyDeclaredNames of AsyncFunctionBody +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +({ + async function foo(bar) { let bar; } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js new file mode 100644 index 0000000000..c332a4e846 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: It is a syntax error if FormalParameters contains SuperCall is true +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +({ + async foo(foo = super()) { } +}) diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-e.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-e.js new file mode 100644 index 0000000000..b3d81fdb95 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-e.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `get` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + g\u0065t m() {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-g.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-g.js new file mode 100644 index 0000000000..75736d5796 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-g.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `get` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + \u0067et m() {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-t.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-t.js new file mode 100644 index 0000000000..8ffa507dcc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get-t.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `get` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + ge\u0074 m() {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-get.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get.js new file mode 100644 index 0000000000..f1c64a4533 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-get.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `get` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + \u0067\u0065\u0074 m() {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-e.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-e.js new file mode 100644 index 0000000000..a8050d16d2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-e.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `set` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + s\u0065t m(v) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-s.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-s.js new file mode 100644 index 0000000000..2aa423b4f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-s.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `set` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + \u0073et m(v) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-t.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-t.js new file mode 100644 index 0000000000..c7af0b976b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set-t.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `set` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + se\u0074 m(v) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/escaped-set.js b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set.js new file mode 100644 index 0000000000..c9b80ebbe7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/escaped-set.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `set` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + \u0073\u0065\u0074 m(v) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/fn-name-fn.js b/js/src/tests/test262/language/expressions/object/method-definition/fn-name-fn.js new file mode 100644 index 0000000000..bd67abeb44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/fn-name-fn.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: 12.2.6.9 +description: Assignment of function `name` attribute (MethodDefinition) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + id() {}, + [anonSym]() {}, + [namedSym]() {} +}; + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/fn-name-gen.js b/js/src/tests/test262/language/expressions/object/method-definition/fn-name-gen.js new file mode 100644 index 0000000000..1ecbed8f2a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/fn-name-gen.js @@ -0,0 +1,43 @@ +// 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.4.13 +description: > + Assignment of function `name` attribute (GeneratorMethod) +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + [...] + 9. Perform SetFunctionName(closure, propKey). +includes: [propertyHelper.js] +features: [generators, Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var o; + +o = { + *id() {}, + *[anonSym]() {}, + *[namedSym]() {} +}; + +assert.sameValue(o.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(o.id, 'name'); +verifyNotWritable(o.id, 'name'); +verifyConfigurable(o.id, 'name'); + +assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(o[anonSym], 'name'); +verifyNotWritable(o[anonSym], 'name'); +verifyConfigurable(o[anonSym], 'name'); + +assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(o[namedSym], 'name'); +verifyNotWritable(o[namedSym], 'name'); +verifyConfigurable(o[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..3482e62678 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,40 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Forbidden extension, f.arguments (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [arrow-function, async-iteration, generators] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + + 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 obj = { + async *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +}; + +obj.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..7be74395e6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-gen-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,40 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [arrow-function, async-iteration, generators] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + + 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 obj = { + async *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +}; + +obj.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..04968aeb0d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,41 @@ +// |reftest| async +// 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/async-meth.template +/*--- +description: Forbidden extension, f.arguments (async method) +esid: sec-async-function-definitions +features: [arrow-function, async-functions] +flags: [generated, noStrict, async] +info: | + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +}; + +obj.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..2f1b6d96dd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/async-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,41 @@ +// |reftest| async +// 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/async-meth.template +/*--- +description: Forbidden extension, o.caller (async method) +esid: sec-async-function-definitions +features: [arrow-function, async-functions] +flags: [generated, noStrict, async] +info: | + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +}; + +obj.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/browser.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..90481c7c99 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,38 @@ +// 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/gen-meth.template +/*--- +description: Forbidden extension, f.arguments (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + + 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 obj = { + *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..a6535ae934 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/gen-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,38 @@ +// 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/gen-meth.template +/*--- +description: Forbidden extension, o.caller (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + + 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 obj = { + *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..5c739e5c00 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,35 @@ +// 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/meth.template +/*--- +description: Forbidden extension, f.arguments (method) +esid: sec-runtime-semantics-definemethod +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + 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 obj = { + method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..445d706dbc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,35 @@ +// 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/meth.template +/*--- +description: Forbidden extension, o.caller (method) +esid: sec-runtime-semantics-definemethod +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + 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 obj = { + method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b1/shell.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..7be88f006a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,66 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [arrow-function, async-iteration, generators] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + + 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 obj = { + async *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..7b4ad46cc5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,66 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [arrow-function, async-iteration, generators] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + + 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 obj = { + async *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..4e7383d47f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-gen-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,66 @@ +// |reftest| async +// 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/async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (async generator method) +esid: sec-asyncgenerator-definitions-propertydefinitionevaluation +features: [arrow-function, async-iteration, generators] +flags: [generated, noStrict, async] +info: | + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + + 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 obj = { + async *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..8c4587393c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,67 @@ +// |reftest| async +// 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/async-meth.template +/*--- +description: Forbidden extension, o.caller (async method) +esid: sec-async-definitions +features: [arrow-function, async-functions] +flags: [generated, noStrict, async] +info: | + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..0825fc002d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,67 @@ +// |reftest| async +// 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/async-meth.template +/*--- +description: Forbidden extension, o.caller (async method) +esid: sec-async-definitions +features: [arrow-function, async-functions] +flags: [generated, noStrict, async] +info: | + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..339ea9ef5b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/async-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,67 @@ +// |reftest| async +// 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/async-meth.template +/*--- +description: Forbidden extension, o.caller (async method) +esid: sec-async-definitions +features: [arrow-function, async-functions] +flags: [generated, noStrict, async] +info: | + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + 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 obj = { + async method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/browser.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..de57ed3f17 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,64 @@ +// 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/gen-meth.template +/*--- +description: Forbidden extension, o.caller (generator method) +esid: sec-generator-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + + 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 obj = { + *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next().value; +assert.sameValue(callCount, 1, 'generator method body was evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..86eb411a42 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,64 @@ +// 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/gen-meth.template +/*--- +description: Forbidden extension, o.caller (generator method) +esid: sec-generator-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + + 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 obj = { + *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next().value; +assert.sameValue(callCount, 1, 'generator method body was evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..c6d5da32bb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,64 @@ +// 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/gen-meth.template +/*--- +description: Forbidden extension, o.caller (generator method) +esid: sec-generator-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + + 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 obj = { + *method() { + "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 + 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, this.method); + } + callCount++; + } +}; + +obj.method().next().value; +assert.sameValue(callCount, 1, 'generator method body was evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..755cced7f1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-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/meth.template +/*--- +description: Forbidden extension, o.caller (method) +esid: sec-runtime-semantics-definemethod +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + 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 obj = { + method() { + "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 + 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, this.method); + } + + callCount++; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..f34e303a0e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-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/meth.template +/*--- +description: Forbidden extension, o.caller (method) +esid: sec-runtime-semantics-definemethod +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + 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 obj = { + method() { + "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 + 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, this.method); + } + + callCount++; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..3ebf9fe182 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/meth-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/meth.template +/*--- +description: Forbidden extension, o.caller (method) +esid: sec-runtime-semantics-definemethod +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + 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 obj = { + method() { + "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 + 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, this.method); + } + + callCount++; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/b2/shell.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/browser.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/browser.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/shell.js b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/forbidden-ext/shell.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..b05d92c975 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-array-destructuring-param-strict-body.js @@ -0,0 +1,141 @@ +// |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/gen-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method([element]) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-abrupt.js new file mode 100644 index 0000000000..66050c3bd9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..62d8f68b98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-arg-val-not-undefined.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/gen-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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; +var obj = { + *method(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; + } +}; + +obj.method(false, '', NaN, 0, null, obj).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method 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/object/method-definition/gen-meth-dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..ed813ed055 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-arg-val-undefined.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/gen-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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; +var obj = { + *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +obj.method(undefined, void 0).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js new file mode 100644 index 0000000000..0a420f3c65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js @@ -0,0 +1,70 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method(x = 0, x) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-later.js new file mode 100644 index 0000000000..4896ed4fb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-later.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-prior.js new file mode 100644 index 0000000000..31cf8c202a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-prior.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(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; + } +}; + +obj.method(3).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-self.js new file mode 100644 index 0000000000..e9c760f74b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-ref-self.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-rest.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-rest.js new file mode 100644 index 0000000000..db09934efb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-rest.js @@ -0,0 +1,74 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/gen-meth.template +/*--- +description: RestParameter does not support an initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method(...x = []) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-trailing-comma.js new file mode 100644 index 0000000000..9475c8d9b2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-dflt-params-trailing-comma.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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; +var obj = { + *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +obj.method(42, undefined, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..d04259c457 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-eval-var-scope-syntax-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/gen-meth.template +/*--- +description: sloppy direct eval in params introduces var (generator method in sloppy code) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [default-parameters, generators] +flags: [generated, noStrict] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(a = eval("var a = 42")) { + + callCount = callCount + 1; + } +}; + +assert.throws(SyntaxError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..b10d612aca --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-object-destructuring-param-strict-body.js @@ -0,0 +1,141 @@ +// |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/gen-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method({property}) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-multiple.js new file mode 100644 index 0000000000..1c2aa808a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-multiple.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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; +var obj = { + *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +obj.method(42, 39, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-single.js new file mode 100644 index 0000000000..32bd3c08e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-params-trailing-comma-single.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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; +var obj = { + *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +}; + +obj.method(42, 39).next(); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-param-strict-body.js new file mode 100644 index 0000000000..a60d7dfc90 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-param-strict-body.js @@ -0,0 +1,141 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/gen-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method(a,...rest) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..7238cc6dde --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-meth-rest-params-trailing-comma-early-error.js @@ -0,0 +1,67 @@ +// |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/gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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, { + *method(...a,) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..1082896597 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + var yi\u0065ld; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier.js new file mode 100644 index 0000000000..9eadc20db7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-binding-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + var yield; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..44972293de --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + void yi\u0065ld; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference.js new file mode 100644 index 0000000000..ac3bb6d022 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-identifier-reference.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + void yield; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..c6beb85f3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier-escaped.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + yi\u0065ld: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier.js new file mode 100644 index 0000000000..ed4e11a171 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-as-label-identifier.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/obj-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +var obj = { + *method() { + yield: ; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-non-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-non-strict.js new file mode 100644 index 0000000000..4be93d4a8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-non-strict.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-non-strict.case +// - src/generators/non-strict/obj-method.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated, noStrict] +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) + } +}.method; + +var iter = gen(); + +var item = iter.next(); + +assert.sameValue(item.done, false); +assert.sameValue(item.value, undefined); + +item = iter.next(42); + +assert.sameValue(item.done, true); +assert.sameValue(item.value, 43); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-non-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..6718d4ffa7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-non-strict.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-non-strict.case +// - src/generators/non-strict/obj-method.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-GeneratorMethod +features: [Symbol, object-spread, generators] +flags: [generated, noStrict] +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +var s = Symbol('s'); + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } + } +}.method; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); +iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); +var item = iter.next({ z: 30, b: 2 }); + +var value = item.value; + +assert.sameValue(item.done, false); +assert.sameValue(value.x, 10); +assert.sameValue(value.y, 20); +assert.sameValue(value.z, 30); +assert.sameValue(value.a, 1); +assert.sameValue(value.b, 2); +assert.sameValue(value[s], 42); +assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); +assert.sameValue(Object.keys(value).length, 5); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..968afe2fe3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-spread-strict-strict.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/obj-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator method) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-strict-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-strict-strict.js new file mode 100644 index 0000000000..6e36a3e99f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-identifier-strict-strict.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/obj-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..1352d0507b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-multiple.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/obj-method.template +/*--- +description: Use yield value in a array spread position (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +includes: [compareArray.js] +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + yield [...yield yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-single.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-single.js new file mode 100644 index 0000000000..964cbdf9f8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-arr-single.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/obj-method.template +/*--- +description: Use yield value in a array spread position (Generator method) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + yield [...yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-obj.js b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-obj.js new file mode 100644 index 0000000000..b6664311a4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/gen-yield-spread-obj.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/obj-method.template +/*--- +description: Use yield value in a object spread position (Generator method) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated] +info: | + 14.4 Generator Function Definitions + + GeneratorMethod[Yield, Await]: + * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var gen = { + *method() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } +}.method; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-ctor.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-ctor.js new file mode 100644 index 0000000000..727b8337c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-ctor.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. + +/*--- +description: > + Generator functions declared as methods cannot be used as constructors. +es6id: 14.4.13 +features: [generators] +---*/ + +var method = { *method() {} }.method; + +assert.throws(TypeError, function() { + var instance = new method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-no-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-no-strict.js new file mode 100644 index 0000000000..6406a25a6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-no-strict.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + In the absence of the "use strict" directive, generator functions declared + as methods obey "global" ThisMode semantics. +es6id: 14.4.13 +flags: [noStrict] +features: [generators] +---*/ + +var global = (function() { return this; }()); +var thisValue = null; +var method = { + *method() { + thisValue = this; + } +}.method; + +method().next(); + +assert.sameValue(thisValue, global); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-strict.js new file mode 100644 index 0000000000..a9b0e3cb3d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-invoke-fn-strict.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + In the presence of the "use strict" directive, generator functions declared + as methods obey "strict" ThisMode semantics. +es6id: 14.4.13 +flags: [noStrict] +features: [generators] +---*/ + +var thisValue = null; +var method = { + *method() { + 'use strict'; + thisValue = this; + } +}.method; + +method().next(); + +assert.sameValue(thisValue, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-length-dflt.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-length-dflt.js new file mode 100644 index 0000000000..5f3a6f96a0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-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: [generators, default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = { *m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { *m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { *m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { *m(x, y = 42, z) {} }.m; + +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/object/method-definition/generator-length.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-length.js new file mode 100644 index 0000000000..93e5c72b8f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-length.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. + +/*--- +description: > + Generator functions declared as methods have a `length` property that + describes the number of formal parameters. +es6id: 14.4.13 +includes: [propertyHelper.js] +features: [generators] +---*/ + +var method = { *method(a, b, c) {} }.method; + +assert.sameValue(method.length, 3); +verifyNotEnumerable(method, 'length'); +verifyNotWritable(method, 'length'); +verifyConfigurable(method, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-string.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-string.js new file mode 100644 index 0000000000..96707b6883 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-string.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. + +/*--- +description: > + Generator functions declared as methods are assigned a `name` property + according to the string value of their property name. +es6id: 14.4.13 +includes: [propertyHelper.js] +features: [generators] +---*/ + +var method = { *method() {} }.method; + +assert.sameValue(method.name, 'method'); +verifyNotEnumerable(method, 'name'); +verifyNotWritable(method, 'name'); +verifyConfigurable(method, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-symbol.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-symbol.js new file mode 100644 index 0000000000..c506a32cab --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-name-prop-symbol.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. + +/*--- +description: > + Generator functions declared as methods are assigned a `name` property + according to the string value of their property name. +es6id: 14.4.13 +includes: [propertyHelper.js] +features: [Symbol, generators] +---*/ + +var m = Symbol('method'); +var method = { *[m]() {} }[m]; + +assert.sameValue(method.name, '[method]'); +verifyNotEnumerable(method, 'name'); +verifyNotWritable(method, 'name'); +verifyConfigurable(method, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-no-yield.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-no-yield.js new file mode 100644 index 0000000000..c217b75f90 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-no-yield.js @@ -0,0 +1,22 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Generators declared with GeneratorMethod syntax do not require a + `yield` expression. + features: [generators] + es6id: 14.4 +---*/ + +var result; +var obj = { + *foo(a) {} +}; + +result = obj.foo(3).next(); + +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-param-id-yield.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-id-yield.js new file mode 100644 index 0000000000..65a443daa8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-id-yield.js @@ -0,0 +1,21 @@ +// |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. + +/*--- +description: > + The BindingIdentifier of a SingleNameBinding witihn the FormalParameters of + a GeneratorMethod may not be the `yield` keyword. +es6id: 14.4 +features: [generators] +flags: [noStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + *method(yield) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-param-init-yield.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-init-yield.js new file mode 100644 index 0000000000..3f07f6316d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-init-yield.js @@ -0,0 +1,23 @@ +// |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. + +/*--- +description: > + The Initializer of a SingleNameBinding witihn the FormalParameters of a + GeneratorMethod may not contain the `yield` keyword. +es6id: 14.4 +features: [generators] +flags: [noStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +(function*() { + ({ + *method(x = yield) {} + }); +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-const.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-const.js new file mode 100644 index 0000000000..13db6a8e28 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-const.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod early SyntaxError when lexical declaration + inside generator shadows parameter name +features: [generators] +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod error with lexical shadowing +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *foo(a) { + const a = 3; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-let.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-let.js new file mode 100644 index 0000000000..38c74a2fc9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-param-redecl-let.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod early SyntaxError when lexical declaration + inside generator shadows parameter name +features: [generators] +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod error with lexical shadowing +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *foo(a) { + let a = 3; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-params.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-params.js new file mode 100644 index 0000000000..605419c8fb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-params.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Generator functions declared as methods honor their declared formal + parameters. +es6id: 14.4.13 +features: [generators] +---*/ + +var value1 = {}; +var value2 = {}; +var value3 = {}; +var arg1, arg2, arg3; +var obj = { + *method(a, b, c) { + arg1 = a; + arg2 = b; + arg3 = c; + } +}; + +obj.method(value1, value2, value3).next(); + +assert.sameValue(arg1, value1); +assert.sameValue(arg2, value2); +assert.sameValue(arg3, value3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-eval-error.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-eval-error.js new file mode 100644 index 0000000000..62a7bed5c4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-eval-error.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. + +/*--- +description: > + Errors thrown during method definition are forwarded to the runtime. +es6id: 14.4.13 +features: [generators] +---*/ + +assert.throws(Test262Error, function() { + ({ + *[(function() { throw new Test262Error(); }())]() {} + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-expr.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-expr.js new file mode 100644 index 0000000000..4f68db8aa1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-expr.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. + +/*--- +description: > + When the `yield` keyword occurs within the PropertyName of a + GeneratorMethod within a generator function, it behaves as a + YieldExpression. +es6id: 14.4 +features: [generators] +flags: [noStrict] +---*/ + +var obj = null; +var yield = 'propNameViaIdentifier'; +var iter = (function*() { + obj = { + *[yield]() {} + }; +})(); + +iter.next(); + +assert.sameValue(obj, null); + +iter.next('propNameViaExpression'); + +assert( + !Object.prototype.hasOwnProperty.call(obj, 'propNameViaIdentifier'), + "The property name is not taken from the 'yield' variable" +); +assert( + Object.prototype.hasOwnProperty.call(obj, 'propNameViaExpression'), + "The property name is taken from the yield expression" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-id.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-id.js new file mode 100644 index 0000000000..b12f993f2e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-prop-name-yield-id.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. + +/*--- +description: > + When the `yield` keyword occurs within the PropertyName of a + GeneratorMethod outside of a generator function, it behaves as an + Identifier. +es6id: 14.4 +features: [generators] +flags: [noStrict] +---*/ + +var yield = 'propName'; +var obj = { + *[yield]() {} +}; + +assert( + Object.prototype.hasOwnProperty.call(obj, 'propName'), + "The property name is taken from the 'yield' variable" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-property-desc.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-property-desc.js new file mode 100644 index 0000000000..e079a31ab2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-property-desc.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. + +/*--- +description: > + Generator functions declared as methods are defined as enumerable, + writable, configurable properties on the initialized object. +es6id: 14.4.13 +includes: [propertyHelper.js] +features: [generators] +---*/ + +var obj = { *method() {} }; + +verifyEnumerable(obj, 'method'); +verifyWritable(obj, 'method'); +verifyConfigurable(obj, 'method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype-prop.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype-prop.js new file mode 100644 index 0000000000..9ca466d1b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype-prop.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. + +/*--- +description: > + Generator functions declared as methods define a `prototype` property. +es6id: 14.4.13 +includes: [propertyHelper.js] +features: [generators] +---*/ + +var GeneratorPrototype = Object.getPrototypeOf(function* () {}).prototype; +var method = { *method() {} }.method; + +verifyNotEnumerable(method, 'prototype'); +verifyWritable(method, 'prototype'); +verifyNotConfigurable(method, 'prototype'); + +assert.sameValue( + Object.getPrototypeOf(method.prototype), + GeneratorPrototype +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype.js new file mode 100644 index 0000000000..e1cbbe141f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-prototype.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. + +/*--- +description: > + The prototype of generator functions declared as methods is the + Generator Prototype. +es6id: 14.4.13 +features: [generators] +---*/ + +var obj = { *method() {} }; +assert.sameValue( + Object.getPrototypeOf(obj.method), + Object.getPrototypeOf(function*() {}) +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-return.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-return.js new file mode 100644 index 0000000000..ee4b6a20cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-return.js @@ -0,0 +1,25 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `return` is a valid statement within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var result; +var obj = { + *g1() { return; }, + *g2() { return 1; } +}; + +result = obj.g1().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +result = obj.g2().next(); +assert.sameValue(result.value, 1); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-body.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-body.js new file mode 100644 index 0000000000..cc619c9c5b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-body.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod early SyntaxError when super is called + directly inside generator body +features: [generators] +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod error if HasDirectSuper in body +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *foo(a) { + super(); + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-param.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-param.js new file mode 100644 index 0000000000..ff1cbb4347 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-call-param.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod early SyntaxError when super is called + directly inside generator args +features: [generators] +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod error if HasDirectSuper in args +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *foo(a = super()) { + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-body.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-body.js new file mode 100644 index 0000000000..15dde63dab --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-body.js @@ -0,0 +1,25 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod can reference SuperProperty in body +features: [generators] +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod body uses SuperProperty (allowed) +---*/ + +var obj; + +var obj = { + *foo() { + return super.toString; + } +}; + +obj.toString = null; + +assert.sameValue(obj.foo().next().value, Object.prototype.toString); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-param.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-param.js new file mode 100644 index 0000000000..f2d1f2d3af --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-super-prop-param.js @@ -0,0 +1,23 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + GeneratorMethod can reference SuperProperty in default parameters +es6id: 14.4.1 +author: Sam Mikes +description: GeneratorMethod uses SuperProperty (allowed) +features: [default-parameters, generators, super] +---*/ + +var obj = { + *foo(a = super.toString) { + return a; + } +}; + +obj.toString = null; + +assert.sameValue(obj.foo().next().value, Object.prototype.toString); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/generator-use-strict-with-non-simple-param.js b/js/src/tests/test262/language/expressions/object/method-definition/generator-use-strict-with-non-simple-param.js new file mode 100644 index 0000000000..aa390737b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/generator-use-strict-with-non-simple-param.js @@ -0,0 +1,25 @@ +// |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-generator-function-definitions-static-semantics-early-errors +description: > + A SyntaxError is thrown if a generator method contains a non-simple parameter list and a UseStrict directive. +info: | + Static Semantics: Early Errors + + It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and IsSimpleParameterList of StrictFormalParameters is false. +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +var o = { + *m(a = 0) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-array-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..9e3b782d2c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-array-destructuring-param-strict-body.js @@ -0,0 +1,137 @@ +// |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/meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (method) +esid: sec-runtime-semantics-definemethod +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method([element]) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-abrupt.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-abrupt.js new file mode 100644 index 0000000000..d0b95458d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-abrupt.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..e650ffe0ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-arg-val-not-undefined.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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; +var obj = { + method(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; + } +}; + +obj.method(false, '', NaN, 0, null, obj); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method 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/object/method-definition/meth-dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..ea061dbadd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-arg-val-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/meth.template +/*--- +description: Use of initializer when argument value is `undefined` (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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; +var obj = { + method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +obj.method(undefined, void 0); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-duplicates.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-duplicates.js new file mode 100644 index 0000000000..04dbd6f3da --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-duplicates.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method(x = 0, x) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-later.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-later.js new file mode 100644 index 0000000000..6bc6514fea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-later.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-prior.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-prior.js new file mode 100644 index 0000000000..dd1edc1264 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-prior.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(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; + } +}; + +obj.method(3); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-self.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-self.js new file mode 100644 index 0000000000..5990e01af2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-ref-self.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/meth.template +/*--- +description: Referencing a parameter from within its own initializer (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-rest.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-rest.js new file mode 100644 index 0000000000..05e0365c8d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-rest.js @@ -0,0 +1,70 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/meth.template +/*--- +description: RestParameter does not support an initializer (method) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method(...x = []) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-trailing-comma.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-trailing-comma.js new file mode 100644 index 0000000000..27275b4cd4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-dflt-params-trailing-comma.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (method) +esid: sec-runtime-semantics-definemethod +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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; +var obj = { + method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +obj.method(42, undefined, 1); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-eval-var-scope-syntax-err.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-eval-var-scope-syntax-err.js new file mode 100644 index 0000000000..61ba250a7d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-eval-var-scope-syntax-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/eval-var-scope-syntax-err.case +// - src/function-forms/error-no-strict/meth.template +/*--- +description: sloppy direct eval in params introduces var (method in sloppy code) +esid: sec-runtime-semantics-definemethod +features: [default-parameters] +flags: [generated, noStrict] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(a = eval("var a = 42")) { + + callCount = callCount + 1; + } +}; + +assert.throws(SyntaxError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-object-destructuring-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..e1bc9900b4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-object-destructuring-param-strict-body.js @@ -0,0 +1,137 @@ +// |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/meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (method) +esid: sec-runtime-semantics-definemethod +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method({property}) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-multiple.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-multiple.js new file mode 100644 index 0000000000..6dd75d99f2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-multiple.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (method) +esid: sec-runtime-semantics-definemethod +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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; +var obj = { + method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +}; + +obj.method(42, 39, 1); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-single.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-single.js new file mode 100644 index 0000000000..43d6c80f91 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-params-trailing-comma-single.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (method) +esid: sec-runtime-semantics-definemethod +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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; +var obj = { + method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +}; + +obj.method(42, 39); + +// Stores a reference `ref` for case evaluation +var ref = obj.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-param-strict-body.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-param-strict-body.js new file mode 100644 index 0000000000..d2b7c23fee --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-param-strict-body.js @@ -0,0 +1,137 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (method) +esid: sec-runtime-semantics-definemethod +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method(a,...rest) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..6c1e0435d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/meth-rest-params-trailing-comma-early-error.js @@ -0,0 +1,62 @@ +// |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/meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (method) +esid: sec-runtime-semantics-definemethod +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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, { + method(...a,) { + + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-ctor.js b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-ctor.js new file mode 100644 index 0000000000..f1c3450e44 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-ctor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions declared as methods may not be used as constructors. +es6id: 14.3.8 +---*/ + +var obj = { method() {} }; +assert.throws(TypeError, function() { + new obj.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-no-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-no-strict.js new file mode 100644 index 0000000000..ef606afbd0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-no-strict.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. + +/*--- +description: > + In the absence of the "use strict" directive, functions declared as methods + obey "global" ThisMode semantics. +es6id: 14.3.8 +flags: [noStrict] +---*/ + +var global = (function() { return this; }()); +var thisValue = null; +var method = { + method() { + thisValue = this; + } +}.method; + +method(); + +assert.sameValue(thisValue, global); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-strict.js b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-strict.js new file mode 100644 index 0000000000..aab879473e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-invoke-fn-strict.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. + +/*--- +description: > + In the presence of the "use strict" directive, functions declared as + methods obey "strict" ThisMode semantics. +es6id: 14.3.8 +flags: [noStrict] +---*/ + +var thisValue = null; +var method = { + method() { + 'use strict'; + thisValue = this; + } +}.method; + +method(); + +assert.sameValue(thisValue, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-length-dflt.js b/js/src/tests/test262/language/expressions/object/method-definition/name-length-dflt.js new file mode 100644 index 0000000000..f437244cc2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-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 = { m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { m(x, y = 42, z) {} }.m; + +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/object/method-definition/name-length.js b/js/src/tests/test262/language/expressions/object/method-definition/name-length.js new file mode 100644 index 0000000000..9889eaaeb8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-length.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. + +/*--- +description: > + Functions declared as methods have a `length` property that describes the + number of formal parameters. +es6id: 14.3.8 +includes: [propertyHelper.js] +---*/ + +var method = { method(a, b, c) {} }.method; + +assert.sameValue(method.length, 3); +verifyNotEnumerable(method, 'length'); +verifyNotWritable(method, 'length'); +verifyConfigurable(method, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-string.js b/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-string.js new file mode 100644 index 0000000000..af0baad594 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-string.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. + +/*--- +description: > + Functions declared as methods are assigned a `name` property according to + the string value of their property name. +es6id: 14.3.8 +includes: [propertyHelper.js] +---*/ + +var method = { method() {} }.method; + +assert.sameValue(method.name, 'method'); +verifyNotEnumerable(method, 'name'); +verifyNotWritable(method, 'name'); +verifyConfigurable(method, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-symbol.js b/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-symbol.js new file mode 100644 index 0000000000..1481109cbc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-name-prop-symbol.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. + +/*--- +description: > + Functions declared as methods are assigned a `name` property according to + the string value of their property name. +es6id: 14.3.8 +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var m = Symbol('method'); +var method = { [m]() {} }[m]; + +assert.sameValue(method.name, '[method]'); +verifyNotEnumerable(method, 'name'); +verifyNotWritable(method, 'name'); +verifyConfigurable(method, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-param-id-yield.js b/js/src/tests/test262/language/expressions/object/method-definition/name-param-id-yield.js new file mode 100644 index 0000000000..6d1304939b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-param-id-yield.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. + +/*--- +description: > + The BindingIdentifier of a SingleNameBinding witihn the FormalParameters of + a non-generator MethodDefinition may be the `yield` keyword. +es6id: 14.3 +flags: [noStrict] +---*/ + +var obj = { + method(yield) { + return yield; + } +}; + + +assert.sameValue(obj.method('arg'), 'arg'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-param-init-yield.js b/js/src/tests/test262/language/expressions/object/method-definition/name-param-init-yield.js new file mode 100644 index 0000000000..bb20602dc8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-param-init-yield.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + When the `yield` keyword occurs within the Initializer of a + SingleNameBinding within the FormalParameters of a non-generator + MethodDefinition, it behaves as an Identifier. +es6id: 14.3 +flags: [noStrict] +---*/ + +var yield = 'default'; +var obj = { + method(x = yield) { + return x; + } +}; + + +assert.sameValue(obj.method(), 'default'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-param-redecl.js b/js/src/tests/test262/language/expressions/object/method-definition/name-param-redecl.js new file mode 100644 index 0000000000..682d63d80b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-param-redecl.js @@ -0,0 +1,22 @@ +// |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. + +/*--- +description: > + It is a Syntax Error if any element of the BoundNames of + StrictFormalParameters also occurs in the LexicallyDeclaredNames of + FunctionBody. +es6id: 14.3.1 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + method(param) { + let param; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-params.js b/js/src/tests/test262/language/expressions/object/method-definition/name-params.js new file mode 100644 index 0000000000..ed2ae90225 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-params.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions declared as methods honor their declared formal parameters. +es6id: 14.3.8 +---*/ + +var value1 = {}; +var value2 = {}; +var value3 = {}; +var arg1, arg2, arg3; +var obj = { + method(a, b, c) { + arg1 = a; + arg2 = b; + arg3 = c; + } +}; + +obj.method(value1, value2, value3); + +assert.sameValue(arg1, value1); +assert.sameValue(arg2, value2); +assert.sameValue(arg3, value3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-eval-error.js b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-eval-error.js new file mode 100644 index 0000000000..4db4f964cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-eval-error.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. + +/*--- +description: > + Errors thrown during method definition are forwarded to the runtime. +es6id: 14.3.8 +---*/ + +assert.throws(Test262Error, function() { + ({ + [(function() { throw new Test262Error(); }())]() {} + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-expr.js b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-expr.js new file mode 100644 index 0000000000..2ed775db5a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-expr.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. + +/*--- +description: > + When the `yield` keyword occurs within the PropertyName of a + non-generator MethodDefinition within a generator function, it behaves as a + YieldExpression. +es6id: 14.3 +features: [generators] +flags: [noStrict] +---*/ + +var obj = null; +var yield = 'propNameViaIdentifier'; +var iter = (function*() { + obj = { + [yield]() {} + }; +})(); + +iter.next(); + +assert.sameValue(obj, null); + +iter.next('propNameViaExpression'); + +assert( + !Object.prototype.hasOwnProperty.call(obj, 'propNameViaIdentifier'), + "The property name is not taken from the 'yield' variable" +); +assert( + Object.prototype.hasOwnProperty.call(obj, 'propNameViaExpression'), + "The property name is taken from the yield expression" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-id.js b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-id.js new file mode 100644 index 0000000000..91c6f2a265 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-prop-name-yield-id.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + When the `yield` keyword occurs within the PropertyName of a + non-generator MethodDefinition outside of a generator function, it behaves + as an Identifier. +es6id: 14.3 +flags: [noStrict] +---*/ + +var yield = 'propName'; +var obj = { + [yield]() {} +}; + +assert( + Object.prototype.hasOwnProperty.call(obj, 'propName'), + "The property name is taken from the 'yield' variable" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-property-desc.js b/js/src/tests/test262/language/expressions/object/method-definition/name-property-desc.js new file mode 100644 index 0000000000..2db539d5a8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-property-desc.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. + +/*--- +description: > + Functions declared as methods are defined as enumerable, writable, + configurable properties on the initialized object. +es6id: 14.3.8 +includes: [propertyHelper.js] +---*/ + +var obj = { method() {} }; + +verifyEnumerable(obj, 'method'); +verifyWritable(obj, 'method'); +verifyConfigurable(obj, 'method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-prototype-prop.js b/js/src/tests/test262/language/expressions/object/method-definition/name-prototype-prop.js new file mode 100644 index 0000000000..2720007c12 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-prototype-prop.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. + +/*--- +description: > + Functions declared as methods do not define a `prototype` property. +es6id: 14.3.9 +---*/ + +var method = { method() {} }.method; + +assert( + !Object.prototype.hasOwnProperty.call(method, 'prototype'), + "Functions declared as methods do not define a 'prototype' property" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-prototype.js b/js/src/tests/test262/language/expressions/object/method-definition/name-prototype.js new file mode 100644 index 0000000000..1c3b99ca6b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-prototype.js @@ -0,0 +1,13 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + The prototype of functions declared as methods is the Function prototype. +es6id: 14.3.8 +---*/ + +var obj = { method() {} }; +assert.sameValue(Object.getPrototypeOf(obj.method), Function.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-body.js b/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-body.js new file mode 100644 index 0000000000..0755d80330 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-body.js @@ -0,0 +1,20 @@ +// |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. + +/*--- +description: > + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. +esid: sec-object-initializer-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + method() { + super(); + } +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-param.js b/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-param.js new file mode 100644 index 0000000000..6607a16dfb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-super-call-param.js @@ -0,0 +1,18 @@ +// |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. + +/*--- +description: > + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. +esid: sec-object-initializer-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({ + method(param = super()) {} +}); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-body.js b/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-body.js new file mode 100644 index 0000000000..1f8f302c2e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-body.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. + +/*--- +description: > + The HomeObject of Functions declared as methods is the Object prototype. +es6id: 14.3.8 +features: [super] +---*/ + +var obj = { + method() { + return super.toString; + } +}; + +obj.toString = null; + +assert.sameValue(obj.method(), Object.prototype.toString); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-param.js b/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-param.js new file mode 100644 index 0000000000..d46612b028 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/name-super-prop-param.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. + +/*--- +description: > + The HomeObject of Functions declared as methods is the Object prototype. +es6id: 14.3.8 +features: [super] +---*/ + +var obj = { + method(x = super.toString) { + return x; + } +}; + +obj.toString = null; + +assert.sameValue(obj.method(), Object.prototype.toString); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/object-method-returns-promise.js b/js/src/tests/test262/language/expressions/object/method-definition/object-method-returns-promise.js new file mode 100644 index 0000000000..9a57e2ddf0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/object-method-returns-promise.js @@ -0,0 +1,18 @@ +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson <brian.terlson@microsoft.com> +esid: pending +description: > + Async function method definitions return promises +features: [async-functions] +---*/ +var obj = { + async method() {} +} +var p = obj.method(); +assert(p instanceof Promise, "async functions return promise instances"); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js new file mode 100644 index 0000000000..4147026935 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js @@ -0,0 +1,90 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +obj.method().next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js new file mode 100644 index 0000000000..1c3b6d6732 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, 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 obj = { + *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +obj.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js new file mode 100644 index 0000000000..8299b33331 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js @@ -0,0 +1,87 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +obj.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js new file mode 100644 index 0000000000..cb1d1490ec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 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 obj = { + method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +obj.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js new file mode 100644 index 0000000000..d0cba3fac1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body (async method). +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, async-functions, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + async #m() {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn.js new file mode 100644 index 0000000000..d49334f37f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-fn.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name + (async method). +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, async-functions] +---*/ + +$DONOTEVALUATE(); + +var o = { + async #m() {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js new file mode 100644 index 0000000000..041c4be37a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body. (async generator) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, async-iteration, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + async * #m() {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen.js new file mode 100644 index 0000000000..ff4c600266 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-async-gen.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name. + (async generator) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, async-iteration] +---*/ + +$DONOTEVALUATE(); + +var o = { + async * #m() {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js new file mode 100644 index 0000000000..55f9506956 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body. (generator) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, generators, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + * #m() {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen.js new file mode 100644 index 0000000000..e16fd6b282 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-gen.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name. + (generator) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, generators] +---*/ + +$DONOTEVALUATE(); + +var o = { + * #m() {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method-inside-class.js new file mode 100644 index 0000000000..e3cc1c6d78 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body. (getter method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + get #m() {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method.js new file mode 100644 index 0000000000..afe43213b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-get-method.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name. + (getter method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private] +---*/ + +$DONOTEVALUATE(); + +var o = { + get #m() {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method-inside-class.js new file mode 100644 index 0000000000..ec3ee177bf --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body. (ordinary method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + #m() {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method.js new file mode 100644 index 0000000000..093f1996d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-method.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name. + (ordinary method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private] +---*/ + +$DONOTEVALUATE(); + +var o = { + #m() {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method-inside-class.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method-inside-class.js new file mode 100644 index 0000000000..73fac9e29f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method-inside-class.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name even + inside a class body. (getter method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private, class, class-fields-public] +---*/ + +$DONOTEVALUATE(); + +class C { + field = { + set #m(x) {} + } +} diff --git a/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method.js b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method.js new file mode 100644 index 0000000000..a60cb19552 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/private-name-early-error-set-method.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions-static-semantics-early-errors +description: > + Throws an early SyntaxError if a method definition has a private name. + (getter method) +info: | + Static Semantics: Early Errors + + PropertyDefinition : MethodDefinition + It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty. +negative: + phase: parse + type: SyntaxError +features: [class-methods-private] +---*/ + +$DONOTEVALUATE(); + +var o = { + set #m(x) {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js b/js/src/tests/test262/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js new file mode 100644 index 0000000000..ccabe8543c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js @@ -0,0 +1,24 @@ +// |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-method-definitions-static-semantics-early-errors +description: > + A SyntaxError is thrown if a setter method contains a non-simple parameter list and a UseStrict directive. +info: | + Static Semantics: Early Errors + + It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of PropertySetParameterList is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var o = { + set m(a = 0) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/shell.js b/js/src/tests/test262/language/expressions/object/method-definition/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/shell.js diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-accessor.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-accessor.js new file mode 100644 index 0000000000..3d8d09771f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-accessor.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within the body of accessor methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + ({set accessor(await) {}}); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-generator.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-generator.js new file mode 100644 index 0000000000..2287ef2441 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-generator.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within the parameter list of generator methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + ({*method(await) {}}); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-normal.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-normal.js new file mode 100644 index 0000000000..ca0d1894b1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-binding-normal.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within the parameter list of methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + ({method(await) {}}); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-accessor.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-accessor.js new file mode 100644 index 0000000000..d050188cfe --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-accessor.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within accessor methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +var await = 0; +var fromParam, fromBody; + +class C { + static { + ({ + set accessor(x = fromParam = await) { + fromBody = await; + } + }).accessor = undefined; + } +} + +assert.sameValue(fromParam, 0, 'from parameter'); +assert.sameValue(fromBody, 0, 'from body'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-generator.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-generator.js new file mode 100644 index 0000000000..0732cd0648 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-generator.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within generator methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +var await = 0; +var fromParam, fromBody; + +class C { + static { + ({ + *method(x = fromParam = await) { + fromBody = await; + } + }).method().next(); + } +} + +assert.sameValue(fromParam, 0, 'from parameter'); +assert.sameValue(fromBody, 0, 'from body'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-normal.js b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-normal.js new file mode 100644 index 0000000000..0a96a248cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/static-init-await-reference-normal.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within methods +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +var await = 0; +var fromParam, fromBody; + +class C { + static { + ({ + method(x = fromParam = await) { + fromBody = await; + } + }).method(); + } +} + +assert.sameValue(fromParam, 0, 'from parameter'); +assert.sameValue(fromBody, 0, 'from body'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/use-strict-with-non-simple-param.js b/js/src/tests/test262/language/expressions/object/method-definition/use-strict-with-non-simple-param.js new file mode 100644 index 0000000000..c97c9c7d01 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/use-strict-with-non-simple-param.js @@ -0,0 +1,24 @@ +// |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-method-definitions-static-semantics-early-errors +description: > + A SyntaxError is thrown if a method contains a non-simple parameter list and a UseStrict directive. +info: | + Static Semantics: Early Errors + + It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of StrictFormalParameters is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var o = { + m(a = 0) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-with-rhs.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-with-rhs.js new file mode 100644 index 0000000000..0e962e5931 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-with-rhs.js @@ -0,0 +1,120 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +var obj = { + *g1() { (yield 1) }, + *g2() { [yield 1] }, + *g3() { {yield 1} }, + *g4() { yield 1, yield 2; }, + *g5() { (yield 1) ? yield 2 : yield 3; } +}; + +iter = obj.g1(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within grouping operator: result `value`'); +assert.sameValue( + result.done, false, 'Within grouping operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following grouping operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following grouping operator: result `done` flag' +); + +iter = obj.g2(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within array literal: result `value`'); +assert.sameValue( + result.done, false, 'Within array literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following array literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following array literal: result `done` flag' +); + +iter = obj.g3(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within object literal: result `value`'); +assert.sameValue( + result.done, false, 'Within object literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following object literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following object literal: result `done` flag' +); + +iter = obj.g4(); +result = iter.next(); +assert.sameValue( + result.value, 1, 'First expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'First expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, 2, 'Second expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'Second expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following comma expression: result `value`' +); +assert.sameValue( + result.done, true, 'Following comma expression: result `done` flag' +); + +iter = obj.g5(); +result = iter.next(); +assert.sameValue( + result.value, + 1, + 'Conditional expression in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Conditional expression in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + 3, + 'Branch in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Branch in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following conditional operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following conditional operator: result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-without-rhs.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-without-rhs.js new file mode 100644 index 0000000000..21fe83f4e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-expression-without-rhs.js @@ -0,0 +1,130 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +var obj = { + *g1() { (yield) }, + *g2() { [yield] }, + *g3() { {yield} }, + *g4() { yield, yield; }, + *g5() { (yield) ? yield : yield; } +}; + +iter = obj.g1(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within grouping operator: result `value`' +); +assert.sameValue( + result.done, false, 'Within grouping operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following grouping operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following grouping operator: result `done` flag' +); + +iter = obj.g2(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within array literal: result `value`' +); +assert.sameValue( + result.done, false, 'Within array literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following array literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following array literal: result `done` flag' +); + +iter = obj.g3(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within object literal: result `value`' +); +assert.sameValue( + result.done, false, 'Within object literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following object literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following object literal: result `done` flag' +); + +iter = obj.g4(); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'First expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'First expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Second expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'Second expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following comma expression: result `value`' +); +assert.sameValue( + result.done, true, 'Following comma expression: result `done` flag' +); + +iter = obj.g5(); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Conditional expression in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Conditional expression in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Branch in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Branch in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following conditional operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following conditional operator: result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-function-expression-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-function-expression-binding-identifier.js new file mode 100644 index 0000000000..e82150bb98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-function-expression-binding-identifier.js @@ -0,0 +1,25 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as the binding identifier of a function expression + within generator bodies. + features: [generators] + es6id: 14.1 + flags: [noStrict] +---*/ + +var result; +var obj = { + *g() { + (function yield() {}); + } +}; + +result = obj.g().next(); + +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-generator-method-binding-identifier.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-generator-method-binding-identifier.js new file mode 100644 index 0000000000..f28e85f989 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-generator-method-binding-identifier.js @@ -0,0 +1,30 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid BindingIdentifier for GeneratorMethods + features: [generators] + es6id: 12.1.1 +---*/ + +var iter, result; +var obj = { + *yield() { (yield 3) + (yield 4); } +} + +iter = obj.yield(); + +result = iter.next(); +assert.sameValue(result.value, 3, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, 4, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Third result `value`'); +assert.sameValue(result.done, true, 'Third result `done` flag');; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-identifier-in-nested-function.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-identifier-in-nested-function.js new file mode 100644 index 0000000000..909d2d0a85 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-identifier-in-nested-function.js @@ -0,0 +1,26 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is not a reserved keyword within normal function bodies declared + within generator function bodies. + features: [generators] + es6id: 12.1.1 + flags: [noStrict] +---*/ + +var result; +var obj = { + *g() { + function h() { + yield = 1; + } + } +}; + +result = obj.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-literal-property-name.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-literal-property-name.js new file mode 100644 index 0000000000..8b1adeb65e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-literal-property-name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + features: [generators] + es6id: 12.1.1 +---*/ + +var result; +var obj = { + *g() { + ({ get yield() { return 1 } }); + } +}; + +result = obj.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-logical-or-expression.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-logical-or-expression.js new file mode 100644 index 0000000000..258bbc1d04 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-logical-or-expression.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions are not LogicalOrExpressions. + features: [generators] + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *g() { + yield ? yield : yield; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-parameter.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-parameter.js new file mode 100644 index 0000000000..46bcb0620f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-parameter.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within generator function bodies and may + not be used as the binding identifier of a parameter. + features: [generators] + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *g(yield) {} +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-property-name.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-property-name.js new file mode 100644 index 0000000000..0fa724954b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-property-name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + features: [generators] + es6id: 12.1.1 +---*/ + +var result; +var obj = { + *g() { + ({ yield: 1 }); + } +}; + +result = obj.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-statement.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-statement.js new file mode 100644 index 0000000000..88f327147f --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-statement.js @@ -0,0 +1,49 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid statement within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +var obj = { + *g1() { yield; }, + *g2() { yield 1; } +}; + +iter = obj.g1(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Without right-hand-side: first result `value`' +); +assert.sameValue( + result.done, false, 'Without right-hand-side: first result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Without right-hand-side: second result `value`' +); +assert.sameValue( + result.done, true, 'Without right-hand-eside: second result `done` flag' +); + +iter = obj.g2(); +result = iter.next(); +assert.sameValue( + result.value, 1, 'With right-hand-side: first result `value`' +); +assert.sameValue( + result.done, false, 'With right-hand-side: first result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'With right-hand-side: second result `value`' +); +assert.sameValue( + result.done, true, 'With right-hand-eside: second result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-as-yield-operand.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-yield-operand.js new file mode 100644 index 0000000000..0beb76f49b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-as-yield-operand.js @@ -0,0 +1,33 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions may be used as the right-hand-side of other `yield` + expressions. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +var obj = { + *g() { + yield yield 1; + } +}; + +iter = obj.g(); + +result = iter.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Third result `value`'); +assert.sameValue(result.done, true, 'Thid result `done` flag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-newline.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-newline.js new file mode 100644 index 0000000000..69d234cfec --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-newline.js @@ -0,0 +1,29 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Newlines terminate `yield` expressions. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +var obj = { + *g() { + yield + 1 + } +}; + +iter = obj.g(); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Second result `value`'); +assert.sameValue(result.done, true, 'Second result `done` flag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-return.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-return.js new file mode 100644 index 0000000000..bea909f6e0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-return.js @@ -0,0 +1,22 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + Generator can be declared with GeneratorMethod syntax +features: [generators] +es6id: 14.4 +author: Sam Mikes +description: can declare generator methods +---*/ + +var obj = { + *foo(a) { yield a+1; return; } +}; + +var g = obj.foo(3); + +assert.sameValue(g.next().value, 4); +assert.sameValue(g.next().done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-star-after-newline.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-star-after-newline.js new file mode 100644 index 0000000000..133314c379 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-star-after-newline.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + A newline may not precede the `*` token in a `yield` expression. + features: [generators] + es6id: 14.4 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *g() { + yield + * 1 + } +}; diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-star-before-newline.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-star-before-newline.js new file mode 100644 index 0000000000..5b281bb95d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-star-before-newline.js @@ -0,0 +1,24 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + The right-hand side of a `yield *` expression may appear on a new line. + features: [generators] + es6id: 14.4 +---*/ + +var result; +var obj = { + *g() { + yield * + g2() + } +}; +var g2 = function*() {}; + +result = obj.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/method-definition/yield-weak-binding.js b/js/src/tests/test262/language/expressions/object/method-definition/yield-weak-binding.js new file mode 100644 index 0000000000..4566975196 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method-definition/yield-weak-binding.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions bind weakly + features: [generators] + es6id: 14.4 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var obj = { + *g() { yield 3 + yield 4; } +}; diff --git a/js/src/tests/test262/language/expressions/object/method.js b/js/src/tests/test262/language/expressions/object/method.js new file mode 100644 index 0000000000..6d3e51a9d1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/method.js @@ -0,0 +1,30 @@ +// 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.2.5 +description: > + super method calls in object literal method +---*/ +var proto = { + method(x) { + return 'proto' + x; + } +}; + +var object = { + method(x) { + return super.method(x); + } +}; + +Object.setPrototypeOf(object, proto); + +assert.sameValue(object.method(42), 'proto42', "`object.method(42)` returns `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue(proto.method(42), 'proto42', "`proto.method(42)` returns `'proto42'`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue( + Object.getPrototypeOf(object).method(42), + 'proto42', + "`Object.getPrototypeOf(object).method(42)` returns `'proto42'`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/not-defined.js b/js/src/tests/test262/language/expressions/object/not-defined.js new file mode 100644 index 0000000000..b8a7d4d33c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/not-defined.js @@ -0,0 +1,13 @@ +// 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.2.5 +description: > + Throws when IdentifierReference is undefined +---*/ + +assert.throws(ReferenceError, function() { + var o = {notDefined}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/object-spread-proxy-get-not-called-on-dontenum-keys.js b/js/src/tests/test262/language/expressions/object/object-spread-proxy-get-not-called-on-dontenum-keys.js new file mode 100644 index 0000000000..411723dde5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/object-spread-proxy-get-not-called-on-dontenum-keys.js @@ -0,0 +1,73 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-propertydefinitionevaluation +description: > + Proxy's "get" trap is not invoked for non-enumerable keys. +info: | + PropertyDefinition : ... AssignmentExpression + + [...] + 3. Let excludedNames be a new empty List. + 4. Return ? CopyDataProperties(object, fromValue, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + [...] + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + ii. If desc is not undefined and desc.[[Enumerable]] is true, then + 1. Let propValue be ? Get(from, nextKey). + 2. Perform ! CreateDataPropertyOrThrow(target, nextKey, propValue). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-spread, Proxy, Symbol] +includes: [compareArray.js, propertyHelper.js] +---*/ + +var VALUE_LITERAL = "VALUE_LITERAL"; +var VALUE_GOPD = "VALUE_GOPD"; +var VALUE_GET = "VALUE_GET"; + +var dontEnumSymbol = Symbol("dont_enum_symbol"); +var enumerableSymbol = Symbol("enumerable_symbol"); + +var dontEnumKeys = [dontEnumSymbol, "dontEnumString", "0"]; +var enumerableKeys = [enumerableSymbol, "enumerableString", "1"]; +var ownKeysResult = [...dontEnumKeys, ...enumerableKeys]; + +var getOwnKeys = []; +var getKeys = []; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + var isEnumerable = enumerableKeys.indexOf(key) !== -1; + return {value: VALUE_GOPD, writable: false, enumerable: isEnumerable, configurable: true}; + }, + get: function(_target, key) { + getKeys.push(key); + return VALUE_GET; + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +var result = {[enumerableSymbol]: VALUE_LITERAL, enumerableString: VALUE_LITERAL, [1]: VALUE_LITERAL, ...proxy}; +assert.compareArray(getOwnKeys, ownKeysResult); +assert.compareArray(getKeys, enumerableKeys); + +verifyProperty(result, enumerableSymbol, {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); +verifyProperty(result, "enumerableString", {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); +verifyProperty(result, "1", {value: VALUE_GET, writable: true, enumerable: true, configurable: true}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/object-spread-proxy-no-excluded-keys.js b/js/src/tests/test262/language/expressions/object/object-spread-proxy-no-excluded-keys.js new file mode 100644 index 0000000000..2f65a9996b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/object-spread-proxy-no-excluded-keys.js @@ -0,0 +1,49 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-propertydefinitionevaluation +description: > + Proxy's "getOwnPropertyDescriptor" trap is invoked for all keys. +info: | + PropertyDefinition : ... AssignmentExpression + + [...] + 3. Let excludedNames be a new empty List. + 4. Return ? CopyDataProperties(object, fromValue, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + [...] + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-spread, Proxy, Symbol] +includes: [compareArray.js] +---*/ + +var sym = Symbol(); +var getOwnKeys = []; +var ownKeysResult = [sym, "foo", "0"]; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +({[sym]: 0, foo: 0, [0]: 0, ...proxy}); +assert.compareArray(getOwnKeys, ownKeysResult); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/object-spread-proxy-ownkeys-returned-keys-order.js b/js/src/tests/test262/language/expressions/object/object-spread-proxy-ownkeys-returned-keys-order.js new file mode 100644 index 0000000000..5e70ce39b5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/object-spread-proxy-ownkeys-returned-keys-order.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-propertydefinitionevaluation +description: > + Proxy keys are iterated in order they were provided by "ownKeys" trap. +info: | + PropertyDefinition : ... AssignmentExpression + + [...] + 3. Let excludedNames be a new empty List. + 4. Return ? CopyDataProperties(object, fromValue, excludedNames). + + CopyDataProperties ( target, source, excludedItems ) + + [...] + 5. Let keys be ? from.[[OwnPropertyKeys]](). + 6. For each element nextKey of keys in List order, do + [...] + c. If excluded is false, then + i. Let desc be ? from.[[GetOwnProperty]](nextKey). + + [[OwnPropertyKeys]] ( ) + + [...] + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + [...] + 23. Return trapResult. +features: [object-spread, Proxy, Symbol] +includes: [compareArray.js] +---*/ + +var getOwnKeys = []; +var ownKeysResult = [Symbol(), "foo", "0"]; +var proxy = new Proxy({}, { + getOwnPropertyDescriptor: function(_target, key) { + getOwnKeys.push(key); + }, + ownKeys: function() { + return ownKeysResult; + }, +}); + +({...proxy}); +assert.compareArray(getOwnKeys, ownKeysResult); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error-2.js b/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error-2.js new file mode 100644 index 0000000000..5cc7cb73e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error-2.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: 12.2.5.9 +description: > + Errors thrown during IdentifierReference evaluation are forwarded to the + runtime. +flags: [noStrict] +features: [Proxy] +---*/ + +var p = new Proxy({}, { + has: function () { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + with (p) { + ({attr}); + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error.js b/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error.js new file mode 100644 index 0000000000..33763ffce5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-id-eval-error.js @@ -0,0 +1,23 @@ +// 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.2.5.9 +description: > + Errors thrown during IdentifierReference evaluation are forwarded to the + runtime. +flags: [noStrict] +features: [Symbol, Symbol.unscopables] +---*/ + +var obj = { + attr: null, + get [Symbol.unscopables]() { throw new Test262Error(); } +}; + +assert.throws(Test262Error, function() { + with (obj) { + ({ attr }); + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-id-get-error.js b/js/src/tests/test262/language/expressions/object/prop-def-id-get-error.js new file mode 100644 index 0000000000..0424ba0ee2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-id-get-error.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: 12.2.5.9 +description: > + Errors thrown during IdentifierReference value retrieval are forwarded to + the runtime. +---*/ + +assert.throws(ReferenceError, function() { + ({ unresolvable }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-id-valid.js b/js/src/tests/test262/language/expressions/object/prop-def-id-valid.js new file mode 100644 index 0000000000..dd23a99854 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-id-valid.js @@ -0,0 +1,23 @@ +// 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.2.5.9 +description: > + When a valid IdentifierReference appears in an object initializer, a new + data property is created. The property name is the string value of the + identifier, the property value is the value of the identifier, and the + property is enumerable, writable, and configurable. +includes: [propertyHelper.js] +---*/ + +var attr = 23; +var obj; + +obj = { attr }; + +assert.sameValue(obj.attr, 23); +verifyEnumerable(obj, 'attr'); +verifyWritable(obj, 'attr'); +verifyConfigurable(obj, 'attr'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-invalid-async-prefix.js b/js/src/tests/test262/language/expressions/object/prop-def-invalid-async-prefix.js new file mode 100644 index 0000000000..b5c846b643 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-invalid-async-prefix.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + async is not a valid prefix of an identifier reference +esid: sec-object-initializer +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition + + MethodDefinition: + PropertyName ( UniqueFormalParameters ) { FunctionBody } + AsyncMethod + + AsyncMethod: + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({async async}); diff --git a/js/src/tests/test262/language/expressions/object/prop-def-invalid-star-prefix.js b/js/src/tests/test262/language/expressions/object/prop-def-invalid-star-prefix.js new file mode 100644 index 0000000000..cacc6b1ec4 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-def-invalid-star-prefix.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Tiancheng "Timothy" Gu. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + * is not a valid prefix of an identifier reference +esid: sec-object-initializer +info: | + PropertyDefinition: + IdentifierReference + CoverInitializedName + PropertyName : AssignmentExpression + MethodDefinition +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +({* foo}); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-data-data.js b/js/src/tests/test262/language/expressions/object/prop-dup-data-data.js new file mode 100644 index 0000000000..ae346f3b65 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-data-data.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Refer 11.1.5; + The production + PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment + 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + a. This production is contained in strict code and IsDataDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true +es5id: 11.1.5_4-4-a-2 +description: > + Object literal - Duplicate data property name allowed if not in + strict mode +---*/ + +void { + foo: 0, + foo: 1 +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-data-set.js b/js/src/tests/test262/language/expressions/object/prop-dup-data-set.js new file mode 100644 index 0000000000..a22a4f5b51 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-data-set.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-b-2 +description: > + Object literal - No SyntaxError if a data property definition is + followed by set accessor definition with the same name +---*/ + +void { + foo: 1, + set foo(x) {} +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-get-data.js b/js/src/tests/test262/language/expressions/object/prop-dup-get-data.js new file mode 100644 index 0000000000..4ce5ca25f5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-get-data.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-c-1 +description: > + Object literal - No SyntaxError if a get accessor property definition + is followed by a data property definition with the same name +---*/ + +void { + get foo() {}, + foo: 1 +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-get-get.js b/js/src/tests/test262/language/expressions/object/prop-dup-get-get.js new file mode 100644 index 0000000000..a456efec26 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-get-get.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-d-1 +description: Object literal - No SyntaxError for duplicate property name (get,get) +---*/ + +void { + get foo() {}, + get foo() {} +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-get-set-get.js b/js/src/tests/test262/language/expressions/object/prop-dup-get-set-get.js new file mode 100644 index 0000000000..a9227db162 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-get-set-get.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-d-3 +description: > + Object literal - No SyntaxError for duplicate property name + (get,set,get) +---*/ + +void { + get foo() {}, + set foo(arg) {}, + get foo() {} +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-set-data.js b/js/src/tests/test262/language/expressions/object/prop-dup-set-data.js new file mode 100644 index 0000000000..9c07baa686 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-set-data.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-c-2 +description: > + Object literal - No SyntaxError if a set accessor property definition + is followed by a data property definition with the same name +---*/ + +void { + set foo(x) {}, + foo: 1 +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-set-get-set.js b/js/src/tests/test262/language/expressions/object/prop-dup-set-get-set.js new file mode 100644 index 0000000000..56fa5e867b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-set-get-set.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-d-4 +description: > + Object literal - No SyntaxError for duplicate property name + (set,get,set) +---*/ + +void { + set foo(arg) {}, + get foo() {}, + set foo(arg1) {} +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/prop-dup-set-set.js b/js/src/tests/test262/language/expressions/object/prop-dup-set-set.js new file mode 100644 index 0000000000..c8e482f4dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/prop-dup-set-set.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.1.5_4-4-d-2 +description: Object literal - No SyntaxError for duplicate property name (set,set) +---*/ + +void { + set foo(arg) {}, + set foo(arg1) {} +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/properties-names-eval-arguments.js b/js/src/tests/test262/language/expressions/object/properties-names-eval-arguments.js new file mode 100644 index 0000000000..8f9ed68921 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/properties-names-eval-arguments.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: 12.2.5 +description: > + property names `eval` and `arguments` +---*/ +var o = { + eval() { + return 1; + }, + arguments() { + return 2; + }, +}; + +assert.sameValue(o.eval(), 1, "`o.eval()` returns `1`"); +assert.sameValue(o.arguments(), 2, "`o.arguments()` returns `2`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/property-name-yield.js b/js/src/tests/test262/language/expressions/object/property-name-yield.js new file mode 100644 index 0000000000..f8ab2ced3a --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/property-name-yield.js @@ -0,0 +1,12 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal. + es6id: 12.1.1 +---*/ + +({ yield: 1 }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-body-lex-distinct.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-body-lex-distinct.js new file mode 100644 index 0000000000..df8d77f575 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-body-lex-distinct.js @@ -0,0 +1,58 @@ +// 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: [generators, let] +---*/ + +var o = { + *m() { + let x; + eval('var x;'); + } +}; +var iter = o.m(); + +assert.throws(SyntaxError, function() { + iter.next(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-close.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-close.js new file mode 100644 index 0000000000..afb0b98f30 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-close.js @@ -0,0 +1,35 @@ +// 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] +features: [generators] +---*/ + +var x = 'outside'; +var probe1, probe2, probeBody; + +({ + *m( + _ = (eval('var x = "inside";'), probe1 = function() { return x; }), + __ = probe2 = function() { return x; } + ) { + probeBody = function() { return x; }; + } +}.m().next()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-open.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-open.js new file mode 100644 index 0000000000..7157eaf78b --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-elem-var-open.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] +features: [generators] +---*/ + +var x = 'outside'; +var probe1, probe2; + +({ + *m( + _ = probe1 = function() { return x; }, + __ = (eval('var x = "inside";'), probe2 = function() { return x; }) + ) {} +}.m().next()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-close.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-close.js new file mode 100644 index 0000000000..c357b326af --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-close.js @@ -0,0 +1,33 @@ +// 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] +features: [generators] +---*/ + +var x = 'outside'; +var probeParam, probeBody; + +({ + *m( + ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })] + ) { + probeBody = function() { return x; } + } +}.m().next()); + +assert.sameValue(probeParam(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-open.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-open.js new file mode 100644 index 0000000000..b686c1b753 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-param-rest-elem-var-open.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] +features: [generators] +---*/ + +var x = 'outside'; +var probe1, probe2; + +({ + *m( + _ = probe1 = function() { return x; }, + ...[__ = (eval('var x = "inside";'), probe2 = function() { return x; })] + ) {} +}.m().next()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-close.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..9536c96b11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-close.js @@ -0,0 +1,39 @@ +// 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. + [...] +features: [generators] +---*/ + +var probe; + +({ + // A parameter expression is necessary to trigger the creation of the scope + // under test. + *m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +}.m().next()); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-open.js b/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..7bc1851085 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-gen-meth-paramsbody-var-open.js @@ -0,0 +1,37 @@ +// 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. + [...] +features: [generators] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +({ + *m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +}.m().next()); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-getter-body-lex-distinc.js b/js/src/tests/test262/language/expressions/object/scope-getter-body-lex-distinc.js new file mode 100644 index 0000000000..8b5874b158 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-getter-body-lex-distinc.js @@ -0,0 +1,57 @@ +// 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 o = { + get a() { + let x; + eval('var x;'); + } +}; + +assert.throws(SyntaxError, function() { + o.a; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-body-lex-distinct.js b/js/src/tests/test262/language/expressions/object/scope-meth-body-lex-distinct.js new file mode 100644 index 0000000000..5cc48775d6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-body-lex-distinct.js @@ -0,0 +1,55 @@ +// 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 m = { + m() { + let x; + eval('var x;'); + } +}.m; + +assert.throws(SyntaxError, m); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-close.js b/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-close.js new file mode 100644 index 0000000000..6d8c2e60ff --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-close.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: > + 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; + +({ + m( + _ = (eval('var x = "inside";'), probe1 = function() { return x; }), + __ = probe2 = function() { return x; } + ) { + probeBody = function() { return x; }; + } +}.m()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-open.js b/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-open.js new file mode 100644 index 0000000000..d51f1bfd16 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-param-elem-var-open.js @@ -0,0 +1,31 @@ +// 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; + +({ + m( + _ = probe1 = function() { return x; }, + __ = (eval('var x = "inside";'), probe2 = function() { return x; }) + ) {} +}.m()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-elem-var-close.js b/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-elem-var-close.js new file mode 100644 index 0000000000..62aeae3b3c --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-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 probeParam, probeBody; + +({ + m( + ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })] + ) { + probeBody = function() { return x; } + } +}.m()); + +assert.sameValue(probeParam(), 'inside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-elem-var-open.js b/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-elem-var-open.js new file mode 100644 index 0000000000..3e4d9c3fe8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-param-rest-elem-var-open.js @@ -0,0 +1,31 @@ +// 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; + +({ + m( + _ = probe1 = function() { return x; }, + ...[__ = (eval('var x = "inside";'), probe2 = function() { return x; })] + ) {} +}.m()); + +assert.sameValue(probe1(), 'inside'); +assert.sameValue(probe2(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-close.js b/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..1a2a47ef46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-close.js @@ -0,0 +1,38 @@ +// 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. + m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +}.m()); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-open.js b/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..1cc395b18e --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-meth-paramsbody-var-open.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: > + 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; + +({ + m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +}.m()); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-setter-body-lex-distinc.js b/js/src/tests/test262/language/expressions/object/scope-setter-body-lex-distinc.js new file mode 100644 index 0000000000..3318fac03d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-setter-body-lex-distinc.js @@ -0,0 +1,57 @@ +// 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 o = { + set a(_) { + let x; + eval('var x;'); + } +}; + +assert.throws(SyntaxError, function() { + o.a = null; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-close.js b/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-close.js new file mode 100644 index 0000000000..3f18937429 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-close.js @@ -0,0 +1,38 @@ +// 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. + set a(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +}.a = null); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-open.js b/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-open.js new file mode 100644 index 0000000000..6919f07aea --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/scope-setter-paramsbody-var-open.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: > + 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; + +({ + set a(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +}.a = undefined); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/setter-body-strict-inside.js b/js/src/tests/test262/language/expressions/object/setter-body-strict-inside.js new file mode 100644 index 0000000000..ad0341354d --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-body-strict-inside.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5_7-2-2-s +description: > + Strict Mode - SyntaxError is thrown when an assignment to a + reserved word is made in a strict FunctionBody of a + PropertyAssignment +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(value) { + "use strict"; + public = 42; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-body-strict-outside-strict.js b/js/src/tests/test262/language/expressions/object/setter-body-strict-outside-strict.js new file mode 100644 index 0000000000..a3b0ac3989 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-body-strict-outside-strict.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5_7-2-1-s +description: > + Strict Mode - SyntaxError is thrown when an assignment to a + reserved word is contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(value) { + public = 42; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-length-dflt.js b/js/src/tests/test262/language/expressions/object/setter-length-dflt.js new file mode 100644 index 0000000000..bfead82f90 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-length-dflt.js @@ -0,0 +1,41 @@ +// 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 set = Object.getOwnPropertyDescriptor({ set m(x = 42) {} }, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-inside.js b/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-inside.js new file mode 100644 index 0000000000..2c6e159ab6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-inside.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5-4-s +description: > + Strict Mode - SyntaxError is thrown when 'arguments' occurs as + the Identifier in a PropertySetParameterList of a + PropertyAssignment if its FunctionBody is strict code +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(arguments) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-outside-strict.js b/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-outside-strict.js new file mode 100644 index 0000000000..b1bfb8c519 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-param-arguments-strict-outside-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5-2-s +description: > + Strict Mode - SyntaxError is thrown when 'arguments' occurs as the + Identifier in a PropertySetParameterList of a PropertyAssignment + that is contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(arguments) {} +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-inside.js b/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-inside.js new file mode 100644 index 0000000000..b3c3db1caa --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-inside.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5-3-s +description: > + Strict Mode - SyntaxError is thrown when 'evals' occurs as the + Identifier in a PropertySetParameterList of a PropertyAssignment + if its FunctionBody is strict code +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(eval) { + "use strict"; + } +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-outside-strict.js b/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-outside-strict.js new file mode 100644 index 0000000000..c92405d8b5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-param-eval-strict-outside-strict.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es5id: 11.1.5-1-s +description: > + Strict Mode - SyntaxError is thrown when 'eval' occurs as the + Identifier in a PropertySetParameterList of a PropertyAssignment + that is contained in strict code +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +void { + set x(eval) {} +}; diff --git a/js/src/tests/test262/language/expressions/object/setter-prop-desc.js b/js/src/tests/test262/language/expressions/object/setter-prop-desc.js new file mode 100644 index 0000000000..ee77d269bd --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-prop-desc.js @@ -0,0 +1,39 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: Property descriptor of "set" accessor methods +info: | + ObjectLiteral: + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + 3. ReturnIfAbrupt(status). + 4. Return obj. + + 14.3.8 Runtime Semantics: PropertyDefinitionEvaluation + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + [...] + 8. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + [...] +includes: [propertyHelper.js] +---*/ + +var obj = { set m(x) { return x; } }; +var desc = Object.getOwnPropertyDescriptor(obj, 'm'); + +verifyEnumerable(obj, 'm'); +verifyConfigurable(obj, 'm'); +assert.sameValue(desc.value, undefined, '`value` field'); +assert.sameValue(desc.get, undefined, '`get` field'); +assert.sameValue(typeof desc.set, 'function', 'type of `set` field'); +assert.sameValue(desc.set(436), 436, '`set` function return value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/setter-super-prop.js b/js/src/tests/test262/language/expressions/object/setter-super-prop.js new file mode 100644 index 0000000000..5568a66c62 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/setter-super-prop.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: 12.2.5 +description: > + super method calls in object literal setters +---*/ +var proto = { + _x: 0, + set x(v) { + return this._x = v; + } +}; + +var object = { + set x(v) { + super.x = v; + } +}; + +Object.setPrototypeOf(object, proto); + +assert.sameValue(object.x = 1, 1, "`object.x = 1` is `1`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue(object._x, 1, "The value of `object._x` is `1`, after executing `Object.setPrototypeOf(object, proto);`"); +assert.sameValue( + Object.getPrototypeOf(object)._x, + 0, + "The value of `Object.getPrototypeOf(object)._x` is `0`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/shell.js b/js/src/tests/test262/language/expressions/object/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/shell.js diff --git a/js/src/tests/test262/language/expressions/object/yield-non-strict-access.js b/js/src/tests/test262/language/expressions/object/yield-non-strict-access.js new file mode 100644 index 0000000000..1ce5eb7c75 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/yield-non-strict-access.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: 12.2.5 +description: > + In non-strict mode, yield is a valid Identifier. +flags: [noStrict] +---*/ +var yield = 1; +var object = {yield}; + +assert.sameValue(object.yield, 1, "The value of `object.yield` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/object/yield-non-strict-syntax.js b/js/src/tests/test262/language/expressions/object/yield-non-strict-syntax.js new file mode 100644 index 0000000000..6b21dc2f45 --- /dev/null +++ b/js/src/tests/test262/language/expressions/object/yield-non-strict-syntax.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: 12.2.5 +description: > + In non-strict mode, yield is a valid Identifier. +flags: [noStrict] +---*/ +var yield = 1; +var object = {yield}; + +reportCompare(0, 0); |