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

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

Issue 8231031: Check for compile-time constants in DartCompiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated feedback. 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 of expressions. 4 // Dart test program testing string interpolation of expressions.
5 5
6 6
7 class StringInterpolate2Test { 7 class StringInterpolate2Test {
8 8
9 static final F1 = "1 + 5 = ${1+5}"; 9 static var F1;
10 10
11 static void testMain() { 11 static void testMain() {
12 12
13 F1 = "1 + 5 = ${1+5}";
14
13 Expect.equals("1 + 5 = 6", F1); 15 Expect.equals("1 + 5 = 6", F1);
14 16
15 var fib = [1, 1, 2, 3, 5, 8, 13, 21]; 17 var fib = [1, 1, 2, 3, 5, 8, 13, 21];
16 18
17 var i = 5; 19 var i = 5;
18 var s = "${i}"; 20 var s = "${i}";
19 Expect.equals("5", s); 21 Expect.equals("5", s);
20 22
21 s = "fib(${i}) = ${fib[i]}"; 23 s = "fib(${i}) = ${fib[i]}";
22 Expect.equals("fib(5) = 8", s); 24 Expect.equals("fib(5) = 8", s);
23 25
24 i = 5; 26 i = 5;
25 s = "$i squared is ${((x) => x*x)(i)}"; 27 s = "$i squared is ${((x) => x*x)(i)}";
26 Expect.equals("5 squared is 25", s); 28 Expect.equals("5 squared is 25", s);
27 29
28 Expect.equals("8", "${fib.length}"); 30 Expect.equals("8", "${fib.length}");
29 Expect.equals("8", '${fib. 31 Expect.equals("8", '${fib.length}');
floitsch 2011/10/14 22:46:15 why simplify this test?
zundel 2011/10/17 02:56:02 sorry, I thought it was a typo. It changed from d
floitsch 2011/10/17 07:28:34 could be, that it was a typo. But since the line-b
30 length}');
31 32
32 var map = { "red": 1, "green": 2, "blue": 3 }; 33 var map = { "red": 1, "green": 2, "blue": 3 };
33 s = "green has value ${map["green"]}"; 34 s = "green has value ${map["green"]}";
34 Expect.equals("green has value 2", s); 35 Expect.equals("green has value 2", s);
35 36
36 i = 0; 37 i = 0;
37 b() => "${++i}"; 38 b() => "${++i}";
38 s = "aaa ${"bbb ${b()} bbb"} aaa ${b()}"; 39 s = "aaa ${"bbb ${b()} bbb"} aaa ${b()}";
39 Expect.equals("aaa bbb 1 bbb aaa 2", s); 40 Expect.equals("aaa bbb 1 bbb aaa 2", s);
40 41
41 // test multiple levels of nesting, including changing quotes and 42 // test multiple levels of nesting, including changing quotes and
42 // multiline string types 43 // multiline string types
43 s = "a ${(){ return 'b ${(){ return """ 44 s = "a ${(){ return 'b ${(){ return """
44 c""";}()}'; }()} d"; 45 c""";}()}'; }()} d";
45 Expect.equals("a b c d", s); 46 Expect.equals("a b c d", s);
46 } 47 }
47 } 48 }
48 49
49 main() { 50 main() {
50 StringInterpolate2Test.testMain(); 51 StringInterpolate2Test.testMain();
51 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698