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}; | 32 // Compile time constants don't allow string interpolation. |
ngeoffray
2011/10/14 09:26:56
I have CC'ed Matthias to make sure he's aware of t
zundel
2011/10/14 10:04:21
For the negative test, see tringInterpolate7Negati
ngeoffray
2011/10/14 10:33:42
Apologies for the "never got a response". Gilad is
zundel
2011/10/14 20:59:52
I am going ahead and allowing them since the VM do
hausner
2011/10/14 22:20:24
I was told that string interpolation should not be
| |
33 // static final map2 = const {"$s1$s3": b}; | |
33 } | 34 } |
34 | 35 |
35 class StaticFinalFieldTest { | 36 class StaticFinalFieldTest { |
36 static testMain() { | 37 static testMain() { |
37 Expect.equals(15, A.c); | 38 Expect.equals(15, A.c); |
38 Expect.equals(8, A.b); | 39 Expect.equals(8, A.b); |
39 Expect.equals(5, A.a.n); | 40 Expect.equals(5, A.a.n); |
40 Expect.equals(true, 8 === A.b); | 41 Expect.equals(true, 8 === A.b); |
41 Expect.equals(true, A.a === A.d); | 42 Expect.equals(true, A.a === A.d); |
42 Expect.equals(true, A.s1 === A.s2); | 43 Expect.equals(true, A.s1 === A.s2); |
43 Expect.equals(false, A.s1 === A.s3); | 44 Expect.equals(false, A.s1 === A.s3); |
44 Expect.equals(false, A.s1 === A.b); | 45 Expect.equals(false, A.s1 === A.b); |
45 Expect.equals(true, A.d1 === A.d2); | 46 Expect.equals(true, A.d1 === A.d2); |
46 Expect.equals(true, Spain.SD == "Salvador Dali"); | 47 Expect.equals(true, Spain.SD == "Salvador Dali"); |
47 Expect.equals(true, A.artist2 == "Alberto Giacometti"); | 48 Expect.equals(true, A.artist2 == "Alberto Giacometti"); |
48 Expect.equals(true, A.architect1 == "Antoni Gaudi"); | 49 Expect.equals(true, A.architect1 == "Antoni Gaudi"); |
49 Expect.equals(2, A.map1["Tuesday"]); | 50 Expect.equals(2, A.map1["Tuesday"]); |
50 Expect.equals(8, A.map2["hulahop"]); | 51 // Expect.equals(8, A.map2["hulahop"]); |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
54 main() { | 55 main() { |
55 StaticFinalFieldTest.testMain(); | 56 StaticFinalFieldTest.testMain(); |
56 } | 57 } |
OLD | NEW |