| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // Dart test program for testing throw expressions. | 7 // Dart test program for testing throw expressions. |
| 8 | 8 |
| 9 void test1() { | 9 void test1() { |
| 10 var x = 6; | 10 var x = 6; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Expect.equals(15, x); | 41 Expect.equals(15, x); |
| 42 } | 42 } |
| 43 | 43 |
| 44 foo(x, y) => throw "foo" "$x"; | 44 foo(x, y) => throw "foo" "$x"; |
| 45 | 45 |
| 46 bar(x, y) => throw "foo" "${throw x}"; | 46 bar(x, y) => throw "foo" "${throw x}"; |
| 47 | 47 |
| 48 class Q { | 48 class Q { |
| 49 var qqq; | 49 var qqq; |
| 50 f(x) { qqq = x; } | 50 f(x) { qqq = x; } |
| 51 Q get nono => throw "nono"; |
| 51 } | 52 } |
| 52 | 53 |
| 53 void test3() { | 54 void test3() { |
| 54 try { | 55 try { |
| 55 throw throw throw "up"; | 56 throw throw throw "up"; |
| 56 } catch(e) { | 57 } catch(e) { |
| 57 Expect.equals("up", e); | 58 Expect.equals("up", e); |
| 58 } | 59 } |
| 59 | 60 |
| 60 var x = 10; | 61 var x = 10; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 x = null; | 85 x = null; |
| 85 try { | 86 try { |
| 86 x = new Q(); | 87 x = new Q(); |
| 87 x..f(11) ..qqq = throw 77 ..f(22); | 88 x..f(11) ..qqq = throw 77 ..f(22); |
| 88 } catch(e) { | 89 } catch(e) { |
| 89 Expect.equals(77, e); | 90 Expect.equals(77, e); |
| 90 Expect.equals(11, x.qqq); | 91 Expect.equals(11, x.qqq); |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 | 94 |
| 95 void test4() { |
| 96 var q = new Q(); |
| 97 Expect.throws(() => q.nono, (e) => e == "nono"); |
| 98 } |
| 99 |
| 94 main() { | 100 main() { |
| 95 test1(); | 101 test1(); |
| 96 test2(); | 102 test2(); |
| 97 test3(); | 103 test3(); |
| 104 test4(); |
| 98 } | 105 } |
| OLD | NEW |