diff --git a/test/language/expressions/call/eval-spread-empty-leading.js b/test/language/expressions/call/eval-spread-empty-leading.js new file mode 100644 index 0000000000000000000000000000000000000000..74ddaa89e9e4a02301443b7bcc3d9ca02880eeb6 --- /dev/null +++ b/test/language/expressions/call/eval-spread-empty-leading.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +id: sec-function-calls-runtime-semantics-evaluation +info: > + Direct eval call with empty leading spread. +description: | + 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); diff --git a/test/language/expressions/call/eval-spread-empty-trailing.js b/test/language/expressions/call/eval-spread-empty-trailing.js new file mode 100644 index 0000000000000000000000000000000000000000..ee92dc95b7f8938bf0d5c35370185e0f25e426d5 --- /dev/null +++ b/test/language/expressions/call/eval-spread-empty-trailing.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +id: sec-function-calls-runtime-semantics-evaluation +info: > + Direct eval call with empty trailing spread. +description: | + 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); diff --git a/test/language/expressions/call/eval-spread-empty.js b/test/language/expressions/call/eval-spread-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..3c462a686d8415640d82407d196f536084b5bc56 --- /dev/null +++ b/test/language/expressions/call/eval-spread-empty.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +id: sec-function-calls-runtime-semantics-evaluation +info: > + Direct eval call with empty spread. +description: | + 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); diff --git a/test/language/expressions/call/eval-spread.js b/test/language/expressions/call/eval-spread.js new file mode 100644 index 0000000000000000000000000000000000000000..8ad99fcf9c037a6dd2de657cda30a37e15c7f8f0 --- /dev/null +++ b/test/language/expressions/call/eval-spread.js @@ -0,0 +1,49 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +id: sec-function-calls-runtime-semantics-evaluation +info: > + Direct eval call with spread. +description: | + 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);