Debian Codegraph @

js/src/tests/test262/language/statements/try/optional-catch-binding-lexical.js

raw
1 // Copyright (C) 2017 Lucas Azzola. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 author: Lucas Azzola
6 esid: pending
7 description: lexical environment runtime semantics for optional catch binding
8 features: [optional-catch-binding]
9 info: |
10 Runtime Semantics: CatchClauseEvaluation
11
12 Catch : catch Block
13 Let oldEnv be the running execution context's LexicalEnvironment.
14 Let catchEnv be NewDeclarativeEnvironment(oldEnv).
15 Set the running execution context's LexicalEnvironment to catchEnv.
16 (...)
17 Set the running execution context's LexicalEnvironment to oldEnv.
18 Return Completion(B).
19 ---*/
20
21 let x = 1;
22 let ranCatch = false;
23
24 try {
25 x = 2;
26 throw new Error();
27 } catch {
28 let x = 3;
29 let y = true;
30 ranCatch = true;
31 }
32
33 assert(ranCatch, 'executed `catch` block');
34 assert.sameValue(x, 2);
35
36 assert.throws(ReferenceError, function() {
37 y;
38 });
39
40 reportCompare(0, 0);