OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Dart test program for testing static final fields. | |
5 | |
6 interface Spain { | |
7 static final AG = "Antoni Gaudi"; | |
8 static final SD = "Salvador Dali"; | |
9 } | |
10 | |
11 interface Switzerland { | |
12 static final AG = "Alberto Giacometti"; | |
13 static final LC = "Le Corbusier"; | |
14 } | |
15 | |
16 class A implements Switzerland { | |
17 const A() : n = 5; | |
18 final n; | |
19 static final a = const A(); | |
20 static final b = 3 + 5; | |
21 static final c = A.b + 7; | |
22 static final d = const A(); | |
23 static final s1 = "hula"; | |
24 static final s2 = "hula"; | |
25 static final s3 = "hop"; | |
26 static final d1 = 1.1; | |
27 static final d2 = 0.55 + 0.55; | |
28 static final artist2 = Switzerland.AG; | |
29 static final architect1 = Spain.AG; | |
30 static final array1 = const <int>[1, 2]; | |
31 static final map1 = const {"Monday": 1, "Tuesday": 2, }; | |
32 } | |
33 | |
34 class StaticFinalFieldTest { | |
35 static testMain() { | |
36 Expect.equals(15, A.c); | |
37 Expect.equals(8, A.b); | |
38 Expect.equals(5, A.a.n); | |
39 Expect.equals(true, 8 === A.b); | |
40 Expect.equals(true, A.a === A.d); | |
41 Expect.equals(true, A.s1 === A.s2); | |
42 Expect.equals(false, A.s1 === A.s3); | |
43 Expect.equals(false, A.s1 === A.b); | |
44 Expect.equals(true, A.d1 === A.d2); | |
45 Expect.equals(true, Spain.SD == "Salvador Dali"); | |
46 Expect.equals(true, A.artist2 == "Alberto Giacometti"); | |
47 Expect.equals(true, A.architect1 == "Antoni Gaudi"); | |
48 Expect.equals(2, A.map1["Tuesday"]); | |
49 } | |
50 } | |
51 | |
52 main() { | |
53 StaticFinalFieldTest.testMain(); | |
54 } | |
OLD | NEW |