Skip to content
Snippets Groups Projects
Commit 230dee16 authored by Leo Balter's avatar Leo Balter
Browse files

Merge pull request #585 from bocoup/generation-spread

Add tests for the spread operator (procedurally generated)
parents c6a15255 18a2ba86
No related branches found
No related tags found
No related merge requests found
Showing
with 496 additions and 0 deletions
......@@ -3,6 +3,7 @@
/*---
path: language/expressions/call/spread-
name: CallExpression
esid: sec-function-calls-runtime-semantics-evaluation
es6id: 12.3.4.1
info: |
CallExpression : MemberExpression Arguments
......
......@@ -4,6 +4,7 @@
path: language/expressions/new/spread-
name: >
`new` operator
esid: sec-new-operator-runtime-semantics-evaluation
es6id: 12.3.3.1
info: |
MemberExpression : new MemberExpression Arguments
......
......@@ -3,6 +3,7 @@
/*---
path: language/expressions/super/spread-
name: SuperCall
esid: sec-super-keyword-runtime-semantics-evaluation
es6id: 12.3.5.1
info: |
SuperCall : super Arguments
......
......@@ -3,6 +3,7 @@
/*---
path: language/expressions/call/spread-err-
name: CallExpression
esid: sec-function-calls-runtime-semantics-evaluation
es6id: 12.3.4.1
info: |
CallExpression : MemberExpression Arguments
......
......@@ -4,6 +4,7 @@
path: language/expressions/new/spread-err-
name: >
`new` operator
esid: sec-new-operator-runtime-semantics-evaluation
es6id: 12.3.3.1
info: |
MemberExpression : new MemberExpression Arguments
......
......@@ -3,6 +3,7 @@
/*---
path: language/expressions/super/spread-err-
name: SuperCall
esid: sec-super-keyword-runtime-semantics-evaluation
es6id: 12.3.5.1
info: |
SuperCall : super Arguments
......
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments when no iteration occurs
template: default
info: |
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.
---*/
//- args
1, 2, 3, ...[]
//- body
assert.sameValue(arguments.length, 3);
assert.sameValue(arguments[0], 1);
assert.sameValue(arguments[1], 2);
assert.sameValue(arguments[2], 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments when evaluation throws
template: error
info: |
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).
---*/
//- error
Test262Error
//- args
0, ...function*() { throw new Test262Error(); }()
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator following other arguments when GetIterator fails
(@@iterator function return value)
template: error
features: [Symbol.iterator]
info: |
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.
---*/
//- setup
var iter = {};
Object.defineProperty(iter, Symbol.iterator, {
get: function() {
return null;
}
});
//- error
TypeError
//- args
0, ...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator following other arguments when GetIterator fails
(@@iterator function invocation)
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
throw new Test262Error();
};
//- error
Test262Error
//- args
0, ...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator following other arguments when GetIterator fails
(@@iterator property access)
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
Object.defineProperty(iter, Symbol.iterator, {
get: function() {
throw new Test262Error();
}
});
//- error
Test262Error
//- args
0, ...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments when IteratorStep fails
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
return {
next: function() {
throw new Test262Error();
}
};
};
//- error
Test262Error
//- args
0, ...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments when IteratorValue fails
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
var poisonedValue = Object.defineProperty({}, 'value', {
get: function() {
throw new Test262Error();
}
});
iter[Symbol.iterator] = function() {
return {
next: function() {
return poisonedValue;
}
};
};
//- error
Test262Error
//- args
0, ...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments when reference is unresolvable
template: error
info: |
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.
---*/
//- error
ReferenceError
//- args
0, ...unresolvableReference
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator following other arguments with a valid iterator
template: default
features: [Symbol.iterator]
info: |
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.
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
var nextCount = 3;
return {
next: function() {
nextCount += 1;
return { done: nextCount === 6, value: nextCount };
}
};
};
//- args
1, 2, 3, ...iter
//- body
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);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator applied to the only argument when no iteration occurs
template: default
info: |
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.
[...]
---*/
//- params
//- args
...[]
//- body
assert.sameValue(arguments.length, 0);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator applied to the only argument when GetIterator fails
(@@iterator function invocation)
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
throw new Test262Error();
};
//- error
Test262Error
//- args
...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator applied to the only argument when GetIterator fails
(@@iterator property access)
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
Object.defineProperty(iter, Symbol.iterator, {
get: function() {
throw new Test262Error();
}
});
//- error
Test262Error
//- args
...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Spread operator applied to the only argument when GetIterator fails
(@@iterator function return value)
template: error
features: [Symbol.iterator]
info: |
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.
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
return null;
};
//- error
TypeError
//- args
...iter
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Spread operator applied to the only argument when IteratorStep fails
template: error
features: [Symbol.iterator]
info: |
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).
---*/
//- setup
var iter = {};
iter[Symbol.iterator] = function() {
return {
next: function() {
throw new Test262Error();
}
};
};
//- error
Test262Error
//- args
...iter
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment