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