cptn-finally-from-catch.js (1526B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 13.15.8 5 description: > 6 Completion value from `finally` clause of a try..catch..finally statement 7 (following execution of `catch` block) 8 info: | 9 TryStatement : try Block Catch Finally 10 11 1. Let B be the result of evaluating Block. 12 2. If B.[[type]] is throw, then 13 a. Let C be CatchClauseEvaluation of Catch with parameter B.[[value]]. 14 [...] 15 4. Let F be the result of evaluating Finally. 16 5. If F.[[type]] is normal, let F be C. 17 6. If F.[[type]] is return, or F.[[type]] is throw, return Completion(F). 18 7. If F.[[value]] is not empty, return NormalCompletion(F.[[value]]). 19 8. Return Completion{[[type]]: F.[[type]], [[value]]: undefined, 20 [[target]]: F.[[target]]}. 21 22 13.15.7 Runtime Semantics: CatchClauseEvaluation 23 24 Catch : catch ( CatchParameter ) Block 25 26 [...] 27 7. Let B be the result of evaluating Block. 28 8. Set the running execution context’s LexicalEnvironment to oldEnv. 29 9. Return Completion(B). 30 ---*/ 31 32 assert.sameValue( 33 eval('1; try { throw null; } catch (err) { } finally { }'), undefined 34 ); 35 assert.sameValue( 36 eval('2; try { throw null; } catch (err) { 3; } finally { }'), 3 37 ); 38 assert.sameValue( 39 eval('4; try { throw null; } catch (err) { } finally { 5; }'), undefined 40 ); 41 assert.sameValue( 42 eval('6; try { throw null; } catch (err) { 7; } finally { 8; }'), 7 43 ); 44 45 reportCompare(0, 0);