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 // Dart test program for constructors and initializers. | 4 // Dart test program for constructors and initializers. |
5 | 5 |
6 // Test 'expression as Type' casts. | 6 // Test 'expression as Type' casts. |
7 | 7 |
8 class C { | 8 class C { |
9 final int foo = 42; | 9 final int foo = 42; |
10 } | 10 } |
(...skipping 24 matching lines...) Expand all Loading... |
35 Expect.equals(37, ((od as C) as D).bar); | 35 Expect.equals(37, ((od as C) as D).bar); |
36 (oc as D).foo; /// 01: runtime error | 36 (oc as D).foo; /// 01: runtime error |
37 (on as D).toString(); | 37 (on as D).toString(); |
38 (on as D).foo; /// 02: runtime error | 38 (on as D).foo; /// 02: runtime error |
39 (on as C).foo; /// 03: runtime error | 39 (on as C).foo; /// 03: runtime error |
40 oc.foo; /// 04: static type warning | 40 oc.foo; /// 04: static type warning |
41 od.foo; /// 05: static type warning | 41 od.foo; /// 05: static type warning |
42 (on as Object).toString(); | 42 (on as Object).toString(); |
43 (oc as Object).toString(); | 43 (oc as Object).toString(); |
44 (od as Object).toString(); | 44 (od as Object).toString(); |
45 (on as Dynamic).toString(); | 45 (on as dynamic).toString(); |
46 (on as Dynamic).foo; /// 07: runtime error | 46 (on as dynamic).foo; /// 07: runtime error |
47 (oc as Dynamic).foo; | 47 (oc as dynamic).foo; |
48 (od as Dynamic).foo; | 48 (od as dynamic).foo; |
49 (oc as Dynamic).bar; /// 08: runtime error | 49 (oc as dynamic).bar; /// 08: runtime error |
50 (od as Dynamic).bar; | 50 (od as dynamic).bar; |
51 C c = oc as C; | 51 C c = oc as C; |
52 c = od as C; | 52 c = od as C; |
53 c = oc; | 53 c = oc; |
54 D d = od as D; | 54 D d = od as D; |
55 d = oc as D; /// 10: runtime error | 55 d = oc as D; /// 10: runtime error |
56 d = od; | 56 d = od; |
57 | 57 |
58 (ol as List)[0]; | 58 (ol as List)[0]; |
59 (ol as List<int>)[0]; | 59 (ol as List<int>)[0]; |
60 (ol as Dynamic)[0]; | 60 (ol as dynamic)[0]; |
61 (ol as String).length; /// 12: runtime error | 61 (ol as String).length; /// 12: runtime error |
62 int x = (ol as List<int>)[0]; | 62 int x = (ol as List<int>)[0]; |
63 (ol as List<int>)[0] = (oi as int); | 63 (ol as List<int>)[0] = (oi as int); |
64 | 64 |
65 (os as String).length; | 65 (os as String).length; |
66 (os as Dynamic).length; | 66 (os as dynamic).length; |
67 (oi as String).length; /// 13: runtime error | 67 (oi as String).length; /// 13: runtime error |
68 (os as List).length; /// 14: runtime error | 68 (os as List).length; /// 14: runtime error |
69 | 69 |
70 (oi as int) + 2; | 70 (oi as int) + 2; |
71 (oi as List).length; /// 15: runtime error | 71 (oi as List).length; /// 15: runtime error |
72 } | 72 } |
73 | 73 |
74 | 74 |
OLD | NEW |