| 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 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test 'expression as Type' casts. | 8 // Test 'expression as Type' casts. |
| 9 | 9 |
| 10 class C { | 10 class C { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 Expect.equals(42, (oc as C).foo); | 33 Expect.equals(42, (oc as C).foo); |
| 34 Expect.equals(42, (od as C).foo); | 34 Expect.equals(42, (od as C).foo); |
| 35 Expect.equals(42, (od as D).foo); | 35 Expect.equals(42, (od as D).foo); |
| 36 Expect.equals(37, (od as D).bar); | 36 Expect.equals(37, (od as D).bar); |
| 37 Expect.equals(37, ((od as C) as D).bar); | 37 Expect.equals(37, ((od as C) as D).bar); |
| 38 (oc as D).foo; // //# 01: runtime error | 38 (oc as D).foo; // //# 01: runtime error |
| 39 (on as D).toString(); | 39 (on as D).toString(); |
| 40 (on as D).foo; // //# 02: runtime error | 40 (on as D).foo; // //# 02: runtime error |
| 41 (on as C).foo; // //# 03: runtime error | 41 (on as C).foo; // //# 03: runtime error |
| 42 oc.foo; // //# 04: static type warning | 42 oc.foo; // //# 04: compile-time error |
| 43 od.foo; // //# 05: static type warning | 43 od.foo; // //# 05: compile-time error |
| 44 (on as Object).toString(); | 44 (on as Object).toString(); |
| 45 (oc as Object).toString(); | 45 (oc as Object).toString(); |
| 46 (od as Object).toString(); | 46 (od as Object).toString(); |
| 47 (on as dynamic).toString(); | 47 (on as dynamic).toString(); |
| 48 (on as dynamic).foo; // //# 07: runtime error | 48 (on as dynamic).foo; // //# 07: runtime error |
| 49 (oc as dynamic).foo; | 49 (oc as dynamic).foo; |
| 50 (od as dynamic).foo; | 50 (od as dynamic).foo; |
| 51 (oc as dynamic).bar; // //# 08: runtime error | 51 (oc as dynamic).bar; // //# 08: runtime error |
| 52 (od as dynamic).bar; | 52 (od as dynamic).bar; |
| 53 C c = oc as C; | 53 C c = oc as C; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 (ol as List<int>)[0] = (oi as int); | 65 (ol as List<int>)[0] = (oi as int); |
| 66 | 66 |
| 67 (os as String).length; | 67 (os as String).length; |
| 68 (os as dynamic).length; | 68 (os as dynamic).length; |
| 69 (oi as String).length; // //# 13: runtime error | 69 (oi as String).length; // //# 13: runtime error |
| 70 (os as List).length; // //# 14: runtime error | 70 (os as List).length; // //# 14: runtime error |
| 71 | 71 |
| 72 (oi as int) + 2; | 72 (oi as int) + 2; |
| 73 (oi as List).length; // //# 15: runtime error | 73 (oi as List).length; // //# 15: runtime error |
| 74 } | 74 } |
| OLD | NEW |