Add test templates for spread in array initializer

Formulate templates for the SpreadElement in an array initializer in
order to conform to existing pattern.
This commit is contained in:
Mike Pennisi 2016-06-11 17:27:19 -04:00
parent aeb88953f0
commit 2658524163
2 changed files with 57 additions and 0 deletions

View File

@ -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.
/*---
path: language/expressions/array/spread-
name: Array initializer
esid: sec-runtime-semantics-arrayaccumulation
es6id: 12.2.5.2
info: |
SpreadElement : ...AssignmentExpression
1. Let spreadRef be the result of evaluating AssignmentExpression.
2. Let spreadObj be ? GetValue(spreadRef).
3. Let iterator be ? GetIterator(spreadObj).
4. Repeat
a. Let next be ? IteratorStep(iterator).
b. If next is false, return nextIndex.
c. Let nextValue be ? IteratorValue(next).
d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)),
nextValue).
e. Assert: status is true.
f. Let nextIndex be nextIndex + 1.
---*/
var callCount = 0;
(function(/*{ params }*/) {
/*{ body }*/
callCount += 1;
}.apply(null, [/*{ args }*/]));
assert.sameValue(callCount, 1);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/array/spread-err-
name: Array initializer
esid: sec-runtime-semantics-arrayaccumulation
es6id: 12.2.5.2
info: |
SpreadElement : ...AssignmentExpression
1. Let spreadRef be the result of evaluating AssignmentExpression.
2. Let spreadObj be ? GetValue(spreadRef).
3. Let iterator be ? GetIterator(spreadObj).
4. Repeat
a. Let next be ? IteratorStep(iterator).
b. If next is false, return nextIndex.
c. Let nextValue be ? IteratorValue(next).
d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)),
nextValue).
e. Assert: status is true.
f. Let nextIndex be nextIndex + 1.
---*/
assert.throws(/*{ error }*/, function() {
[/*{ args }*/];
});