OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Dart test program for testing throw expressions. | 5 // Dart test program for testing throw expressions. |
6 | 6 |
7 void test1() { | 7 void test1() { |
8 var x = 6; | 8 var x = 6; |
9 try { | 9 try { |
10 throw x = 10; | 10 throw x = 10; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 bar(x, y) => throw "foo" "${throw x}"; | 44 bar(x, y) => throw "foo" "${throw x}"; |
45 | 45 |
46 class Q { | 46 class Q { |
47 var qqq; | 47 var qqq; |
48 f(x) { qqq = x; } | 48 f(x) { qqq = x; } |
49 } | 49 } |
50 | 50 |
51 void test3() { | 51 void test3() { |
52 try { | 52 try { |
53 throw throw throw "throw"; | 53 throw throw throw "up"; |
54 } catch(e) { | 54 } catch(e) { |
55 Expect.equals("throw", e); | 55 Expect.equals("up", e); |
56 } | 56 } |
57 | 57 |
58 var x = 10; | 58 var x = 10; |
59 try { | 59 try { |
60 foo(x = 12, throw 7); | 60 foo(x = 12, throw 7); |
61 } catch(e) { | 61 } catch(e) { |
62 Expect.equals(7, e); | 62 Expect.equals(7, e); |
63 Expect.equals(12, x); | 63 Expect.equals(12, x); |
64 } | 64 } |
65 | 65 |
(...skipping 21 matching lines...) Expand all Loading... |
87 Expect.equals(77, e); | 87 Expect.equals(77, e); |
88 Expect.equals(11, x.qqq); | 88 Expect.equals(11, x.qqq); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 main() { | 92 main() { |
93 test1(); | 93 test1(); |
94 test2(); | 94 test2(); |
95 test3(); | 95 test3(); |
96 } | 96 } |
OLD | NEW |