OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of malformed_test; | 5 part of malformed_test; |
6 | 6 |
7 /// [o] is either `null` or `new List<String>()`. | 7 /// [o] is either `null` or `new List<String>()`. |
8 void testValue(var o) { | 8 void testValue(var o) { |
9 assert(o == null || o is List<String>); | 9 assert(o == null || o is List<String>); |
10 | 10 |
11 test(true, () => o is Unresolved, "$o is Unresolved"); | 11 test(true, () => o is Unresolved, "$o is Unresolved"); |
12 test(false, () => o is List<Unresolved>, "$o is List<Unresolved>"); | 12 test(false, () => o is List<Unresolved>, "$o is List<Unresolved>"); |
13 test(true, () => o is! Unresolved, "$o is! Unresolved"); | 13 test(true, () => o is! Unresolved, "$o is! Unresolved"); |
14 test(false, () => o is! List<Unresolved>, "$o is List<Unresolved>"); | 14 test(false, () => o is! List<Unresolved>, "$o is List<Unresolved>"); |
15 | 15 |
16 test(true, () => o as Unresolved, "$o as Unresolved"); | 16 test(true, () => o as Unresolved, "$o as Unresolved"); |
17 test(false, () => o as List<Unresolved>, "$o as List<Unresolved>"); | 17 test(false, () => o as List<Unresolved>, "$o as List<Unresolved>"); |
18 | 18 |
19 test(false, () { | 19 test(false, () { |
20 try { | 20 try {} on Unresolved catch (e) {} catch (e) {} |
21 } on Unresolved catch (e) { | |
22 } catch (e) { | |
23 } | |
24 }, "on Unresolved catch: Nothing thrown."); | 21 }, "on Unresolved catch: Nothing thrown."); |
25 test(true, () { | 22 test(true, () { |
26 try { | 23 try { |
27 throw o; | 24 throw o; |
28 } on Unresolved catch (e) { | 25 } on Unresolved catch (e) {} catch (e) {} |
29 } catch (e) { | |
30 } | |
31 }, "on Unresolved catch ($o)"); | 26 }, "on Unresolved catch ($o)"); |
32 test(false, () { | 27 test(false, () { |
33 try { | 28 try { |
34 throw o; | 29 throw o; |
35 } on List<String> catch (e) { | 30 } on List< |
36 } on NullThrownError catch (e) { | 31 String> catch (e) {} on NullThrownError catch (e) {} on Unresolved catch
(e) {} catch (e) {} |
37 } on Unresolved catch (e) { | |
38 } catch (e) { | |
39 } | |
40 }, "on List<String>/NullThrowError catch ($o)"); | 32 }, "on List<String>/NullThrowError catch ($o)"); |
41 test(false, () { | 33 test(false, () { |
42 try { | 34 try { |
43 throw o; | 35 throw o; |
44 } on List<Unresolved> catch (e) { | 36 } on List< |
45 } on NullThrownError catch (e) { | 37 Unresolved> catch (e) {} on NullThrownError catch (e) {} on Unresolved c
atch (e) {} catch (e) {} |
46 } on Unresolved catch (e) { | |
47 } catch (e) { | |
48 } | |
49 }, "on List<Unresolved>/NullThrowError catch ($o)"); | 38 }, "on List<Unresolved>/NullThrowError catch ($o)"); |
50 | 39 |
51 test(o != null && inCheckedMode(), | 40 test(o != null && inCheckedMode(), () { |
52 () { Unresolved u = o; }, | 41 Unresolved u = o; |
53 "Unresolved u = $o;"); | 42 }, "Unresolved u = $o;"); |
54 test(false, | 43 test(false, () { |
55 () { List<Unresolved> u = o; }, | 44 List<Unresolved> u = o; |
56 "List<Unresolved> u = $o;"); | 45 }, "List<Unresolved> u = $o;"); |
57 } | 46 } |
OLD | NEW |