Skip to content
Snippets Groups Projects
Commit 052bf237 authored by Gorkem Yakin's avatar Gorkem Yakin
Browse files

Merge pull request #475 from bocoup/completion-reform

Tests for ES2015/2016 Completion Reform
parents 23d0f459 e62d43c8
No related branches found
No related tags found
No related merge requests found
Showing
with 626 additions and 0 deletions
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.2.6
description: >
Completion value when iteration completes due to an empty abrupt completion
info: >
IterationStatement : do Statement while ( Expression ) ;
1. Let V = undefined.
2. Repeat
a. Let stmt be the result of evaluating Statement.
b. If LoopContinues(stmt, labelSet) is false, return
Completion(UpdateEmpty(stmt, V)).
---*/
assert.sameValue(eval('1; do { break; } while (false)'), undefined);
assert.sameValue(eval('2; do { 3; break; } while (false)'), 3);
assert.sameValue(eval('4; do { continue; } while (false)'), undefined);
assert.sameValue(eval('5; do { 6; continue; } while (false)'), 6);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.2.6
description: >
Completion value when iteration completes due to expression value
info: >
IterationStatement : do Statement while ( Expression ) ;
1. Let V = undefined.
2. Repeat
a. Let stmt be the result of evaluating Statement.
b. If LoopContinues(stmt, labelSet) is false, return
Completion(UpdateEmpty(stmt, V)).
c. If stmt.[[value]] is not empty, let V = stmt.[[value]].
d. Let exprRef be the result of evaluating Expression.
e. Let exprValue be GetValue(exprRef).
f. ReturnIfAbrupt(exprValue).
g. If ToBoolean(exprValue) is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('1; do { } while (false)'), undefined);
assert.sameValue(eval('2; do { 3; } while (false)'), 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and iteration is cancelled
info: >
IterationStatement : for ( var ForBinding in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
m. If LoopContinues(result, labelSet) is false, return
IteratorClose(iterator, UpdateEmpty(result, V)).
---*/
assert.sameValue(eval('1; for (var a in { x: 0 }) { break; }'), undefined);
assert.sameValue(eval('2; for (var b in { x: 0 }) { 3; break; }'), 3);
assert.sameValue(
eval('4; outer: do { for (var a in { x: 0 }) { continue outer; } } while (false)'),
undefined
);
assert.sameValue(
eval('5; outer: do { for (var b in { x: 0 }) { 6; continue outer; } } while (false)'),
6
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and iteration occurs
info: >
IterationStatement : for ( var ForBinding in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
n. If result.[[value]] is not empty, let V be result.[[value]].
---*/
assert.sameValue(eval('1; for (var a in { x: 0 }) { }'), undefined);
assert.sameValue(eval('2; for (var b in { x: 0 }) { 3; }'), 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and iteration is skipped
info: >
IterationStatement : for ( var ForBinding in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
13.7.5.12 Runtime Semantics: ForIn/OfHeadEvaluation
[...]
7. If iterationKind is enumerate, then
a. If exprValue.[[value]] is null or undefined, then
i. Return Completion{[[type]]: break, [[value]]: empty, [[target]]:
empty}.
---*/
assert.sameValue(eval('1; for (var a in undefined) { }'), undefined);
assert.sameValue(eval('2; for (var b in undefined) { 3; }'), undefined);
assert.sameValue(eval('4; for (var c in null) { }'), undefined);
assert.sameValue(eval('5; for (var d in null) { 6; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and no iteration occurs
info: >
IterationStatement : for ( var ForBinding in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('1; for (var a in {}) { }'), undefined);
assert.sameValue(eval('2; for (var b in {}) { 3; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and iteration is cancelled
info: >
IterationStatement : for ( LeftHandSideExpression in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
m. If LoopContinues(result, labelSet) is false, return
IteratorClose(iterator, UpdateEmpty(result, V)).
---*/
assert.sameValue(eval('var a; 1; for (a in { x: 0 }) { break; }'), undefined);
assert.sameValue(eval('var b; 2; for (b in { x: 0 }) { 3; break; }'), 3);
assert.sameValue(
eval('var a; 4; outer: do { for (a in { x: 0 }) { continue outer; } } while (false)'),
undefined
);
assert.sameValue(
eval('var b; 5; outer: do { for (b in { x: 0 }) { 6; continue outer; } } while (false)'),
6
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and iteration occurs
info: >
IterationStatement : for ( LeftHandSideExpression in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
n. If result.[[value]] is not empty, let V be result.[[value]].
---*/
assert.sameValue(eval('var a; 1; for (a in { x: 0 }) { }'), undefined);
assert.sameValue(eval('var b; 2; for (b in { x: 0 }) { 3; }'), 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and iteration is skipped
info: >
IterationStatement : for ( LeftHandSideExpression in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
13.7.5.12 Runtime Semantics: ForIn/OfHeadEvaluation
[...]
7. If iterationKind is enumerate, then
a. If exprValue.[[value]] is null or undefined, then
i. Return Completion{[[type]]: break, [[value]]: empty, [[target]]:
empty}.
---*/
assert.sameValue(eval('var a; 1; for (a in undefined) { }'), undefined);
assert.sameValue(eval('var b; 2; for (b in undefined) { 3; }'), undefined);
assert.sameValue(eval('var c; 4; for (c in null) { }'), undefined);
assert.sameValue(eval('var d; 5; for (d in null) { 6; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and no iteration occurs
info: >
IterationStatement : for ( LeftHandSideExpression in Expression ) Statement
1. Let keyResult be ForIn/OfHeadEvaluation( « », Expression, enumerate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('var a; 1; for (a in {}) { }'), undefined);
assert.sameValue(eval('var b; 2; for (b in {}) { 3; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and iteration is cancelled
info: >
IterationStatement : for ( var ForBinding of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
m. If LoopContinues(result, labelSet) is false, return
IteratorClose(iterator, UpdateEmpty(result, V)).
---*/
assert.sameValue(eval('1; for (var a of [0]) { break; }'), undefined);
assert.sameValue(eval('2; for (var b of [0]) { 3; break; }'), 3);
assert.sameValue(
eval('4; outer: do { for (var a of [0]) { continue outer; } } while (false)'),
undefined
);
assert.sameValue(
eval('5; outer: do { for (var b of [0]) { 6; continue outer; } } while (false)'),
6
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and iteration occurs
info: >
IterationStatement : for ( var ForBinding of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
n. If result.[[value]] is not empty, let V be result.[[value]].
---*/
assert.sameValue(eval('1; for (var a of [0]) { }'), undefined);
assert.sameValue(eval('2; for (var b of [0]) { 3; }'), 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has a declaration and no iteration occurs
info: >
IterationStatement : for ( var ForBinding of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
varBinding, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('1; for (var a of []) { }'), undefined);
assert.sameValue(eval('2; for (var b of []) { 3; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and iteration is cancelled
info: >
IterationStatement :
for ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
m. If LoopContinues(result, labelSet) is false, return
IteratorClose(iterator, UpdateEmpty(result, V)).
---*/
assert.sameValue(eval('var a; 1; for (a of [0]) { break; }'), undefined);
assert.sameValue(eval('var b; 2; for (b of [0]) { 3; break; }'), 3);
assert.sameValue(
eval('var a; 4; outer: do { for (a of [0]) { continue outer; } } while (false)'),
undefined
);
assert.sameValue(
eval('var b; 5; outer: do { for (b of [0]) { 6; continue outer; } } while (false)'),
6
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and iteration occurs
info: >
IterationStatement :
for ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
[...]
k. Let result be the result of evaluating stmt.
[...]
n. If result.[[value]] is not empty, let V be result.[[value]].
---*/
assert.sameValue(eval('var a; 1; for (a of [0]) { }'), undefined);
assert.sameValue(eval('var b; 2; for (b of [0]) { 3; }'), 3);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.5.11
description: >
Completion value when head has no declaration and no iteration occurs
info: >
IterationStatement :
for ( LeftHandSideExpression of AssignmentExpression ) Statement
1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
AssignmentExpression, iterate).
2. ReturnIfAbrupt(keyResult).
3. Return ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
keyResult, assignment, labelSet).
13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
[...]
2. Let V = undefined.
[...]
5. Repeat
a. Let nextResult be IteratorStep(iterator).
b. ReturnIfAbrupt(nextResult).
c. If nextResult is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('var a; 1; for (a of []) { }'), undefined);
assert.sameValue(eval('var b; 2; for (b of []) { 3; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.4.7
description: >
Completion value when head has a declaration and a "test" expression and iteration occurs
info: >
IterationStatement :
for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
1. Let varDcl be the result of evaluating VariableDeclarationList.
2. ReturnIfAbrupt(varDcl).
3. Return ForBodyEvaluation(the first Expression, the second Expression,
Statement, « », labelSet).
13.7.4.8 Runtime Semantics: ForBodyEvaluation
1. Let V = undefined.
[...]
4. Repeat
a. If test is not [empty], then
i. Let testRef be the result of evaluating test.
ii. Let testValue be GetValue(testRef).
iii. ReturnIfAbrupt(testValue).
iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
---*/
assert.sameValue(
eval('1; for (var runA = true; runA; runA = false) { }'), undefined
);
assert.sameValue(
eval('2; for (var runB = true; runB; runB = false) { 3; }'), 3
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.4.7
description: >
Completion value when head has a declaration and a "test" expression and no iteration occurs
info: >
IterationStatement :
for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
1. Let varDcl be the result of evaluating VariableDeclarationList.
2. ReturnIfAbrupt(varDcl).
3. Return ForBodyEvaluation(the first Expression, the second Expression,
Statement, « », labelSet).
13.7.4.8 Runtime Semantics: ForBodyEvaluation
1. Let V = undefined.
[...]
4. Repeat
a. If test is not [empty], then
i. Let testRef be the result of evaluating test.
ii. Let testValue be GetValue(testRef).
iii. ReturnIfAbrupt(testValue).
iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('1; for (var run = false; run; ) { }'), undefined);
assert.sameValue(eval('2; for (var run = false; run; ) { 3; }'), undefined);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.4.7
description: >
Completion value when head has no declaration and a "test" expression and
iteration occurs
info: >
IterationStatement :
for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
1. If the first Expression is present, then
a. Let exprRef be the result of evaluating the first Expression.
b. Let exprValue be GetValue(exprRef).
c. ReturnIfAbrupt(exprValue).
2. Return ForBodyEvaluation(the second Expression, the third Expression,
Statement, « », labelSet).
13.7.4.8 Runtime Semantics: ForBodyEvaluation
1. Let V = undefined.
[...]
4. Repeat
a. If test is not [empty], then
i. Let testRef be the result of evaluating test.
ii. Let testValue be GetValue(testRef).
iii. ReturnIfAbrupt(testValue).
iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
---*/
assert.sameValue(
eval('var runA; 1; for (runA = true; runA; runA = false) { }'), undefined
);
assert.sameValue(
eval('var runB; 2; for (runB = true; runB; runB = false) { 3; }'), 3
);
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.7.4.7
description: >
Completion value when head has no declaration and a "test" expression and no iteration occurs
info: >
IterationStatement :
for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
1. If the first Expression is present, then
a. Let exprRef be the result of evaluating the first Expression.
b. Let exprValue be GetValue(exprRef).
c. ReturnIfAbrupt(exprValue).
2. Return ForBodyEvaluation(the second Expression, the third Expression,
Statement, « », labelSet).
13.7.4.8 Runtime Semantics: ForBodyEvaluation
1. Let V = undefined.
[...]
4. Repeat
a. If test is not [empty], then
i. Let testRef be the result of evaluating test.
ii. Let testValue be GetValue(testRef).
iii. ReturnIfAbrupt(testValue).
iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
---*/
assert.sameValue(eval('1; for ( ; false; ) { }'), undefined);
assert.sameValue(eval('2; for ( ; false; ) { 3; }'), undefined);
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