completion-values.js (2187B)
1 // Copyright (C) 2020 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-try-statement-runtime-semantics-evaluation 5 description: > 6 Direct eval try/catch/finally for completion value 7 info: | 8 TryStatement : try Block Catch Finally 9 10 Let B be the result of evaluating Block. 11 If B.[[Type]] is throw, let C be CatchClauseEvaluation of Catch with argument B.[[Value]]. 12 Else, let C be B. 13 Let F be the result of evaluating Finally. 14 If F.[[Type]] is normal, set F to C. 15 Return Completion(UpdateEmpty(F, undefined)). 16 ---*/ 17 18 assert.sameValue( 19 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { 42; break; -2 }; } while (false);'), 20 42 21 ); 22 assert.sameValue( 23 eval('99; do { -99; try { [].x.x } catch (e) { -1; } finally { 42; break; -3 }; } while (false);'), 24 42 25 ); 26 assert.sameValue( 27 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { break; -2 }; } while (false);'), 28 undefined 29 ); 30 assert.sameValue( 31 eval('99; do { -99; try { [].x.x } catch (e) { -1; } finally { break; -3 }; } while (false);'), 32 undefined 33 ); 34 assert.sameValue( 35 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { 42; break; -3 }; -77 } while (false);'), 36 42 37 ); 38 assert.sameValue( 39 eval('99; do { -99; try { [].x.x } catch (e) { -1; } finally { 42; break; -3 }; -77 } while (false);'), 40 42 41 ); 42 assert.sameValue( 43 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { break; -3 }; -77 } while (false);'), 44 undefined 45 ); 46 assert.sameValue( 47 eval('99; do { -99; try { [].x.x } catch (e) { -1; } finally { break; -3 }; -77 } while (false);'), 48 undefined 49 ); 50 assert.sameValue( 51 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { 42; continue; -3 }; } while (false);'), 52 42 53 ); 54 assert.sameValue( 55 eval('99; do { -99; try { [].x.x } catch (e) { -1; } finally { 42; continue; -3 }; } while (false);'), 56 42 57 ); 58 assert.sameValue( 59 eval('99; do { -99; try { 39 } catch (e) { -1 } finally { 42; continue; -3 }; -77 } while (false);'), 60 42 61 ); 62 assert.sameValue( 63 eval('99; do { -99; try { [].x.x } catch (e) { -1 } finally { 42; continue; -3 }; -77 } while (false);'), 64 42 65 ); 66 67 reportCompare(0, 0);