diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions/call')
94 files changed, 3653 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_1.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_1.js new file mode 100644 index 0000000000..df9bdcc505 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-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. + +/*--- +es5id: 11.2.3-3_1 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (FunctionDeclaration) +---*/ + + var fooCalled = false; + function foo(){ fooCalled = true; } + + var o = { }; +assert.throws(TypeError, function() { + o.bar( foo() ); + throw new Test262Error("o.bar does not exist!"); +}); +assert.sameValue(fooCalled, true, 'fooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_2.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_2.js new file mode 100644 index 0000000000..1468481a32 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_2.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. + +/*--- +es5id: 11.2.3-3_2 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (FunctionExpression) +---*/ + + var fooCalled = false; + var foo = function (){ fooCalled = true; } + + var o = { }; +assert.throws(TypeError, function() { + o.bar( foo() ); + throw new Test262Error("o.bar does not exist!"); +}); +assert.sameValue(fooCalled, true, 'fooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_3.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_3.js new file mode 100644 index 0000000000..eef2ae8d5d --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_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. + +/*--- +es5id: 11.2.3-3_3 +description: > + Call arguments are not evaluated before the check is made to see + if the object is actually callable (undefined member) +---*/ + + var fooCalled = false; + function foo(){ fooCalled = true; } + + var o = { }; +assert.throws(TypeError, function() { + o.bar.gar( foo() ); + throw new Test262Error("o.bar does not exist!"); +}); +assert.sameValue(fooCalled, false, 'fooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_4.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_4.js new file mode 100644 index 0000000000..7dae3a8724 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.2.3-3_4 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (property) +---*/ + + var fooCalled = false; + function foo(){ fooCalled = true; } + + var o = { }; + Object.defineProperty(o, "bar", {get: function() {this.barGetter = true; return 42;}, + set: function(x) {this.barSetter = true; }}); +assert.throws(TypeError, function() { + o.bar( foo() ); + throw new Test262Error("o.bar does not exist!"); +}); +assert.sameValue(fooCalled, true, 'fooCalled'); +assert.sameValue(o.barGetter, true, 'o.barGetter'); +assert.sameValue(o.barSetter, undefined, 'o.barSetter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_5.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_5.js new file mode 100644 index 0000000000..e985aa7043 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_5.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. + +/*--- +es5id: 11.2.3-3_5 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (eval'ed) +---*/ + + var fooCalled = false; + function foo(){ fooCalled = true; } + + var o = { }; +assert.throws(TypeError, function() { + eval("o.bar( foo() );"); + throw new Test262Error("o.bar does not exist!"); +}); +assert.sameValue(fooCalled, true, 'fooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_6.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_6.js new file mode 100644 index 0000000000..e9899d94b5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_6.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. + +/*--- +es5id: 11.2.3-3_6 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (getter called) +---*/ + + var o = { }; + Object.defineProperty(o, "bar", {get: function() {this.barGetter = true; return 42;}, + set: function(x) {this.barSetter = true; }}); +assert.throws(TypeError, function() { + o.foo( o.bar ); + throw new Test262Error("o.foo does not exist!"); +}); +assert.sameValue(o.barGetter, true, 'o.barGetter'); +assert.sameValue(o.barSetter, undefined, 'o.barSetter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_7.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_7.js new file mode 100644 index 0000000000..24e16f351d --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_7.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. + +/*--- +es5id: 11.2.3-3_7 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (getter called as indexed property) +---*/ + + var o = { }; + Object.defineProperty(o, "bar", {get: function() {this.barGetter = true; return 42;}, + set: function(x) {this.barSetter = true; }}); +assert.throws(TypeError, function() { + o.foo( o["bar"] ); + throw new Test262Error("o.foo does not exist!"); +}); +assert.sameValue(o.barGetter, true, 'o.barGetter'); +assert.sameValue(o.barSetter, undefined, 'o.barSetter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/11.2.3-3_8.js b/js/src/tests/test262/language/expressions/call/11.2.3-3_8.js new file mode 100644 index 0000000000..2058665d46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/11.2.3-3_8.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 11.2.3-3_8 +description: > + Call arguments are evaluated before the check is made to see if + the object is actually callable (global object) +flags: [noStrict] +---*/ + + var fooCalled = false; + function foo(){ fooCalled = true; } +assert.throws(TypeError, function() { + this.bar( foo() ); + throw new Test262Error("this.bar does not exist!"); +}); +assert.sameValue(fooCalled, true, 'fooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A1.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A1.js new file mode 100644 index 0000000000..db5f3e00c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A1.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + White Space and Line Terminator between MemberExpression and Arguments + are allowed +es5id: 11.2.3_A1 +description: Checking by using eval +---*/ + +//CHECK#1 +if (eval("Number\u0009()") !== 0) { + throw new Test262Error('#1: Number\\u0009() === 0'); +} + +//CHECK#2 +if (eval("Number\u000B()") !== 0) { + throw new Test262Error('#2: Number\\u000B() === 0'); +} + +//CHECK#3 +if (eval("Number\u000C()") !== 0) { + throw new Test262Error('#3: Number\\u000C() === 0'); +} + +//CHECK#4 +if (eval("Number\u0020()") !== 0) { + throw new Test262Error('#4: Number\\u0020 === 0'); +} + +//CHECK#5 +if (eval("Number\u00A0()") !== 0) { + throw new Test262Error('#5: Number\\u00A0() === 0'); +} + +//CHECK#6 +if (eval("Number\u000A()") !== 0) { + throw new Test262Error('#6: Number\\u000A() === 0'); +} + +//CHECK#7 +if (eval("Number\u000D()") !== 0) { + throw new Test262Error('#7: Number\\u000D() === 0'); +} + +//CHECK#8 +if (eval("Number\u2028()") !== 0) { + throw new Test262Error('#8: Number\\u2028() === 0'); +} + +//CHECK#9 +if (eval("Number\u2029()") !== 0) { + throw new Test262Error('#9: Number\\u2029() === 0'); +} + +//CHECK#10 +if (eval("Number\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029()") !== 0) { + throw new Test262Error('#10: Number\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029() === 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A2.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A2.js new file mode 100644 index 0000000000..8e788cac6a --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A2.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "CallExpression : MemberExpression Arguments uses GetValue" +es5id: 11.2.3_A2 +description: If GetBase(MemberExpression) is null, throw ReferenceError +---*/ + +//CHECK#1 +try { + x(); + throw new Test262Error('#1.1: x() throw ReferenceError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: x() throw ReferenceError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + x(1,2,3); + throw new Test262Error('#2.1: x(1,2,3) throw ReferenceError. Actual: ' + (x(1,2,3))); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#2.2: x(1,2,3) throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T1.js new file mode 100644 index 0000000000..4a50f27899 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If MemberExpression is not Object, throw TypeError +es5id: 11.2.3_A3_T1 +description: Checking "boolean primitive" case +---*/ + +//CHECK#1 +try { + true(); + throw new Test262Error('#1.1: true() throw TypeError. Actual: ' + (true())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: true() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = true; + x(); + throw new Test262Error('#2.1: var x = true; x() throw TypeError. Actual: ' + (x())) +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = true; x() throw TypeError. Actual: ' + (e)) + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T2.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T2.js new file mode 100644 index 0000000000..25d3d27693 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If MemberExpression is not Object, throw TypeError +es5id: 11.2.3_A3_T2 +description: Checking "number primitive" case +---*/ + +//CHECK#1 +try { + 1(); + throw new Test262Error('#1.1: 1() throw TypeError. Actual: ' + (1())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: 1() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = 1; + x(); + throw new Test262Error('#2.1: var x = 1; x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = 1; x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T3.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T3.js new file mode 100644 index 0000000000..a955322d11 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T3.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If MemberExpression is not Object, throw TypeError +es5id: 11.2.3_A3_T3 +description: Checking "string primitive" case +---*/ + +//CHECK#1 +try { + "1"(); + throw new Test262Error('#1.1: "1"() throw TypeError. Actual: ' + ("1"())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: "1"() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = "1"; + x(); + throw new Test262Error('#2.1: var x = "1"; x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = "1"; x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T4.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T4.js new file mode 100644 index 0000000000..f4794ae619 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T4.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If MemberExpression is not Object, throw TypeError +es5id: 11.2.3_A3_T4 +description: Checking "undefined" case +---*/ + +//CHECK#1 +try { + undefined(); + throw new Test262Error('#1.1: undefined() throw TypeError. Actual: ' + (e)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: undefined() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = undefined; + x(); + throw new Test262Error('#2.1: var x = undefined; x() throw TypeError. Actual: ' + (e)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = undefined; x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T5.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T5.js new file mode 100644 index 0000000000..426efcf6b0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A3_T5.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If MemberExpression is not Object, throw TypeError +es5id: 11.2.3_A3_T5 +description: Checking "null" case +---*/ + +//CHECK#1 +try { + null(); + throw new Test262Error('#1.1: null() throw TypeError. Actual: ' + (null())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: null() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = null; + x(); + throw new Test262Error('#2.1: var x = null; x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = null; x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T1.js new file mode 100644 index 0000000000..ddcac453c8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T1.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If MemberExpression does not implement the internal [[Call]] method, + throw TypeError +es5id: 11.2.3_A4_T1 +description: Checking Boolean object case +---*/ + +//CHECK#1 +try { + new Boolean(true)(); + throw new Test262Error('#1.1: new Boolean(true)() throw TypeError. Actual: ' + (new Boolean(true)())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: new Boolean(true)() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = new Boolean(true); + x(); + throw new Test262Error('#2.1: var x = new Boolean(true); x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = new Boolean(true); x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T2.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T2.js new file mode 100644 index 0000000000..99214a9a3e --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T2.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If MemberExpression does not implement the internal [[Call]] method, + throw TypeError +es5id: 11.2.3_A4_T2 +description: Checking Number object case +---*/ + +//CHECK#1 +try { + new Number(1)(); + throw new Test262Error('#1.1: new Number(1)() throw TypeError. Actual: ' + (new Number(1)())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: new Number(1)() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = new Number(1); + x(); + throw new Test262Error('#2.1: var x = new Number(1); x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = new Number(1); x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T3.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T3.js new file mode 100644 index 0000000000..f643c22127 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T3.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If MemberExpression does not implement the internal [[Call]] method, + throw TypeError +es5id: 11.2.3_A4_T3 +description: Checking String object case +---*/ + +//CHECK#1 +try { + new String("1")(); + throw new Test262Error('#1.1: new String("1")() throw TypeError. Actual: ' + (new String("1")())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: new String("1")() throw TypeError. Actual: ' + (e)); + } +} + +//CHECK#2 +try { + var x = new String("1"); + x(); + throw new Test262Error('#2.1: var x = new String("1"); x() throw TypeError. Actual: ' + (x())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#2.2: var x = new String("1"); x() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T4.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T4.js new file mode 100644 index 0000000000..466eac6e8a --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T4.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If MemberExpression does not implement the internal [[Call]] method, + throw TypeError +es5id: 11.2.3_A4_T4 +description: Checking Global object case +---*/ + +//CHECK#1 +try { + this(); + throw new Test262Error('#1.1: this() throw TypeError. Actual: ' + (this())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: this() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T5.js b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T5.js new file mode 100644 index 0000000000..c49f9edd12 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.3_A4_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If MemberExpression does not implement the internal [[Call]] method, + throw TypeError +es5id: 11.2.3_A4_T5 +description: Checking Math object case +---*/ + +//CHECK#1 +try { + Math(); + throw new Test262Error('#1.1: Math() throw TypeError. Actual: ' + (Math())); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: Math() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T1.js new file mode 100644 index 0000000000..92031d3756 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Arguments : ()" +es5id: 11.2.4_A1.1_T1 +description: Function is declared with no FormalParameterList +---*/ + +function f_arg() { + return arguments; +} + +//CHECK#1 +if (f_arg().length !== 0) { + throw new Test262Error('#1: function f_arg() {return arguments;} f_arg().length === 0. Actual: ' + (f_arg().length)); +} + +//CHECK#2 +if (f_arg()[0] !== undefined) { + throw new Test262Error('#2: function f_arg() {return arguments;} f_arg()[0] === undefined. Actual: ' + (f_arg()[0])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T2.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T2.js new file mode 100644 index 0000000000..755fc4d844 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.1_T2.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: "Arguments : ()" +es5id: 11.2.4_A1.1_T2 +description: Function is declared with FormalParameterList +---*/ + +function f_arg(x,y) { + return arguments; +} + +//CHECK#1 +if (f_arg().length !== 0) { + throw new Test262Error('#1: function f_arg(x,y) {return arguments;} f_arg().length === 0. Actual: ' + (f_arg().length)); +} + +//CHECK#2 +if (f_arg()[0] !== undefined) { + throw new Test262Error('#2: function f_arg(x,y) {return arguments;} f_arg()[0] === undefined. Actual: ' + (f_arg()[0])); +} + +//CHECK#3 +if (f_arg.length !== 2) { + throw new Test262Error('#3: function f_arg(x,y) {return arguments;} f_arg.length === 2. Actual: ' + (f_arg.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T1.js new file mode 100644 index 0000000000..2d1403fe4b --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T1.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Arguments : (ArgumentList)" +es5id: 11.2.4_A1.2_T1 +description: Function is declared with no FormalParameterList +---*/ + +var f_arg = function() { + return arguments; +} + +//CHECK#1 +if (f_arg(1,2,3).length !== 3) { + throw new Test262Error('#1: f_arg = function()() {return arguments;} f_arg(1,2,3).length === 3. Actual: ' + (f_arg(1,2,3).length)); +} + +//CHECK#2 +if (f_arg(1,2,3)[0] !== 1) { + throw new Test262Error('#1: f_arg = function()() {return arguments;} f_arg(1,2,3)[0] === 1. Actual: ' + (f_arg(1,2,3)[0])); +} + +//CHECK#3 +if (f_arg(1,2,3)[1] !== 2) { + throw new Test262Error('#3: f_arg = function()() {return arguments;} f_arg(1,2,3)[1] === 2. Actual: ' + (f_arg(1,2,3)[1])); +} + +//CHECK#4 +if (f_arg(1,2,3)[2] !== 3) { + throw new Test262Error('#4: f_arg = function()() {return arguments;} f_arg(1,2,3)[2] === 3. Actual: ' + (f_arg(1,2,3)[2])); +} + +//CHECK#5 +if (f_arg(1,2,3)[3] !== undefined) { + throw new Test262Error('#5: f_arg = function()() {return arguments;} f_arg(1,2,3)[3] === undefined. Actual: ' + (f_arg(1,2,3)[3])); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T2.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T2.js new file mode 100644 index 0000000000..d4301f9cc3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.2_T2.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Arguments : (ArgumentList)" +es5id: 11.2.4_A1.2_T2 +description: Function is declared with FormalParameterList +---*/ + +var f_arg = function(x,y) { + return arguments; +} + +//CHECK#1 +if (f_arg(1,2,3).length !== 3) { + throw new Test262Error('#1: f_arg = function(x,y) {return arguments;} f_arg(1,2,3).length === 3. Actual: ' + (f_arg(1,2,3).length)); +} + +//CHECK#2 +if (f_arg(1)[0] !== 1) { + throw new Test262Error('#1: f_arg = function(x,y) {return arguments;} f_arg(1)[0] === 1. Actual: ' + (f_arg(1)[0])); +} + +//CHECK#3 +if (f_arg(1,2)[1] !== 2) { + throw new Test262Error('#3: f_arg = function(x,y) {return arguments;} f_arg(1,2)[1] === 2. Actual: ' + (f_arg(1,2)[1])); +} + +//CHECK#4 +if (f_arg(1,2,3)[2] !== 3) { + throw new Test262Error('#4: f_arg = function(x,y) {return arguments;} f_arg(1,2,3)[2] === 3. Actual: ' + (f_arg(1,2,3)[2])); +} + +//CHECK#5 +if (f_arg(1,2,3)[3] !== undefined) { + throw new Test262Error('#5: f_arg = function(x,y) {return arguments;} f_arg(1,2,3)[3] === undefined. Actual: ' + (f_arg(1,2,3)[3])); +} + +//CHECK#6 +if (f_arg.length !== 2) { + throw new Test262Error('#6: f_arg = function(x,y) {return arguments;} f_arg.length === 2. Actual: ' + (f_arg.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.3_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.3_T1.js new file mode 100644 index 0000000000..a894cdfac7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.3_T1.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Arguments : (ArgumentList : ArgumentList,, AssignmentExpression) is a bad + syntax +es5id: 11.2.4_A1.3_T1 +description: incorrect syntax +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f_arg() { +} + +f_arg(1,,2); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T1.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T1.js new file mode 100644 index 0000000000..5b48bfc64a --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Arguments : (ArgumentList : ArgumentList, AssignmentExpression)" +es5id: 11.2.4_A1.4_T1 +description: > + Return an internal list whose length is one greater than the + length of ArgumentList and whose items are the items of + ArgumentList, in order, followed at the end by + GetValue(AssignmentExpression), which is the last item of the new + list +flags: [noStrict] +---*/ + +function f_arg() { +} + +//CHECK#1 +f_arg(x=1,x); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T2.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T2.js new file mode 100644 index 0000000000..59e8029b32 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T2.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: "Arguments : (ArgumentList : ArgumentList, AssignmentExpression)" +es5id: 11.2.4_A1.4_T2 +description: > + Return an internal list whose length is one greater than the + length of ArgumentList and whose items are the items of + ArgumentList, in order, followed at the end by + GetValue(AssignmentExpression), which is the last item of the new + list +---*/ + +function f_arg() { +} + +//CHECK#1 +try { + f_arg(x,x=1); + throw new Test262Error('#1.1: function f_arg() {} f_arg(x,x=1) throw ReferenceError. Actual: ' + (f_arg(x,x=1))); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + throw new Test262Error('#1.2: function f_arg() {} f_arg(x,x=1) throw ReferenceError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T3.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T3.js new file mode 100644 index 0000000000..48b59cb038 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: "Arguments : (ArgumentList : ArgumentList, AssignmentExpression)" +es5id: 11.2.4_A1.4_T3 +description: > + Return an internal list whose length is one greater than the + length of ArgumentList and whose items are the items of + ArgumentList, in order, followed at the end by + GetValue(AssignmentExpression), which is the last item of the new + list +flags: [noStrict] +---*/ + +function f_arg(x,y,z) { + return z; +} + +//CHECK#1 +if (f_arg(x=1,y=x,x+y) !== 2) { + throw new Test262Error('#1: function f_arg(x,y,z) {return z;} f_arg(x=1,y=x,x+y) === 2. Actual: ' + (f_arg(x=1,y=x,x+y))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T4.js b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T4.js new file mode 100644 index 0000000000..c99e5f0f17 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/S11.2.4_A1.4_T4.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: "Arguments : (ArgumentList : ArgumentList, AssignmentExpression)" +es5id: 11.2.4_A1.4_T4 +description: > + Return an internal list whose length is one greater than the + length of ArgumentList and whose items are the items of + ArgumentList, in order, followed at the end by + GetValue(AssignmentExpression), which is the last item of the new + list +---*/ + +var x = function () { throw "x"; }; +var y = function () { throw "y"; }; + +function f_arg() { +} + +//CHECK#1 +try { + f_arg(x(),y()); + throw new Test262Error('#1.1: var x = { valueOf: function () { throw "x"; } }; var y = { valueOf: function () { throw "y"; } }; function f_arg() {} f_arg(x(),y()) throw "x". Actual: ' + (f_arg(x(),y()))); +} +catch (e) { + if (e === "y") { + throw new Test262Error('#1.2: First argument is evaluated first, and then second argument'); + } else { + if (e !== "x") { + throw new Test262Error('#1.3: var x = { valueOf: function () { throw "x"; } }; var y = { valueOf: function () { throw "y"; } }; function f_arg() {} f_arg(x(),y()) throw "x". Actual: ' + (e)); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/browser.js b/js/src/tests/test262/language/expressions/call/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/browser.js diff --git a/js/src/tests/test262/language/expressions/call/eval-err-args.js b/js/src/tests/test262/language/expressions/call/eval-err-args.js new file mode 100644 index 0000000000..503c3d833b --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-err-args.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Error evaluating arguments list for direct eval +esid: sec-function-calls-runtime-semantics-evaluation +info: | + [...] + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : AssignmentExpression + + 1. Let ref be the result of evaluating AssignmentExpression. + 2. Let arg be ? GetValue(ref). +---*/ + +assert.throws(ReferenceError, function() { + eval(unresolvable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-first-arg.js b/js/src/tests/test262/language/expressions/call/eval-first-arg.js new file mode 100644 index 0000000000..35ddaa7b30 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-first-arg.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If the eval function is called with some argument, then use a first + argument +es5id: 15.1.2.1_A1.2_T1 +description: eval("x = 1", "x = 2"), x equal 1, not 2 +---*/ + +//CHECK#1 +var x; +eval("x = 1", "x = 2"); +if (x !== 1) { + throw new Test262Error('#1: eval("x = 1", "x = 2"); x === 1. Actual: ' + (x)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-no-args.js b/js/src/tests/test262/language/expressions/call/eval-no-args.js new file mode 100644 index 0000000000..b6b39ff9cb --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-no-args.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Error evaluating arguments list for direct eval +esid: sec-function-calls-runtime-semantics-evaluation +info: | + [...] + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + ii. If argList has no elements, return undefined. +---*/ + +assert.sameValue(eval(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-realm-indirect.js b/js/src/tests/test262/language/expressions/call/eval-realm-indirect.js new file mode 100644 index 0000000000..d2aed13a29 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-realm-indirect.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +description: > + An eval function from another realm is not a candidate for direct eval +info: | + [...] + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + [...] +flags: [noStrict] +features: [cross-realm] +---*/ + +var x = 'outside'; +var result; + +(function() { + var eval = $262.createRealm().global.eval; + + eval('var x = "inside";'); + + result = x; +}()); + +assert.sameValue(result, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-spread-empty-leading.js b/js/src/tests/test262/language/expressions/call/eval-spread-empty-leading.js new file mode 100644 index 0000000000..e3170f8ad1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-spread-empty-leading.js @@ -0,0 +1,43 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Direct eval call with empty leading spread. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + ii. If argList has no elements, return undefined. + iii. Let evalText be the first element of argList. + ... + +features: [Symbol.iterator] +---*/ + +var nextCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + var i = nextCount++; + return {done: true, value: undefined}; + } + }; +}; + +var x = "global"; + +(function() { + var x = "local"; + eval(...iter, "x = 0;"); + assert.sameValue(x, 0); +})(); + +assert.sameValue(x, "global"); +assert.sameValue(nextCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-spread-empty-trailing.js b/js/src/tests/test262/language/expressions/call/eval-spread-empty-trailing.js new file mode 100644 index 0000000000..6827e2fc10 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-spread-empty-trailing.js @@ -0,0 +1,43 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Direct eval call with empty trailing spread. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + ii. If argList has no elements, return undefined. + iii. Let evalText be the first element of argList. + ... + +features: [Symbol.iterator] +---*/ + +var nextCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + var i = nextCount++; + return {done: true, value: undefined}; + } + }; +}; + +var x = "global"; + +(function() { + var x = "local"; + eval("x = 0;", ...iter); + assert.sameValue(x, 0); +})(); + +assert.sameValue(x, "global"); +assert.sameValue(nextCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-spread-empty.js b/js/src/tests/test262/language/expressions/call/eval-spread-empty.js new file mode 100644 index 0000000000..e2c513b11b --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-spread-empty.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Direct eval call with empty spread. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + ii. If argList has no elements, return undefined. + ... + +features: [Symbol.iterator] +---*/ + +var nextCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + var i = nextCount++; + return {done: true, value: undefined}; + } + }; +}; + +var result = eval(...iter); + +assert.sameValue(result, undefined); +assert.sameValue(nextCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-spread.js b/js/src/tests/test262/language/expressions/call/eval-spread.js new file mode 100644 index 0000000000..dda111785a --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-spread.js @@ -0,0 +1,51 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Direct eval call with spread. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + i. Let argList be ? ArgumentListEvaluation(Arguments). + ii. If argList has no elements, return undefined. + iii. Let evalText be the first element of argList. + ... + +features: [Symbol.iterator] +---*/ + +var elements = [ + "x = 1;", + "x = 2;", +]; + +var nextCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + var i = nextCount++; + if (i < elements.length) { + return {done: false, value: elements[i]}; + } + return {done: true, value: undefined}; + } + }; +}; + +var x = "global"; + +(function() { + var x = "local"; + eval(...iter); + assert.sameValue(x, 1); +})(); + +assert.sameValue(x, "global"); +assert.sameValue(nextCount, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-non-strict.js b/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-non-strict.js new file mode 100644 index 0000000000..a2d6eef814 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-non-strict.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. +/*--- +description: Evaluated code honors the strictness of the calling context +esid: sec-function-calls-runtime-semantics-evaluation +info: | + [...] + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + [...] + iv. If the source code matching this CallExpression is strict code, + let strictCaller be true. Otherwise let strictCaller be false. + [...] +flags: [noStrict] +---*/ + +var count = 0; + +eval('var static; count += 1;'); + +assert.sameValue(count, 1); + +eval('with ({}) {} count += 1;'); + +assert.sameValue(count, 2); + +eval('unresolvable = null; count += 1;'); + +assert.sameValue(count, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-strict-strict.js b/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-strict-strict.js new file mode 100644 index 0000000000..ef5e77f992 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/eval-strictness-inherit-strict-strict.js @@ -0,0 +1,31 @@ +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Evaluated code honors the strictness of the calling context +esid: sec-function-calls-runtime-semantics-evaluation +info: | + [...] + 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + [...] + iv. If the source code matching this CallExpression is strict code, + let strictCaller be true. Otherwise let strictCaller be false. + [...] +flags: [onlyStrict] +---*/ + +assert.throws(SyntaxError, function() { + eval('var static;'); +}); + +assert.throws(SyntaxError, function() { + eval('with ({}) {}'); +}); + +assert.throws(ReferenceError, function() { + eval('unresolvable = null;'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/scope-lex-close.js b/js/src/tests/test262/language/expressions/call/scope-lex-close.js new file mode 100644 index 0000000000..a8d3e0ec67 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/scope-lex-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-ecmascript-function-objects-call-thisargument-argumentslist +description: > + Removal of lexical environment for the function parameters and body +info: | + [...] + 3. Let callerContext be the running execution context. + [...] + 8. Remove calleeContext from the execution context stack and restore + callerContext as the running execution context. + [...] +features: [let] +---*/ + +var probe; + +// This test intentionally elides parameter expressions because their presence +// triggers the creation of an additional LexicalEnvironment dedicated to the +// function body (see sec-functiondeclarationinstantiation) +(function() { + let x = 'inside'; + probe = function() { return x; }; +}()); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/scope-lex-open.js b/js/src/tests/test262/language/expressions/call/scope-lex-open.js new file mode 100644 index 0000000000..3000974cfe --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/scope-lex-open.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-ecmascript-function-objects-call-thisargument-argumentslist +description: > + Creation of new variable environment for the function parameters and body + (as distinct from that for the function's BindingIdentifier) +info: | + [...] + 3. Let callerContext be the running execution context. + 4. Let calleeContext be PrepareForOrdinaryCall(F, undefined). + [...] + + 9.2.1.1 PrepareForOrdinaryCall + + [...] + 8. Let localEnv be NewFunctionEnvironment(F, newTarget). + 9. Set the LexicalEnvironment of calleeContext to localEnv. + 10. Set the VariableEnvironment of calleeContext to localEnv. + [...] +features: [let] +---*/ + +var n = 'outside'; +var probeBefore = function() { return n; }; +var probeInside; + +// This test intentionally elides parameter expressions because their presence +// triggers the creation of an additional LexicalEnvironment dedicated to the +// function body (see sec-functiondeclarationinstantiation) +var func = function n() { + let n = 'inside'; + probeInside = function() { return n; }; +}; + +func(); + +assert.sameValue(probeBefore(), 'outside'); +assert.sameValue(probeInside(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/scope-var-close.js b/js/src/tests/test262/language/expressions/call/scope-var-close.js new file mode 100644 index 0000000000..a909c50c38 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/scope-var-close.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-prepareforordinarycall +description: > + Removal of variable environment for the function parameters and body +info: | + [...] + 3. Let callerContext be the running execution context. + [...] + 8. Remove calleeContext from the execution context stack and restore + callerContext as the running execution context. + [...] +---*/ + +var probe; + +// This test intentionally elides parameter expressions because their presence +// triggers the creation of an additional LexicalEnvironment dedicated to the +// function body (see sec-functiondeclarationinstantiation) +(function() { + var x = 'inside'; + probe = function() { return x; }; +}()); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/scope-var-open.js b/js/src/tests/test262/language/expressions/call/scope-var-open.js new file mode 100644 index 0000000000..6bb7923874 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/scope-var-open.js @@ -0,0 +1,43 @@ +// 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-prepareforordinarycall +description: > + Creation of new variable environment for the function parameters and body + (as distinct from that for the function's BindingIdentifier) +info: | + [...] + 3. Let callerContext be the running execution context. + 4. Let calleeContext be PrepareForOrdinaryCall(F, undefined). + [...] + + 9.2.1.1 PrepareForOrdinaryCall + + [...] + 8. Let localEnv be NewFunctionEnvironment(F, newTarget). + 9. Set the LexicalEnvironment of calleeContext to localEnv. + 10. Set the VariableEnvironment of calleeContext to localEnv. + [...] +---*/ + +var n = 'outside'; +var probeBefore = function() { return n; }; +var probeBody; + +// This test intentionally elides parameter expressions because their presence +// triggers the creation of an additional LexicalEnvironment dedicated to the +// function body (see sec-functiondeclarationinstantiation) +var func = function n() { + // The initializer is intentionally omitted from the following + // VariableStatement in order to demonstrate that a new binding is created + // (and not simply re-used from the FunctionExpression's BindingIdentifier). + var n; + probeBody = function() { return n; }; +}; + +func(); + +assert.sameValue(probeBefore(), 'outside'); +assert.sameValue(probeBody(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/shell.js b/js/src/tests/test262/language/expressions/call/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/shell.js diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-expr-throws.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-expr-throws.js new file mode 100644 index 0000000000..e42e013412 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-expr-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-expr-throws.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when evaluation throws (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [generators] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + +---*/ + +assert.throws(Test262Error, function() { + (function() {}(0, ...function*() { throw new Test262Error(); }())); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-iter-get-value.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-iter-get-value.js new file mode 100644 index 0000000000..eda037f6e8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-iter-get-value.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-iter-get-value.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator function return value) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 2. Let iterator be ? Call(method, obj). + 3. If Type(iterator) is not Object, throw a TypeError exception. +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + return null; + } +}); + +assert.throws(TypeError, function() { + (function() {}(0, ...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-call.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-call.js new file mode 100644 index 0000000000..d7a7771faf --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-call.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-get-call.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator function invocation) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 3. Let iterator be Call(method,obj). + 4. ReturnIfAbrupt(iterator). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + (function() {}(0, ...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-get.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-get.js new file mode 100644 index 0000000000..4ca69e16c6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-get-get.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-get-get.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when GetIterator fails (@@iterator property access) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + 1. If method was not passed, then + a. Let method be ? GetMethod(obj, @@iterator). +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + (function() {}(0, ...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-step.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-step.js new file mode 100644 index 0000000000..636f5ffef0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-step.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-step.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when IteratorStep fails (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.5 IteratorStep ( iterator ) + + 1. Let result be IteratorNext(iterator). + 2. ReturnIfAbrupt(result). + + 7.4.2 IteratorNext ( iterator, value ) + + 1. If value was not passed, then + a. Let result be Invoke(iterator, "next", « »). + [...] + 3. ReturnIfAbrupt(result). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + (function() {}(0, ...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-value.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-value.js new file mode 100644 index 0000000000..394b332c21 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-itr-value.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-itr-value.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when IteratorValue fails (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 7.4.4 IteratorValue ( iterResult ) + + 1. Assert: Type(iterResult) is Object. + 2. Return Get(iterResult, "value"). + + 7.3.1 Get (O, P) + + [...] + 3. Return O.[[Get]](P, O). +---*/ +var iter = {}; +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + (function() {}(0, ...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-obj-unresolvable.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..1bc06fba13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + (function() {}({a: 0, ...unresolvableReference})); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-mult-err-unresolvable.js b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-unresolvable.js new file mode 100644 index 0000000000..308d9e9e98 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-mult-err-unresolvable.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator following other arguments when reference is unresolvable (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + + 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. +---*/ + +assert.throws(ReferenceError, function() { + (function() {}(0, ...unresolvableReference)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-expr-throws.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000..a049c7fe9b --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-expr-throws.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when evaluation throws (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [generators] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(Test262Error, function() { + (function() {}(...function*() { throw new Test262Error(); }())); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-call.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-call.js new file mode 100644 index 0000000000..7dccf2c30d --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-call.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-call.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator function invocation) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 3. Let iterator be Call(method,obj). + 4. ReturnIfAbrupt(iterator). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + (function() {}(...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-get.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-get.js new file mode 100644 index 0000000000..4ecbb002f7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-get.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-get.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator property access) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + 1. If method was not passed, then + a. Let method be ? GetMethod(obj, @@iterator). +---*/ +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + (function() {}(...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-value.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-value.js new file mode 100644 index 0000000000..11f19b5cb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-get-value.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-get-value.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when GetIterator fails (@@iterator function return value) (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 7.4.1 GetIterator ( obj, method ) + + [...] + 2. Let iterator be ? Call(method, obj). + 3. If Type(iterator) is not Object, throw a TypeError exception. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return null; +}; + +assert.throws(TypeError, function() { + (function() {}(...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-step.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-step.js new file mode 100644 index 0000000000..63c664c851 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-step.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-step.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when IteratorStep fails (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + + 7.4.5 IteratorStep ( iterator ) + + 1. Let result be IteratorNext(iterator). + 2. ReturnIfAbrupt(result). + + 7.4.2 IteratorNext ( iterator, value ) + + 1. If value was not passed, then + a. Let result be Invoke(iterator, "next", « »). + [...] + 3. ReturnIfAbrupt(result). +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + (function() {}(...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-value.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-value.js new file mode 100644 index 0000000000..7081c47341 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-itr-value.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-itr-value.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when IteratorValue fails (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + + 7.4.4 IteratorValue ( iterResult ) + + 1. Assert: Type(iterResult) is Object. + 2. Return Get(iterResult, "value"). + + 7.3.1 Get (O, P) + + [...] + 3. Return O.[[Get]](P, O). +---*/ +var iter = {}; +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + (function() {}(...iter)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..7bc51739c3 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + (function() {}({...unresolvableReference})); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-unresolvable.js b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-unresolvable.js new file mode 100644 index 0000000000..a60fbc21fe --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-err-sngl-err-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when reference is unresolvable (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + + 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. +---*/ + +assert.throws(ReferenceError, function() { + (function() {}(...unresolvableReference)); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-empty.js b/js/src/tests/test262/language/expressions/call/spread-mult-empty.js new file mode 100644 index 0000000000..861d8693de --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-empty.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-empty.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator following other arguments when no iteration occurs (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + callCount += 1; +}(1, 2, 3, ...[])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-expr.js b/js/src/tests/test262/language/expressions/call/spread-mult-expr.js new file mode 100644 index 0000000000..798995f0d0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-expr.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-expr.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ +var source = [3, 4, 5]; +var target; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + assert.sameValue(arguments[3], 4); + assert.sameValue(arguments[4], 5); + assert.sameValue(target, source); + callCount += 1; +}(1, 2, ...target = source)); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-iter.js b/js/src/tests/test262/language/expressions/call/spread-mult-iter.js new file mode 100644 index 0000000000..5d18397928 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-iter.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator following other arguments with a valid iterator (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var nextCount = 3; + return { + next: function() { + nextCount += 1; + return { done: nextCount === 6, value: nextCount }; + } + }; +}; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + assert.sameValue(arguments[2], 3); + assert.sameValue(arguments[3], 4); + assert.sameValue(arguments[4], 5); + callCount += 1; +}(1, 2, 3, ...iter)); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-literal.js b/js/src/tests/test262/language/expressions/call/spread-mult-literal.js new file mode 100644 index 0000000000..df90339f58 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-literal.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-literal.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression following other elements (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ArgumentList , ... AssignmentExpression + + 1. Let precedingArgs be the result of evaluating ArgumentList. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let iterator be GetIterator(GetValue(spreadRef) ). + 4. ReturnIfAbrupt(iterator). + 5. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return precedingArgs. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 5); + assert.sameValue(arguments[0], 5); + assert.sameValue(arguments[1], 6); + assert.sameValue(arguments[2], 7); + assert.sameValue(arguments[3], 8); + assert.sameValue(arguments[4], 9); + callCount += 1; +}(5, ...[6, 7, 8], 9)); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-obj-ident.js b/js/src/tests/test262/language/expressions/call/spread-mult-obj-ident.js new file mode 100644 index 0000000000..96c427788c --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-obj-ident.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 4); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(obj, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + + verifyProperty(obj, "c", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "d", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount += 1; +}({a: 1, b: 2, ...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-obj-null.js b/js/src/tests/test262/language/expressions/call/spread-mult-obj-null.js new file mode 100644 index 0000000000..f4e6d6205e --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-obj-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with null value (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...null})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-mult-obj-undefined.js b/js/src/tests/test262/language/expressions/call/spread-mult-obj-undefined.js new file mode 100644 index 0000000000..5f11f31fc8 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-mult-obj-undefined.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with undefined (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...undefined})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-getter-descriptor.js b/js/src/tests/test262/language/expressions/call/spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..f031a17353 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-getter-descriptor.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation with getter results in data property descriptor (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 42 + }); + callCount += 1; +}({...o, c: 4, d: 5})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-getter-init.js b/js/src/tests/test262/language/expressions/call/spread-obj-getter-init.js new file mode 100644 index 0000000000..b27f475c55 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-getter-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/call-expr.template +/*--- +description: Getter in object literal is not evaluated (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, get c() { executedGetter = true; }})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js b/js/src/tests/test262/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..1b100cfcd7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/call-expr.template +/*--- +description: Getter manipulates outter object before it's spread operation (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...cthulhu, ...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread-getter.js b/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..8969cdbacd --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread-getter.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/call-expr.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, c: 4, d: 5, a: 42, ...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread.js b/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread.js new file mode 100644 index 0000000000..7b2f403475 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-mult-spread.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/call-expr.template +/*--- +description: Multiple Object Spread operation (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; +}({...o, ...o2})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-null.js b/js/src/tests/test262/language/expressions/call/spread-obj-null.js new file mode 100644 index 0000000000..d4c262d21f --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/call-expr.template +/*--- +description: Null Object Spread is ignored (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...null})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-override-immutable.js b/js/src/tests/test262/language/expressions/call/spread-obj-override-immutable.js new file mode 100644 index 0000000000..1b2a9ea4e2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-override-immutable.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread overriding immutable properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyProperty(obj, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount += 1; +}({...o, a: 3})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-overrides-prev-properties.js b/js/src/tests/test262/language/expressions/call/spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..691d5250a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-overrides-prev-properties.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread properties overrides previous definitions (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; +}({a: 1, b: 7, ...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-skip-non-enumerable.js b/js/src/tests/test262/language/expressions/call/spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..4db7f6215d --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-skip-non-enumerable.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-spread-order.js b/js/src/tests/test262/language/expressions/call/spread-obj-spread-order.js new file mode 100644 index 0000000000..e0136c6593 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-spread-order.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol, object-spread] +flags: [generated] +includes: [compareArray.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var calls = []; +var o = { get z() { calls.push('z') }, get a() { calls.push('a') } }; +Object.defineProperty(o, 1, { get: () => { calls.push(1) }, enumerable: true }); +Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)") }, enumerable: true }); + + +var callCount = 0; + +(function(obj) { + assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-symbol-property.js b/js/src/tests/test262/language/expressions/call/spread-obj-symbol-property.js new file mode 100644 index 0000000000..c762f28ebe --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-symbol-property.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation where source object contains Symbol properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol, object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj[symbol], 1); + assert(Object.prototype.hasOwnProperty.call(obj, symbol), "symbol is an own property"); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({...o, c: 4, d: 5})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-undefined.js b/js/src/tests/test262/language/expressions/call/spread-obj-undefined.js new file mode 100644 index 0000000000..34dd799ef5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-undefined.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/call-expr.template +/*--- +description: Undefined Object Spread is ignored (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...undefined})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-obj-with-overrides.js b/js/src/tests/test262/language/expressions/call/spread-obj-with-overrides.js new file mode 100644 index 0000000000..cfb06917cd --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-obj-with-overrides.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread properties being overriden (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol, object-spread] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; +}({...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-sngl-empty.js b/js/src/tests/test262/language/expressions/call/spread-sngl-empty.js new file mode 100644 index 0000000000..e0c749c760 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-sngl-empty.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-empty.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to the only argument when no iteration occurs (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + [...] +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 0); + callCount += 1; +}(...[])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-sngl-expr.js b/js/src/tests/test262/language/expressions/call/spread-sngl-expr.js new file mode 100644 index 0000000000..1d5d2f409e --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-sngl-expr.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-expr.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to AssignmentExpression as only element (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var source = [2, 3, 4]; +var target; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 2); + assert.sameValue(arguments[1], 3); + assert.sameValue(arguments[2], 4); + assert.sameValue(target, source); + callCount += 1; +}(...target = source)); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-sngl-iter.js b/js/src/tests/test262/language/expressions/call/spread-sngl-iter.js new file mode 100644 index 0000000000..2902597cf1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-sngl-iter.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-iter.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to the only argument with a valid iterator (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [Symbol.iterator] +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var nextCount = 0; + return { + next: function() { + nextCount += 1; + return { done: nextCount === 3, value: nextCount }; + } + }; +}; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 2); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + callCount += 1; +}(...iter)); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-sngl-literal.js b/js/src/tests/test262/language/expressions/call/spread-sngl-literal.js new file mode 100644 index 0000000000..57b9cc418b --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-sngl-literal.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-literal.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to array literal as only element (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 3); + assert.sameValue(arguments[0], 3); + assert.sameValue(arguments[1], 4); + assert.sameValue(arguments[2], 5); + callCount += 1; +}(...[3, 4, 5])); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/spread-sngl-obj-ident.js b/js/src/tests/test262/language/expressions/call/spread-sngl-obj-ident.js new file mode 100644 index 0000000000..994dab059d --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/spread-sngl-obj-ident.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator without other arguments (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +features: [object-spread] +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 2); + + verifyProperty(obj, "c", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(obj, "d", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-call-args-strict.js b/js/src/tests/test262/language/expressions/call/tco-call-args-strict.js new file mode 100644 index 0000000000..0cfa383888 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-call-args-strict.js @@ -0,0 +1,24 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Expression is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + function getF() { return f; } + return getF()(n - 1); +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-member-args-strict.js b/js/src/tests/test262/language/expressions/call/tco-member-args-strict.js new file mode 100644 index 0000000000..46490813ca --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-member-args-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Expression is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + return f(n - 1); +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-non-eval-function-dynamic.js b/js/src/tests/test262/language/expressions/call/tco-non-eval-function-dynamic.js new file mode 100644 index 0000000000..55d442a5b7 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-non-eval-function-dynamic.js @@ -0,0 +1,47 @@ +// |reftest| skip -- tail-call-optimization is not supported +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Tail-call with identifier named "eval" in function environment, local "eval" binding dynamically added. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + ... + ... + 9. Return ? EvaluateCall(func, ref, arguments, tailCall). + + 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition ) + ... + 7. If tailPosition is true, perform PrepareForTailCall(). + 8. Let result be Call(func, thisValue, argList). + ... + +flags: [noStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; + +(function() { + function f(n) { + "use strict"; + if (n === 0) { + callCount += 1 + return; + } + return eval(n - 1); + } + eval("var eval = f;"); + f($MAX_ITERATIONS); +})(); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-non-eval-function.js b/js/src/tests/test262/language/expressions/call/tco-non-eval-function.js new file mode 100644 index 0000000000..1d704f4494 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-non-eval-function.js @@ -0,0 +1,47 @@ +// |reftest| skip -- tail-call-optimization is not supported +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Tail-call with identifier named "eval" in function environment. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + ... + ... + 9. Return ? EvaluateCall(func, ref, arguments, tailCall). + + 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition ) + ... + 7. If tailPosition is true, perform PrepareForTailCall(). + 8. Let result be Call(func, thisValue, argList). + ... + +flags: [noStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; + +(function() { + function f(n) { + "use strict"; + if (n === 0) { + callCount += 1 + return; + } + return eval(n - 1); + } + var eval = f; + f($MAX_ITERATIONS); +})(); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-non-eval-global.js b/js/src/tests/test262/language/expressions/call/tco-non-eval-global.js new file mode 100644 index 0000000000..9587c817b9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-non-eval-global.js @@ -0,0 +1,46 @@ +// |reftest| skip -- tail-call-optimization is not supported +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Tail-call with identifier named "eval" in global environment. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + ... + ... + 9. Return ? EvaluateCall(func, ref, arguments, tailCall). + + 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition ) + ... + 7. If tailPosition is true, perform PrepareForTailCall(). + 8. Let result be Call(func, thisValue, argList). + ... + +flags: [noStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; + +function f(n) { + "use strict"; + if (n === 0) { + callCount += 1 + return; + } + return eval(n - 1); +} +eval = f; + +f($MAX_ITERATIONS); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/tco-non-eval-with.js b/js/src/tests/test262/language/expressions/call/tco-non-eval-with.js new file mode 100644 index 0000000000..3535cc7a33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/tco-non-eval-with.js @@ -0,0 +1,49 @@ +// |reftest| skip -- tail-call-optimization is not supported +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function-calls-runtime-semantics-evaluation +description: > + Tail-call with identifier named "eval" in object environment. +info: | + 12.3.4.1 Runtime Semantics: Evaluation + ... + 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and + GetReferencedName(ref) is "eval", then + a. If SameValue(func, %eval%) is true, then + ... + ... + 9. Return ? EvaluateCall(func, ref, arguments, tailCall). + + 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition ) + ... + 7. If tailPosition is true, perform PrepareForTailCall(). + 8. Let result be Call(func, thisValue, argList). + ... + +flags: [noStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; + +var f, scope = {}; +with (scope) { + f = function (n) { + "use strict"; + if (n === 0) { + callCount += 1 + return; + } + return eval(n - 1); + } +} +scope.eval = f; + +f($MAX_ITERATIONS); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/trailing-comma.js b/js/src/tests/test262/language/expressions/call/trailing-comma.js new file mode 100644 index 0000000000..17ef0b1e46 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/trailing-comma.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Jeff Morrison. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Check that trailing commas are permitted after spread arguments + in a call expression. +info: http://jeffmo.github.io/es-trailing-function-commas/ +author: Jeff Morrison <lbljeffmo@gmail.com> +---*/ + +function foo() {} +foo(...[],); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/call/with-base-obj.js b/js/src/tests/test262/language/expressions/call/with-base-obj.js new file mode 100644 index 0000000000..7997271ae5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/call/with-base-obj.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-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +description: Correct retrieval of environment's "with" base object +info: | + 4. If Type(ref) is Reference, then + a. If IsPropertyReference(ref) is true, then + [...] + b. Else the base of ref is an Environment Record, + i. Let refEnv be GetBase(ref). + ii. Let thisValue be refEnv.WithBaseObject(). + [...] + 8. Return ? EvaluateDirectCall(func, thisValue, Arguments, tailCall). +flags: [noStrict] +---*/ + +var viaMember, viaCall; +var obj = { + method: function() { + viaCall = this; + }, + get attribute() { + viaMember = this; + } +}; + +with (obj) { + method(); + attribute; +} + +assert.sameValue(viaCall, obj, 'via CallExpression'); +assert.sameValue(viaMember, obj, 'via MemberExpression'); + +reportCompare(0, 0); |