From e62d43c8154b1d9687c678d026187a954312ce43 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 21 Jan 2016 19:15:07 -0500 Subject: [PATCH] Update tests according to ES2016 draft semantics The ES2016 draft further refines the completion values for `if` and `with` statements. Two tests must be removed outright because the completion value in those cases is no longer accessible from the runtime. --- .../statements/for/cptn-decl-abrupt-empty.js | 45 -------------- .../statements/for/cptn-expr-abrupt-empty.js | 59 ------------------- .../if/cptn-else-false-abrupt-empty.js | 20 +++---- .../if/cptn-else-true-abrupt-empty.js | 18 +++--- .../if/cptn-no-else-true-abrupt-empty.js | 13 ++-- .../statements/with/cptn-abrupt-empty.js | 13 ++-- 6 files changed, 32 insertions(+), 136 deletions(-) delete mode 100644 test/language/statements/for/cptn-decl-abrupt-empty.js delete mode 100644 test/language/statements/for/cptn-expr-abrupt-empty.js diff --git a/test/language/statements/for/cptn-decl-abrupt-empty.js b/test/language/statements/for/cptn-decl-abrupt-empty.js deleted file mode 100644 index e3830d5681..0000000000 --- a/test/language/statements/for/cptn-decl-abrupt-empty.js +++ /dev/null @@ -1,45 +0,0 @@ -// 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 but no "test" expression -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 - [...] - b. Let result be the result of evaluating stmt. - c. If LoopContinues(result, labelSet) is false, return - Completion(UpdateEmpty(result, V)). - - 13.9.3 Runtime Semantics: Evaluation - - BreakStatement : break ; - - 1. Return Completion{[[type]]: break, [[value]]: empty, [[target]]: empty}. ----*/ - -assert.sameValue(eval('1; for (var run = true; ; ) { break; }'), undefined); -assert.sameValue( - eval('2; for (var first = true; ; ) { if (!first) { break; } first = false; 3; }'), - 3, - 'Updating an empty completion from a prior iteration.' -); - -assert.sameValue(eval('4; outer: do { for (var run = true; ; ) { continue outer; } } while (false)'), undefined); -assert.sameValue( - eval('5; outer: do { for (var first = true; ; ) { if (!first) { continue outer; } first = false; 6; } } while (false)'), - 6, - 'Updating an empty completion from a prior iteration.' -); diff --git a/test/language/statements/for/cptn-expr-abrupt-empty.js b/test/language/statements/for/cptn-expr-abrupt-empty.js deleted file mode 100644 index b51cc62f79..0000000000 --- a/test/language/statements/for/cptn-expr-abrupt-empty.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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 no "test" expression -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 - [...] - b. Let result be the result of evaluating stmt. - c. If LoopContinues(result, labelSet) is false, return - Completion(UpdateEmpty(result, V)). - - 13.9.3 Runtime Semantics: Evaluation - - BreakStatement : break ; - - 1. Return Completion{[[type]]: break, [[value]]: empty, [[target]]: empty}. ----*/ - -assert.sameValue(eval('1; for ( ; ; ) { break; }'), undefined); -assert.sameValue(eval('2; for ( ; ; ) { 3; break; }'), 3); -assert.sameValue( - eval('var first = true; 4; for ( ; ; ) { if (!first) { 5; break; } first = false; }'), - 5, - 'Updating an empty completion from a prior iteration.' -); -assert.sameValue( - eval('var first = true; 6; for ( ; ; ) { if (!first) { break; } first = false; 7; }'), - 7, - 'Updating an empty completion from a prior iteration.' -); - -assert.sameValue(eval('8; outer: do { for ( ; ; ) { continue outer; } } while (false)'), undefined); -assert.sameValue(eval('9; outer: do { for ( ; ; ) { 10; continue outer; } } while (false)'), 10); -assert.sameValue( - eval('var first = true; 11; outer: do { for ( ; ; ) { if (!first) { 12; continue outer; } first = false; } } while (false)'), - 12, - 'Updating an empty completion from a prior iteration.' -); -assert.sameValue( - eval('var first = true; 13; outer: do { for ( ; ; ) { if (!first) { continue outer; } first = false; 14; } } while (false)'), - 14, - 'Updating an empty completion from a prior iteration.' -); diff --git a/test/language/statements/if/cptn-else-false-abrupt-empty.js b/test/language/statements/if/cptn-else-false-abrupt-empty.js index 6fb94344a7..4faeed9e5a 100644 --- a/test/language/statements/if/cptn-else-false-abrupt-empty.js +++ b/test/language/statements/if/cptn-else-false-abrupt-empty.js @@ -1,40 +1,40 @@ // 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 +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 - 4. If exprValue is true, then + 3. If exprValue is true, then [...] - 5. Else, + 4. 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). + 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)'), 3 + 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)'), 7 + 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)'), 11 + eval('10; do { 11; if (false) { } else { continue; } } while (false)'), + undefined ); assert.sameValue( eval('12; do { if (false) { 13; } else { continue; } } while (false)'), @@ -42,5 +42,5 @@ assert.sameValue( ); assert.sameValue( eval('14; do { 15; if (false) { 16; } else { continue; } } while (false)'), - 15 + undefined ); diff --git a/test/language/statements/if/cptn-else-true-abrupt-empty.js b/test/language/statements/if/cptn-else-true-abrupt-empty.js index 7c26d250c4..6417f5ff6a 100644 --- a/test/language/statements/if/cptn-else-true-abrupt-empty.js +++ b/test/language/statements/if/cptn-else-true-abrupt-empty.js @@ -1,42 +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. /*--- -es6id: 13.6.7 +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 - 4. If exprValue is true, then + 3. If exprValue is true, then a. Let stmtCompletion be the result of evaluating the first Statement. - 5. Else, + 4. Else, [...] - 6. ReturnIfAbrupt(stmtCompletion). + 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)'), 3 + 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)'), 7 + 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)'), 3 + 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)'), 7 + eval('6; do { 7; if (true) { continue; } else { 8; } } while (false)'), + undefined ); diff --git a/test/language/statements/if/cptn-no-else-true-abrupt-empty.js b/test/language/statements/if/cptn-no-else-true-abrupt-empty.js index 9d8471d0e8..90e4fc0454 100644 --- a/test/language/statements/if/cptn-no-else-true-abrupt-empty.js +++ b/test/language/statements/if/cptn-no-else-true-abrupt-empty.js @@ -1,31 +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.6.7 +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 - [...] - 4. If exprValue is false, then + 3. If exprValue is false, then [...] - 5. Else, + 4. Else, a. Let stmtCompletion be the result of evaluating Statement. - b. ReturnIfAbrupt(stmtCompletion). + 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)'), 6 + 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)'), 13 + eval('12; do { 13; if (true) { continue; } 14; } while (false)'), undefined ); diff --git a/test/language/statements/with/cptn-abrupt-empty.js b/test/language/statements/with/cptn-abrupt-empty.js index 739884f0db..f801a0a323 100644 --- a/test/language/statements/with/cptn-abrupt-empty.js +++ b/test/language/statements/with/cptn-abrupt-empty.js @@ -1,17 +1,16 @@ // 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 +es7id: pending description: > Statement completion value when body returns an empty abrupt 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). + 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] ---*/ @@ -19,12 +18,12 @@ assert.sameValue( eval('1; do { 2; with({}) { 3; break; } 4; } while (false);'), 3 ); assert.sameValue( - eval('5; do { 6; with({}) { break; } 7; } while (false);'), 6 + 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)'), 13 + eval('12; do { 13; with({}) { continue; } 14; } while (false)'), undefined ); -- GitLab