mirror of https://github.com/tc39/test262.git
Merge pull request #475 from bocoup/completion-reform
Tests for ES2015/2016 Completion Reform
This commit is contained in:
commit
052bf2379b
|
@ -0,0 +1,21 @@
|
|||
// 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);
|
|
@ -0,0 +1,23 @@
|
|||
// 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);
|
|
@ -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.
|
||||
/*---
|
||||
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
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -0,0 +1,27 @@
|
|||
// 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);
|
|
@ -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.
|
||||
/*---
|
||||
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
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -0,0 +1,27 @@
|
|||
// 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);
|
|
@ -0,0 +1,42 @@
|
|||
// 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
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -0,0 +1,29 @@
|
|||
// 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);
|
|
@ -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.
|
||||
/*---
|
||||
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
|
||||
);
|
|
@ -0,0 +1,33 @@
|
|||
// 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);
|
|
@ -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.
|
||||
/*---
|
||||
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);
|
|
@ -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.
|
||||
/*---
|
||||
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
|
||||
);
|
|
@ -0,0 +1,28 @@
|
|||
// 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);
|
|
@ -0,0 +1,35 @@
|
|||
// 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
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
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,0 +1,46 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es7id: pending
|
||||
description:
|
||||
Completion value when expression is false with an `else` clause and body
|
||||
returns an empty abrupt completion
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement else Statement
|
||||
|
||||
3. If exprValue is true, then
|
||||
[...]
|
||||
4. Else,
|
||||
a. Let stmtCompletion be the result of evaluating the second Statement.
|
||||
5. Return Completion(UpdateEmpty(stmtCompletion, undefined)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; do { if (false) { } else { break; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; do { 3; if (false) { } else { break; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; do { if (false) { 5; } else { break; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; do { 7; if (false) { 8; } else { break; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('9; do { if (false) { } else { continue; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('10; do { 11; if (false) { } else { continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('12; do { if (false) { 13; } else { continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('14; do { 15; if (false) { 16; } else { continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
|
@ -0,0 +1,23 @@
|
|||
// 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.6.7
|
||||
description: >
|
||||
Completion value when expression is false with an `else` clause and body
|
||||
returns a normal completion
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement else Statement
|
||||
|
||||
4. If exprValue is true, then
|
||||
[...]
|
||||
5. Else,
|
||||
a. Let stmtCompletion be the result of evaluating the second Statement.
|
||||
6. ReturnIfAbrupt(stmtCompletion).
|
||||
7. If stmtCompletion.[[value]] is not empty, return stmtCompletion.
|
||||
8. Return NormalCompletion(undefined).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; if (false) { } else { }'), undefined);
|
||||
assert.sameValue(eval('2; if (false) { } else { 3; }'), 3);
|
||||
assert.sameValue(eval('4; if (false) { 5; } else { }'), undefined);
|
||||
assert.sameValue(eval('6; if (false) { 7; } else { 8; }'), 8);
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es7id: pending
|
||||
description: >
|
||||
Completion value when expression is true with an `else` clause and body
|
||||
returns an abrupt completion
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement else Statement
|
||||
|
||||
3. If exprValue is true, then
|
||||
a. Let stmtCompletion be the result of evaluating the first Statement.
|
||||
4. Else,
|
||||
[...]
|
||||
5. Return Completion(UpdateEmpty(stmtCompletion, undefined)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; do { if (true) { break; } else { } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; do { 3; if (true) { break; } else { } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; do { if (true) { break; } else { 5; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; do { 7; if (true) { break; } else { 8; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; do { if (true) { continue; } else { } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; do { 3; if (true) { continue; } else { } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; do { if (true) { continue; } else { 5; } } while (false)'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; do { 7; if (true) { continue; } else { 8; } } while (false)'),
|
||||
undefined
|
||||
);
|
|
@ -0,0 +1,23 @@
|
|||
// 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.6.7
|
||||
description: >
|
||||
Completion value when expression is true with an `else` clause and body
|
||||
returns a normal completion
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement else Statement
|
||||
|
||||
4. If exprValue is true, then
|
||||
a. Let stmtCompletion be the result of evaluating the first Statement.
|
||||
5. Else,
|
||||
[...]
|
||||
6. ReturnIfAbrupt(stmtCompletion).
|
||||
7. If stmtCompletion.[[value]] is not empty, return stmtCompletion.
|
||||
8. Return NormalCompletion(undefined).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; if (true) { } else { }'), undefined);
|
||||
assert.sameValue(eval('2; if (true) { 3; } else { }'), 3);
|
||||
assert.sameValue(eval('4; if (true) { } else { 5; }'), undefined);
|
||||
assert.sameValue(eval('6; if (true) { 7; } else { 8; }'), 7);
|
|
@ -0,0 +1,15 @@
|
|||
// 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.6.7
|
||||
description: Completion value when expression is false without an `else` clause
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement
|
||||
|
||||
[...]
|
||||
4. If exprValue is false, then
|
||||
a. Return NormalCompletion(undefined).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; if (false) { }'), undefined);
|
||||
assert.sameValue(eval('2; if (false) { 3; }'), undefined);
|
|
@ -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.
|
||||
/*---
|
||||
es7id: pending
|
||||
description: >
|
||||
Completion value when expression is true without an `else` clause and body
|
||||
returns an empty abrupt completion
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement
|
||||
|
||||
3. If exprValue is false, then
|
||||
[...]
|
||||
4. Else,
|
||||
a. Let stmtCompletion be the result of evaluating Statement.
|
||||
b. Return Completion(UpdateEmpty(stmtCompletion, undefined)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; do { 2; if (true) { 3; break; } 4; } while (false)'), 3
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { 6; if (true) { break; } 7; } while (false)'), undefined
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { 9; if (true) { 10; continue; } 11; } while (false)'), 10
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('12; do { 13; if (true) { continue; } 14; } while (false)'), undefined
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
// 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.6.7
|
||||
description: >
|
||||
Completion value when expression is true without an `else` clause and body
|
||||
returns a normal completion.
|
||||
info: >
|
||||
IfStatement : if ( Expression ) Statement
|
||||
|
||||
[...]
|
||||
4. If exprValue is false, then
|
||||
[...]
|
||||
5. Else,
|
||||
a. Let stmtCompletion be the result of evaluating Statement.
|
||||
b. ReturnIfAbrupt(stmtCompletion).
|
||||
c. If stmtCompletion.[[value]] is not empty, return stmtCompletion.
|
||||
d. Return NormalCompletion(undefined).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; if (true) { }'), undefined);
|
||||
assert.sameValue(eval('2; if (true) { 3; }'), 3);
|
|
@ -0,0 +1,56 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when the matching case is exited via an empty abrupt
|
||||
completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
a. If found is false, then
|
||||
i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
ii. If clauseSelector is an abrupt completion, then
|
||||
1. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
2. Else, return Completion(clauseSelector).
|
||||
iii. Let found be the result of performing Strict Equality Comparison
|
||||
input === clauseSelector.[[value]].
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
iii. If R is an abrupt completion, return Completion(UpdateEmpty(R,
|
||||
V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": break; default: }'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { case "a": { 3; break; } default: }'), 3
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; do { switch ("a") { case "a": continue; default: } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { switch ("a") { case "a": { 6; continue; } default: } } while (false)'),
|
||||
6
|
||||
);
|
|
@ -0,0 +1,65 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with an empty abrupt completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
a. If found is false, then
|
||||
[...]
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
iii. If R is an abrupt completion, return Completion(UpdateEmpty(R,
|
||||
V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; case "b": 3; break; default: }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": case "b": 5; break; default: }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; case "b": break; default: }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { switch ("a") { case "a": 9; case "b": 10; continue; default: } } while (false)'),
|
||||
10,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('11; do { switch ("a") { case "a": case "b": 12; continue; default: } } while (false)'),
|
||||
12,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('13; do { switch ("a") { case "a": 14; case "b": continue; default: } } while (false)'),
|
||||
14,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,66 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with a normal completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
a. If found is false, then
|
||||
i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
ii. If clauseSelector is an abrupt completion, then
|
||||
[...]
|
||||
iii. Let found be the result of performing Strict Equality Comparison
|
||||
input === clauseSelector.[[value]].
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
[...]
|
||||
[...]
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
[...]
|
||||
13. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; default: 3; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": default: 5; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; default: }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,24 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when case block is empty
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { }
|
||||
|
||||
1. Return NormalCompletion(undefined).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; switch(null) {}'), undefined);
|
|
@ -0,0 +1,64 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when the matching case is exited via an empty abrupt
|
||||
completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
2. If clauseSelector is an abrupt completion, then
|
||||
a. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
b. Else, return Completion(clauseSelector).
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
1. Let R be the result of evaluating CaseClause C.
|
||||
2. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
3. If R is an abrupt completion, return
|
||||
Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "a": break; }'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { default: case "a": { 3; break; } }'), 3
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; do { switch ("a") { default: case "a": continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { switch ("a") { default: case "a": { 6; continue; } } } while (false)'),
|
||||
6
|
||||
);
|
|
@ -0,0 +1,80 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with an empty abrupt completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
2. If clauseSelector is an abrupt completion, then
|
||||
a. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
b. Else, return Completion(clauseSelector).
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
1. Let R be the result of evaluating CaseClause C.
|
||||
2. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
3. If R is an abrupt completion, return
|
||||
Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "a": 2; case "b": 3; break; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { default: case "a": case "b": 5; break; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { default: case "a": 7; case "b": break; }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { switch ("a") { default: case "a": 9; case "b": 10; continue; } } while (false)'),
|
||||
10,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('11; do { switch ("a") { default: case "a": case "b": 12; continue; } } while (false)'),
|
||||
12,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('13; do { switch ("a") { default: case "a": 14; case "b": continue; } } while (false)'),
|
||||
14,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,65 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with a normal completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
2. If clauseSelector is an abrupt completion, then
|
||||
a. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
b. Else, return Completion(clauseSelector).
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
1. Let R be the result of evaluating CaseClause C.
|
||||
2. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
3. If R is an abrupt completion, return
|
||||
Completion(UpdateEmpty(R, V)).
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "a": 2; case "b": 3; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { default: case "a": case "b": 5; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { default: case "a": 7; case "b": }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,78 @@
|
|||
// 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.12.11
|
||||
description: Completion value when the final case matches
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
2. If clauseSelector is an abrupt completion, then
|
||||
a. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
b. Else, return Completion(clauseSelector).
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
1. Let R be the result of evaluating CaseClause C.
|
||||
2. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
3. If R is an abrupt completion, return
|
||||
Completion(UpdateEmpty(R, V)).
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "a": }'),
|
||||
undefined,
|
||||
'empty StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { default: case "a": 3; }'),
|
||||
3,
|
||||
'non-empy StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("b") { default: case "a": case "b": }'),
|
||||
undefined,
|
||||
'empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; switch ("b") { default: case "a": case "b": 6; }'),
|
||||
6,
|
||||
'non-empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('7; switch ("b") { default: case "a": 8; case "b": }'),
|
||||
undefined,
|
||||
'empty StatementList (following a non-empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('9; switch ("b") { default: case "a": 10; case "b": 11; }'),
|
||||
11,
|
||||
'non-empty StatementList (following a non-empty case)'
|
||||
);
|
|
@ -0,0 +1,49 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when the default case is exited via an empty abrupt
|
||||
completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; switch ("a") { default: break; }'), undefined);
|
||||
assert.sameValue(eval('2; switch ("a") { default: { 3; break; } }'), 3);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; do { switch ("a") { default: { continue; } } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { switch ("a") { default: { 6; continue; } } } while (false)'),
|
||||
6
|
||||
);
|
|
@ -0,0 +1,66 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when the matching case is exited via an empty abrupt
|
||||
completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
[...]
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
a. Let R be the result of evaluating CaseClause C.
|
||||
b. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
c. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "b": break; }'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { default: case "b": { 3; break; } }'), 3
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; do { switch ("a") { default: case "b": continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { switch ("a") { default: case "b": { 6; continue; } } } while (false)'),
|
||||
6
|
||||
);
|
|
@ -0,0 +1,82 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with an empty abrupt completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
[...]
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
a. Let R be the result of evaluating CaseClause C.
|
||||
b. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
c. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "b": 2; case "c": 3; break; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { default: case "b": case "c": 5; break; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { default: case "b": 7; case "c": break; }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { switch ("a") { default: case "b": 9; case "c": 10; continue; } } while (false)'),
|
||||
10,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('11; do { switch ("a") { default: case "b": case "c": 12; continue; } } while (false)'),
|
||||
12,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('13; do { switch ("a") { default: case "b": 14; case "c": continue; } } while (false)'),
|
||||
14,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,67 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with a normal completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
[...]
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
a. Let R be the result of evaluating CaseClause C.
|
||||
b. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
c. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
13. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "b": 2; case "c": 3; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { default: case "b": case "c": 5; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { default: case "b": 7; case "c": }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,80 @@
|
|||
// 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.12.11
|
||||
description: Completion value when the final case matches
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
i. If foundInB is false, then
|
||||
1. Let clauseSelector be the result of CaseSelectorEvaluation of
|
||||
C.
|
||||
[...]
|
||||
3. Let foundInB be the result of performing Strict Equality
|
||||
Comparison input === clauseSelector.[[value]].
|
||||
ii. If foundInB is true, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
a. Let R be the result of evaluating CaseClause C.
|
||||
b. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
c. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
13. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: case "b": }'),
|
||||
undefined,
|
||||
'empty StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { default: case "b": 3; }'),
|
||||
3,
|
||||
'non-empy StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { default: case "b": case "c": }'),
|
||||
undefined,
|
||||
'empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; switch ("a") { default: case "b": case "c": 6; }'),
|
||||
6,
|
||||
'non-empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('7; switch ("a") { default: case "b": 8; case "c": }'),
|
||||
8,
|
||||
'empty StatementList (following a non-empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('9; switch ("a") { default: case "b": 10; case "c": 11; }'),
|
||||
11,
|
||||
'non-empty StatementList (following a non-empty case)'
|
||||
);
|
|
@ -0,0 +1,69 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with an empty abrupt completion in the default case
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; default: 3; break; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": default: 5; break; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; default: break; }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { switch ("a") { case "a": 9; default: 10; continue; } } while (false)'),
|
||||
10,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('11; do { switch ("a") { case "a": default: 12; continue; } } while (false)'),
|
||||
12,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('13; do { switch ("a") { case "a": 14; default: continue; } } while (false)'),
|
||||
14,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,57 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with a normal completion in the default case
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
12. Repeat for each CaseClause C in B (NOTE this is another complete
|
||||
iteration of the second CaseClauses)
|
||||
[...]
|
||||
13. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; default: 3; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": default: 5; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; default: }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,68 @@
|
|||
// 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.12.11
|
||||
description: Completion value when the default case matches and is final
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the list of CaseClause items in the first CaseClauses, in
|
||||
source text order. If the first CaseClauses is not present A is « ».
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A
|
||||
[...]
|
||||
5. Let foundInB be false.
|
||||
6. Let B be the List containing the CaseClause items in the second
|
||||
CaseClauses, in source text order. If the second CaseClauses is not
|
||||
present B is « ».
|
||||
7. If found is false, then
|
||||
a. Repeat for each CaseClause C in B
|
||||
[...]
|
||||
8. If foundInB is true, return NormalCompletion(V).
|
||||
9. Let R be the result of evaluating DefaultClause.
|
||||
10. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
[...]
|
||||
13. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { default: }'),
|
||||
undefined,
|
||||
'empty StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { default: 3; }'),
|
||||
3,
|
||||
'non-empy StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("b") { case "a": default: }'),
|
||||
undefined,
|
||||
'empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; switch ("b") { case "a": default: 6; }'),
|
||||
6,
|
||||
'non-empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('7; switch ("b") { case "a": 8; default: }'),
|
||||
undefined,
|
||||
'empty StatementList (following a non-empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('9; switch ("b") { case "a": 10; default: 11; }'),
|
||||
11,
|
||||
'non-empty StatementList (following a non-empty case)'
|
||||
);
|
|
@ -0,0 +1,53 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when the matching case is exited via an empty abrupt
|
||||
completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the List of CaseClause items in CaseClauses, in source text
|
||||
order.
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A,
|
||||
a. If found is false, then
|
||||
i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
ii. If clauseSelector is an abrupt completion, then
|
||||
1. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
2. Else, return Completion(clauseSelector).
|
||||
iii. Let found be the result of performing Strict Equality Comparison
|
||||
input === clauseSelector.[[value]].
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
iii. If R is an abrupt completion, return Completion(UpdateEmpty(R,
|
||||
V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; switch ("a") { case "a": break; }'), undefined);
|
||||
assert.sameValue(eval('2; switch ("a") { case "a": { 3; break; } }'), 3);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; do { switch ("a") { case "a": continue; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { switch ("a") { case "a": { 6; continue; } } } while (false)'),
|
||||
6
|
||||
);
|
|
@ -0,0 +1,65 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with an empty abrupt completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the List of CaseClause items in CaseClauses, in source text
|
||||
order.
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A,
|
||||
a. If found is false, then
|
||||
[...]
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
iii. If R is an abrupt completion, return Completion(UpdateEmpty(R,
|
||||
V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; case "b": 3; break; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": case "b": 5; break; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; case "b": break; }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { switch ("a") { case "a": 9; case "b": 10; continue; } } while (false)'),
|
||||
10,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('11; do { switch ("a") { case "a": case "b": 12; continue; } } while (false)'),
|
||||
12,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('13; do { switch ("a") { case "a": 14; case "b": continue; } } while (false)'),
|
||||
14,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,49 @@
|
|||
// 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.12.11
|
||||
description: >
|
||||
Completion value when execution continues through multiple cases and ends
|
||||
with a normal completion
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the List of CaseClause items in CaseClauses, in source text
|
||||
order.
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A,
|
||||
a. If found is false, then
|
||||
[...]
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
[...]
|
||||
5. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": 2; case "b": 3; }'),
|
||||
3,
|
||||
'Non-empty value replaces previous non-empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("a") { case "a": case "b": 5; }'),
|
||||
5,
|
||||
'Non-empty value replaces empty value'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; switch ("a") { case "a": 7; case "b": }'),
|
||||
7,
|
||||
'Empty value does not replace previous non-empty value'
|
||||
);
|
|
@ -0,0 +1,70 @@
|
|||
// 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.12.11
|
||||
description: Completion value when only the final case matches
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the List of CaseClause items in CaseClauses, in source text
|
||||
order.
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A,
|
||||
a. If found is false, then
|
||||
i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
ii. If clauseSelector is an abrupt completion, then
|
||||
1. If clauseSelector.[[value]] is empty, return
|
||||
Completion{[[type]]: clauseSelector.[[type]], [[value]]:
|
||||
undefined, [[target]]: clauseSelector.[[target]]}.
|
||||
2. Else, return Completion(clauseSelector).
|
||||
iii. Let found be the result of performing Strict Equality Comparison
|
||||
input === clauseSelector.[[value]].
|
||||
b. If found is true, then
|
||||
i. Let R be the result of evaluating C.
|
||||
ii. If R.[[value]] is not empty, let V = R.[[value]].
|
||||
iii. If R is an abrupt completion, return Completion(UpdateEmpty(R,
|
||||
V)).
|
||||
5. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case "a": }'),
|
||||
undefined,
|
||||
'empty StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { case "a": 3; }'),
|
||||
3,
|
||||
'non-empy StatementList (lone case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; switch ("b") { case "a": case "b": }'),
|
||||
undefined,
|
||||
'empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; switch ("b") { case "a": case "b": 6; }'),
|
||||
6,
|
||||
'non-empty StatementList (following an empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('7; switch ("b") { case "a": 8; case "b": }'),
|
||||
undefined,
|
||||
'empty StatementList (following a non-empty case)'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('9; switch ("b") { case "a": 10; case "b": 11; }'),
|
||||
11,
|
||||
'non-empty StatementList (following a non-empty case)'
|
||||
);
|
|
@ -0,0 +1,42 @@
|
|||
// 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.12.11
|
||||
description: Completion value when no cases match
|
||||
info: >
|
||||
SwitchStatement : switch ( Expression ) CaseBlock
|
||||
|
||||
[...]
|
||||
8. Let R be the result of performing CaseBlockEvaluation of CaseBlock with
|
||||
argument switchValue.
|
||||
9. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
10. Return R.
|
||||
|
||||
13.12.9 Runtime Semantics: CaseBlockEvaluation
|
||||
|
||||
CaseBlock : { CaseClauses }
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Let A be the List of CaseClause items in CaseClauses, in source text
|
||||
order.
|
||||
3. Let found be false.
|
||||
4. Repeat for each CaseClause C in A,
|
||||
a. If found is false, then
|
||||
i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
ii. If clauseSelector is an abrupt completion, then
|
||||
[...]
|
||||
iii. Let found be the result of performing Strict Equality Comparison
|
||||
input === clauseSelector.[[value]].
|
||||
b. If found is true, then
|
||||
[...]
|
||||
5. Return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; switch ("a") { case null: }'), undefined, 'empty StatementList'
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; switch ("a") { case null: 3; }'),
|
||||
undefined,
|
||||
'non-empty StatementList'
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 13.15.8
|
||||
description: Completion value from `catch` clause of a try..catch statement
|
||||
info: >
|
||||
TryStatement : try Block Catch
|
||||
|
||||
1. Let B be the result of evaluating Block.
|
||||
2. If B.[[type]] is throw, then
|
||||
a. Let C be CatchClauseEvaluation of Catch with parameter B.[[value]].
|
||||
3. Else B.[[type]] is not throw,
|
||||
[...]
|
||||
4. If C.[[type]] is return, or C.[[type]] is throw, return Completion(C).
|
||||
5. If C.[[value]] is not empty, return Completion(C).
|
||||
6. Return Completion{[[type]]: C.[[type]], [[value]]: undefined,
|
||||
[[target]]: C.[[target]]}.
|
||||
|
||||
13.15.7 Runtime Semantics: CatchClauseEvaluation
|
||||
|
||||
Catch : catch ( CatchParameter ) Block
|
||||
|
||||
[...]
|
||||
7. Let B be the result of evaluating Block.
|
||||
8. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
9. Return Completion(B).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; try { throw null; } catch (err) { }'), undefined);
|
||||
assert.sameValue(eval('2; try { throw null; } catch (err) { 3; }'), 3);
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 13.15.8
|
||||
description: >
|
||||
Completion value from `finally` clause of a try..catch..finally statement
|
||||
(following execution of `catch` block)
|
||||
info: >
|
||||
TryStatement : try Block Catch Finally
|
||||
|
||||
1. Let B be the result of evaluating Block.
|
||||
2. If B.[[type]] is throw, then
|
||||
a. Let C be CatchClauseEvaluation of Catch with parameter B.[[value]].
|
||||
[...]
|
||||
4. Let F be the result of evaluating Finally.
|
||||
5. If F.[[type]] is normal, let F be C.
|
||||
6. If F.[[type]] is return, or F.[[type]] is throw, return Completion(F).
|
||||
7. If F.[[value]] is not empty, return NormalCompletion(F.[[value]]).
|
||||
8. Return Completion{[[type]]: F.[[type]], [[value]]: undefined,
|
||||
[[target]]: F.[[target]]}.
|
||||
|
||||
13.15.7 Runtime Semantics: CatchClauseEvaluation
|
||||
|
||||
Catch : catch ( CatchParameter ) Block
|
||||
|
||||
[...]
|
||||
7. Let B be the result of evaluating Block.
|
||||
8. Set the running execution context’s LexicalEnvironment to oldEnv.
|
||||
9. Return Completion(B).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; try { throw null; } catch (err) { } finally { }'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('2; try { throw null; } catch (err) { 3; } finally { }'), 3
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('4; try { throw null; } catch (err) { } finally { 5; }'), undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('6; try { throw null; } catch (err) { 7; } finally { 8; }'), 7
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 13.15.8
|
||||
description: >
|
||||
Completion value from `finally` clause of a try..catch..finally statement
|
||||
(when `catch` block is not executed)
|
||||
info: >
|
||||
TryStatement : try Block Catch Finally
|
||||
|
||||
1. Let B be the result of evaluating Block.
|
||||
2. If B.[[type]] is throw, then
|
||||
[...]
|
||||
3. Else B.[[type]] is not throw, let C be B.
|
||||
4. Let F be the result of evaluating Finally.
|
||||
5. If F.[[type]] is normal, let F be C.
|
||||
6. If F.[[type]] is return, or F.[[type]] is throw, return Completion(F).
|
||||
7. If F.[[value]] is not empty, return NormalCompletion(F.[[value]]).
|
||||
8. Return Completion{[[type]]: F.[[type]], [[value]]: undefined,
|
||||
[[target]]: F.[[target]]}.
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; try { } catch (err) { } finally { }'), undefined);
|
||||
assert.sameValue(eval('2; try { } catch (err) { 3; } finally { }'), undefined);
|
||||
assert.sameValue(eval('4; try { } catch (err) { } finally { 5; }'), undefined);
|
||||
assert.sameValue(eval('6; try { } catch (err) { 7; } finally { 8; }'), undefined);
|
||||
assert.sameValue(eval('9; try { 10; } catch (err) { } finally { }'), 10);
|
||||
assert.sameValue(eval('11; try { 12; } catch (err) { 13; } finally { }'), 12);
|
||||
assert.sameValue(eval('14; try { 15; } catch (err) { } finally { 16; }'), 15);
|
||||
assert.sameValue(eval('17; try { 18; } catch (err) { 19; } finally { 20; }'), 18);
|
|
@ -0,0 +1,22 @@
|
|||
// 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.15.8
|
||||
description: Completion value from `finally` clause of a try..finally statement
|
||||
info: >
|
||||
TryStatement : try Block Finally
|
||||
|
||||
1. Let B be the result of evaluating Block.
|
||||
2. Let F be the result of evaluating Finally.
|
||||
3. If F.[[type]] is normal, let F be B.
|
||||
4. If F.[[type]] is return, or F.[[type]] is throw, return Completion(F).
|
||||
5. If F.[[value]] is not empty, return Completion(F).
|
||||
6. Return Completion{[[type]]: F.[[type]], [[value]]: undefined,
|
||||
[[target]]: F.[[target]]}.
|
||||
---*/
|
||||
|
||||
|
||||
assert.sameValue(eval('1; try { } finally { }'), undefined);
|
||||
assert.sameValue(eval('2; try { 3; } finally { }'), 3);
|
||||
assert.sameValue(eval('4; try { } finally { 5; }'), undefined);
|
||||
assert.sameValue(eval('6; try { 7; } finally { 8; }'), 7);
|
|
@ -0,0 +1,23 @@
|
|||
// 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.15.8
|
||||
description: Completion value from `try` clause of a try..catch statement
|
||||
info: >
|
||||
TryStatement : try Block Catch
|
||||
|
||||
1. Let B be the result of evaluating Block.
|
||||
2. If B.[[type]] is throw, then
|
||||
[...]
|
||||
3. Else B.[[type]] is not throw,
|
||||
a. Let C be B.
|
||||
4. If C.[[type]] is return, or C.[[type]] is throw, return Completion(C).
|
||||
5. If C.[[value]] is not empty, return Completion(C).
|
||||
6. Return Completion{[[type]]: C.[[type]], [[value]]: undefined,
|
||||
[[target]]: C.[[target]]}.
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; try { } catch (err) { }'), undefined);
|
||||
assert.sameValue(eval('2; try { 3; } catch (err) { }'), 3);
|
||||
assert.sameValue(eval('4; try { } catch (err) { 5; }'), undefined);
|
||||
assert.sameValue(eval('6; try { 7; } catch (err) { 8; }'), 7);
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 13.7.3.6
|
||||
description: >
|
||||
Completion value when iteration completes due to an empty abrupt completion
|
||||
info: >
|
||||
IterationStatement : while ( Expression ) Statement
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Repeat
|
||||
a. Let exprRef be the result of evaluating Expression.
|
||||
b. Let exprValue be GetValue(exprRef).
|
||||
c. ReturnIfAbrupt(exprValue).
|
||||
d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
|
||||
e. Let stmt be the result of evaluating Statement.
|
||||
f. If LoopContinues (stmt, labelSet) is false, return
|
||||
Completion(UpdateEmpty(stmt, V)).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; while (true) { break; }'), undefined);
|
||||
assert.sameValue(eval('2; while (true) { 3; break; }'), 3);
|
||||
|
||||
assert.sameValue(
|
||||
eval('4; outer: do { while (true) { continue outer; } } while (false)'),
|
||||
undefined
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; outer: do { while (true) { 6; continue outer; } } while (false)'), 6
|
||||
);
|
|
@ -0,0 +1,23 @@
|
|||
// 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.3.6
|
||||
description: >
|
||||
Completion value when iteration completes due to expression value
|
||||
info: >
|
||||
IterationStatement : while ( Expression ) Statement
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Repeat
|
||||
a. Let exprRef be the result of evaluating Expression.
|
||||
b. Let exprValue be GetValue(exprRef).
|
||||
c. ReturnIfAbrupt(exprValue).
|
||||
d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
|
||||
e. Let stmt be the result of evaluating Statement.
|
||||
f. If LoopContinues (stmt, labelSet) is false, return
|
||||
Completion(UpdateEmpty(stmt, V)).
|
||||
g. If stmt.[[value]] is not empty, let V = stmt.[[value]].
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('var count1 = 2; 1; while (count1 -= 1) { }'), undefined);
|
||||
assert.sameValue(eval('var count2 = 2; 2; while (count2 -= 1) { 3; }'), 3);
|
|
@ -0,0 +1,19 @@
|
|||
// 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.3.6
|
||||
description: >
|
||||
Completion value when no iteration occurs
|
||||
info: >
|
||||
IterationStatement : while ( Expression ) Statement
|
||||
|
||||
1. Let V = undefined.
|
||||
2. Repeat
|
||||
a. Let exprRef be the result of evaluating Expression.
|
||||
b. Let exprValue be GetValue(exprRef).
|
||||
c. ReturnIfAbrupt(exprValue).
|
||||
d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; while (false) { }'), undefined);
|
||||
assert.sameValue(eval('2; while (false) { 3; }'), undefined);
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es7id: pending
|
||||
description: >
|
||||
Statement completion value when body returns an empty abrupt completion
|
||||
info: >
|
||||
WithStatement : with ( Expression ) Statement
|
||||
|
||||
[...]
|
||||
7. Let C be the result of evaluating Statement.
|
||||
8. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
9. Return Completion(UpdateEmpty(C, undefined)).
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
eval('1; do { 2; with({}) { 3; break; } 4; } while (false);'), 3
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('5; do { 6; with({}) { break; } 7; } while (false);'), undefined
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
eval('8; do { 9; with({}) { 10; continue; } 11; } while (false)'), 10
|
||||
);
|
||||
assert.sameValue(
|
||||
eval('12; do { 13; with({}) { continue; } 14; } while (false)'), undefined
|
||||
);
|
|
@ -0,0 +1,19 @@
|
|||
// 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.11.7
|
||||
description: Statement completion value when body returns a normal completion
|
||||
info: >
|
||||
WithStatement : with ( Expression ) Statement
|
||||
|
||||
[...]
|
||||
8. Let C be the result of evaluating Statement.
|
||||
9. Set the running execution context’s Lexical Environment to oldEnv.
|
||||
10. If C.[[type]] is normal and C.[[value]] is empty, return
|
||||
NormalCompletion(undefined).
|
||||
11. Return Completion(C).
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
assert.sameValue(eval('1; with({}) { }'), undefined);
|
||||
assert.sameValue(eval('2; with({}) { 3; }'), 3);
|
Loading…
Reference in New Issue