Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/catchguard-003.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-003.js';
8
9 test();
10
11 function test()
12 {
13 enterFunc ("test");
14
15 var EXCEPTION_DATA = "String exception";
16 var e = "foo", x = "foo";
17 var caught = false;
18
19 printStatus ("Catchguard 'Common Scope' test.");
20
21 try
22 {
23 throw EXCEPTION_DATA;
24 }
25 catch (e if ((x = 1) && false))
26 {
27 reportCompare('PASS', 'FAIL',
28 "Catch block (e if ((x = 1) && false) should not " +
29 "have executed.");
30 }
31 catch (e if (x == 1))
32 {
33 caught = true;
34 }
35 catch (e)
36 {
37 reportCompare('PASS', 'FAIL',
38 "Same scope should be used across all catchguards.");
39 }
40
41 if (!caught)
42 reportCompare('PASS', 'FAIL',
43 "Exception was never caught.");
44
45 if (e != "foo")
46 reportCompare('PASS', 'FAIL',
47 "Exception data modified inside catch() scope should " +
48 "not be visible in the function scope (e ='" +
49 e + "'.)");
50
51 if (x != 1)
52 reportCompare('PASS', 'FAIL',
53 "Data modified in 'catchguard expression' should " +
54 "be visible in the function scope (x = '" +
55 x + "'.)");
56
57 reportCompare('PASS', 'PASS', 'Catchguard Common Scope test');
58
59 exitFunc ("test");
60 }