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 testing setting/getting/initializing static fields. | 4 // Dart test program for testing setting/getting/initializing static fields. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class First { | 8 class First { |
9 First() {} | 9 First() {} |
10 static var a; | 10 static var a; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Expect.equals(15, First.a); | 58 Expect.equals(15, First.a); |
59 Expect.equals(15, First.b); | 59 Expect.equals(15, First.b); |
60 Expect.equals(35, First.setValues()); | 60 Expect.equals(35, First.setValues()); |
61 Expect.equals(24, First.a); | 61 Expect.equals(24, First.a); |
62 Expect.equals(10, First.b); | 62 Expect.equals(10, First.b); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 class StaticField1RunNegativeTest { | 67 class StaticField1RunNegativeTest { |
68 static // /// 01: static type warning, runtime error | 68 static // //# 01: static type warning, runtime error |
69 var x; | 69 var x; |
70 testMain() { | 70 testMain() { |
71 var foo = new StaticField1RunNegativeTest(); | 71 var foo = new StaticField1RunNegativeTest(); |
72 print(x); // Used to compile 'x' and force any errors. | 72 print(x); // Used to compile 'x' and force any errors. |
73 var result = foo.x; | 73 var result = foo.x; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 class StaticField1aRunNegativeTest { | 77 class StaticField1aRunNegativeTest { |
78 static // /// 02: static type warning, runtime error | 78 static // //# 02: static type warning, runtime error |
79 void m() {} | 79 void m() {} |
80 | 80 |
81 testMain() { | 81 testMain() { |
82 var foo = new StaticField1aRunNegativeTest(); | 82 var foo = new StaticField1aRunNegativeTest(); |
83 print(m); // Used to compile 'm' and force any errors. | 83 print(m); // Used to compile 'm' and force any errors. |
84 var result = foo.m; | 84 var result = foo.m; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 class StaticField2RunNegativeTest { | 88 class StaticField2RunNegativeTest { |
89 static /// 03: static type warning, runtime error | 89 static //# 03: static type warning, runtime error |
90 var x; | 90 var x; |
91 | 91 |
92 testMain() { | 92 testMain() { |
93 var foo = new StaticField2RunNegativeTest(); | 93 var foo = new StaticField2RunNegativeTest(); |
94 print(x); // Used to compile 'x' and force any errors. | 94 print(x); // Used to compile 'x' and force any errors. |
95 foo.x = 1; | 95 foo.x = 1; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 class StaticField2aRunNegativeTest { | 99 class StaticField2aRunNegativeTest { |
100 static // /// 04: static type warning, runtime error | 100 static // //# 04: static type warning, runtime error |
101 void m() {} | 101 void m() {} |
102 | 102 |
103 testMain() { | 103 testMain() { |
104 var foo = new StaticField2aRunNegativeTest(); | 104 var foo = new StaticField2aRunNegativeTest(); |
105 print(m); // Used to compile 'm' and force any errors. | 105 print(m); // Used to compile 'm' and force any errors. |
106 foo.m = 1; /// 04:continued | 106 foo.m = 1; //# 04:continued |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 main() { | 110 main() { |
111 StaticFieldTest.testMain(); | 111 StaticFieldTest.testMain(); |
112 InitializerTest.testStaticFieldInitialization(); | 112 InitializerTest.testStaticFieldInitialization(); |
113 new StaticField1RunNegativeTest().testMain(); | 113 new StaticField1RunNegativeTest().testMain(); |
114 new StaticField1aRunNegativeTest().testMain(); | 114 new StaticField1aRunNegativeTest().testMain(); |
115 new StaticField2RunNegativeTest().testMain(); | 115 new StaticField2RunNegativeTest().testMain(); |
116 new StaticField2aRunNegativeTest().testMain(); | 116 new StaticField2aRunNegativeTest().testMain(); |
117 } | 117 } |
OLD | NEW |