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 testing string interpolation. | 4 // Dart test program testing string interpolation. |
5 | 5 |
6 | 6 |
7 class WhatchamaCallIt { | 7 class WhatchamaCallIt { |
8 WhatchamaCallIt() { } | 8 WhatchamaCallIt() { } |
9 | 9 |
10 String foo() { | 10 String foo() { |
11 // Test $this and Field name is defined in subclass. | 11 // Test $this and Field name is defined in subclass. |
12 return "$this and $name"; | 12 return "$this and $name"; |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 class ThingamaBob extends WhatchamaCallIt { | 16 class ThingamaBob extends WhatchamaCallIt { |
17 ThingamaBob(String s) : super(), name = s { } | 17 ThingamaBob(String s) : super(), name = s { } |
18 String name; | 18 String name; |
19 toString() => "Hansel"; | 19 toString() => "Hansel"; |
20 } | 20 } |
21 | 21 |
22 class StringInterpolateTest { | 22 class StringInterpolateTest { |
23 | 23 |
24 static final String A = "svin"; | 24 static const String A = "svin"; |
25 static final String B = "hest"; | 25 static const String B = "hest"; |
26 static final int N = 1 + 1; | 26 static const int N = 1 + 1; |
27 static String Printers; | 27 static String Printers; |
28 static String AAR_Printers; | 28 static String AAR_Printers; |
29 | 29 |
30 static testMain() { | 30 static testMain() { |
31 Printers = "Printers: $A and $B"; | 31 Printers = "Printers: $A and $B"; |
32 AAR_Printers = "AAR has $N $Printers."; | 32 AAR_Printers = "AAR has $N $Printers."; |
33 | 33 |
34 var x = 1; | 34 var x = 1; |
35 var s = "eins und \$x macht zwei."; | 35 var s = "eins und \$x macht zwei."; |
36 print(s); | 36 print(s); |
(...skipping 17 matching lines...) Expand all Loading... |
54 | 54 |
55 var t = new ThingamaBob("Gretel"); | 55 var t = new ThingamaBob("Gretel"); |
56 print(t.foo()); | 56 print(t.foo()); |
57 Expect.equals(t.foo(), "Hansel and Gretel"); | 57 Expect.equals(t.foo(), "Hansel and Gretel"); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 main() { | 61 main() { |
62 StringInterpolateTest.testMain(); | 62 StringInterpolateTest.testMain(); |
63 } | 63 } |
OLD | NEW |