Chromium Code Reviews| 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 class First { | 6 class First { |
| 7 First() {} | 7 First() {} |
| 8 static var a; | 8 static var a; |
| 9 static var b; | 9 static var b; |
| 10 static final int c = 1; | 10 static final int c = 1; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 First.b = First.a = 15; | 55 First.b = First.a = 15; |
| 56 Expect.equals(15, First.a); | 56 Expect.equals(15, First.a); |
| 57 Expect.equals(15, First.b); | 57 Expect.equals(15, First.b); |
| 58 Expect.equals(35, First.setValues()); | 58 Expect.equals(35, First.setValues()); |
| 59 Expect.equals(24, First.a); | 59 Expect.equals(24, First.a); |
| 60 Expect.equals(10, First.b); | 60 Expect.equals(10, First.b); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 class StaticField1RunNegativeTest { | |
| 66 static /// 01: static type warning, runtime error | |
| 67 var x; | |
| 68 static testMain() { | |
| 69 var foo = new StaticField1RunNegativeTest(); | |
|
ahe
2012/06/13 14:27:24
Here I would say:
print(x);
to make sure x is "c
zundel
2012/06/13 15:15:43
Done.
| |
| 70 var x = foo.x; | |
|
ahe
2012/06/13 14:27:24
I would put the /// comment on this line.
Also, I
zundel
2012/06/13 15:15:43
Got rid of the shadowing, but left the other in pl
| |
| 71 } | |
| 72 } | |
| 73 | |
| 74 class StaticField1aRunNegativeTest { | |
| 75 static /// 02: static type warning, runtime error | |
| 76 void m() {} | |
| 77 | |
| 78 static testMain() { | |
| 79 var foo = new StaticField1aRunNegativeTest(); | |
| 80 var m = foo.m; | |
|
ahe
2012/06/13 14:27:24
Ditto. For all three remarks above.
| |
| 81 } | |
| 82 } | |
| 83 | |
| 84 class StaticField2RunNegativeTest { | |
| 85 static /// 03: static type warning, runtime error | |
| 86 var x; | |
| 87 | |
| 88 static testMain() { | |
| 89 var foo = new StaticField2RunNegativeTest(); | |
| 90 foo.x = 1; | |
|
ahe
2012/06/13 14:27:24
Ditto (all three).
| |
| 91 } | |
| 92 } | |
| 93 | |
| 94 class StaticField2aRunNegativeTest { | |
| 95 static void m() {} /// 04: static type warning, runtime error | |
| 96 | |
| 97 static testMain() { | |
| 98 var foo = new StaticField2aRunNegativeTest(); | |
| 99 foo.m = 1; /// 04:continued | |
|
ahe
2012/06/13 14:27:24
Ditto (all three).
zundel
2012/06/13 15:15:43
I'm not sure the original author of this test real
| |
| 100 } | |
| 101 } | |
| 102 | |
| 65 main() { | 103 main() { |
| 66 StaticFieldTest.testMain(); | 104 StaticFieldTest.testMain(); |
| 67 InitializerTest.testStaticFieldInitialization(); | 105 InitializerTest.testStaticFieldInitialization(); |
| 106 StaticField1RunNegativeTest.testMain(); | |
| 107 StaticField1aRunNegativeTest.testMain(); | |
| 108 StaticField2RunNegativeTest.testMain(); | |
| 109 StaticField2aRunNegativeTest.testMain(); | |
| 68 } | 110 } |
| OLD | NEW |