Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: tests/language/src/StringInterpolateTest.dart

Issue 8231031: Check for compile-time constants in DartCompiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Feedback from floitsch Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 void foo() { 10 void foo() {
11 return "Hansel and $name"; // Field name is defined in subclass. 11 return "Hansel and $name"; // Field name is defined in subclass.
12 } 12 }
13 } 13 }
14 14
15 class ThingamaBob extends WhatchamaCallIt { 15 class ThingamaBob extends WhatchamaCallIt {
16 ThingamaBob(String s) : super(), name = s { } 16 ThingamaBob(String s) : super(), name = s { }
17 String name; 17 String name;
18 } 18 }
19 19
20 class StringInterpolateTest { 20 class StringInterpolateTest {
21 21
22 static final String A = "svin"; 22 static final String A = "svin";
23 static final String B = "hest"; 23 static final String B = "hest";
24 static final int N = 1 + 1; 24 static final int N = 1 + 1;
25 static final String Printers = "Printers: $A and $B"; 25 static String Printers;
26 static final String AAR_Printers = "AAR has $N $Printers."; 26 static String AAR_Printers;
27 27
28 static testMain() { 28 static testMain() {
29 Printers = "Printers: $A and $B";
30 AAR_Printers = "AAR has $N $Printers.";
31
29 var x = 1; 32 var x = 1;
30 var s = "eins und \$x macht zwei."; 33 var s = "eins und \$x macht zwei.";
31 print(s); 34 print(s);
32 Expect.equals(@"eins und $x macht zwei.", s); 35 Expect.equals(@"eins und $x macht zwei.", s);
33 36
34 s = "eins und $x macht zwei."; 37 s = "eins und $x macht zwei.";
35 print(s); 38 print(s);
36 Expect.equals(@"eins und 1 macht zwei.", s); 39 Expect.equals(@"eins und 1 macht zwei.", s);
37 40
38 print(AAR_Printers); 41 print(AAR_Printers);
(...skipping 10 matching lines...) Expand all
49 52
50 var t = new ThingamaBob("Gretel"); 53 var t = new ThingamaBob("Gretel");
51 print(t.foo()); 54 print(t.foo());
52 Expect.equals(t.foo(), "Hansel and Gretel"); 55 Expect.equals(t.foo(), "Hansel and Gretel");
53 } 56 }
54 } 57 }
55 58
56 main() { 59 main() {
57 StringInterpolateTest.testMain(); 60 StringInterpolateTest.testMain();
58 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698