OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 static final fields. | 4 // Dart test program for testing static final fields. |
5 | 5 |
6 interface Spain { | 6 interface Spain { |
7 static final AG = "Antoni Gaudi"; | 7 static final AG = "Antoni Gaudi"; |
8 static final SD = "Salvador Dali"; | 8 static final SD = "Salvador Dali"; |
9 } | 9 } |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 static final d = const A(); | 22 static final d = const A(); |
23 static final s1 = "hula"; | 23 static final s1 = "hula"; |
24 static final s2 = "hula"; | 24 static final s2 = "hula"; |
25 static final s3 = "hop"; | 25 static final s3 = "hop"; |
26 static final d1 = 1.1; | 26 static final d1 = 1.1; |
27 static final d2 = 0.55 + 0.55; | 27 static final d2 = 0.55 + 0.55; |
28 static final artist2 = Switzerland.AG; | 28 static final artist2 = Switzerland.AG; |
29 static final architect1 = Spain.AG; | 29 static final architect1 = Spain.AG; |
30 static final array1 = const <int>[1, 2]; | 30 static final array1 = const <int>[1, 2]; |
31 static final map1 = const {"Monday": 1, "Tuesday": 2, }; | 31 static final map1 = const {"Monday": 1, "Tuesday": 2, }; |
32 static final map2 = const {"$s1$s3": b}; | |
33 } | 32 } |
34 | 33 |
35 class StaticFinalFieldTest { | 34 class StaticFinalFieldTest { |
36 static testMain() { | 35 static testMain() { |
37 Expect.equals(15, A.c); | 36 Expect.equals(15, A.c); |
38 Expect.equals(8, A.b); | 37 Expect.equals(8, A.b); |
39 Expect.equals(5, A.a.n); | 38 Expect.equals(5, A.a.n); |
40 Expect.equals(true, 8 === A.b); | 39 Expect.equals(true, 8 === A.b); |
41 Expect.equals(true, A.a === A.d); | 40 Expect.equals(true, A.a === A.d); |
42 Expect.equals(true, A.s1 === A.s2); | 41 Expect.equals(true, A.s1 === A.s2); |
43 Expect.equals(false, A.s1 === A.s3); | 42 Expect.equals(false, A.s1 === A.s3); |
44 Expect.equals(false, A.s1 === A.b); | 43 Expect.equals(false, A.s1 === A.b); |
45 Expect.equals(true, A.d1 === A.d2); | 44 Expect.equals(true, A.d1 === A.d2); |
46 Expect.equals(true, Spain.SD == "Salvador Dali"); | 45 Expect.equals(true, Spain.SD == "Salvador Dali"); |
47 Expect.equals(true, A.artist2 == "Alberto Giacometti"); | 46 Expect.equals(true, A.artist2 == "Alberto Giacometti"); |
48 Expect.equals(true, A.architect1 == "Antoni Gaudi"); | 47 Expect.equals(true, A.architect1 == "Antoni Gaudi"); |
49 Expect.equals(2, A.map1["Tuesday"]); | 48 Expect.equals(2, A.map1["Tuesday"]); |
50 Expect.equals(8, A.map2["hulahop"]); | |
51 } | 49 } |
52 } | 50 } |
53 | 51 |
54 main() { | 52 main() { |
55 StaticFinalFieldTest.testMain(); | 53 StaticFinalFieldTest.testMain(); |
56 } | 54 } |
OLD | NEW |