Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/catchguard-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 var gTestfile = 'catchguard-001.js';
8
9 test();
10
11 function test()
12 {
13 enterFunc ("test");
14
15 var EXCEPTION_DATA = "String exception";
16 var e = "foo";
17 var caught = false;
18
19 printStatus ("Basic catchguard test.");
20
21 try
22 {
23 throw EXCEPTION_DATA;
24 }
25 catch (e if true)
26 {
27 caught = true;
28 e = "this change should not propagate outside of this scope";
29 }
30 catch (e if false)
31 {
32 reportCompare('PASS', 'FAIL', "Catch block (e if false) should not have executed.");
33 }
34 catch (e)
35 {
36 reportCompare('PASS', 'FAIL', "Catch block (e) should not have executed.");
37 }
38
39 if (!caught)
40 reportCompare('PASS', 'FAIL', "Exception was never caught.");
41
42 if (e != "foo")
43 reportCompare('PASS', 'FAIL', "Exception data modified inside catch() scope should " +
44 "not be visible in the function scope (e = '" +
45 e + "'.)");
46
47 reportCompare('PASS', 'PASS', '');
48 exitFunc ("test");
49 }