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

Side by Side Diff: tests/language_strong/string_interpolate2_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
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 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8
9 class StringInterpolate2Test { 8 class StringInterpolate2Test {
10
11 static var F1; 9 static var F1;
12 10
13 static void testMain() { 11 static void testMain() {
14
15 F1 = "1 + 5 = ${1+5}"; 12 F1 = "1 + 5 = ${1+5}";
16 13
17 Expect.equals("1 + 5 = 6", F1); 14 Expect.equals("1 + 5 = 6", F1);
18 15
19 var fib = [1, 1, 2, 3, 5, 8, 13, 21]; 16 var fib = [1, 1, 2, 3, 5, 8, 13, 21];
20 17
21 var i = 5; 18 var i = 5;
22 var s = "${i}"; 19 var s = "${i}";
23 Expect.equals("5", s); 20 Expect.equals("5", s);
24 21
25 s = "fib(${i}) = ${fib[i]}"; 22 s = "fib(${i}) = ${fib[i]}";
26 Expect.equals("fib(5) = 8", s); 23 Expect.equals("fib(5) = 8", s);
27 24
28 i = 5; 25 i = 5;
29 s = "$i squared is ${((x) => x*x)(i)}"; 26 s = "$i squared is ${((x) => x*x)(i)}";
30 Expect.equals("5 squared is 25", s); 27 Expect.equals("5 squared is 25", s);
31 28
32 Expect.equals("8", "${fib.length}"); 29 Expect.equals("8", "${fib.length}");
33 // test single quote 30 // test single quote
34 Expect.equals("8", '${fib.length}'); 31 Expect.equals("8", '${fib.length}');
35 // test multi-line 32 // test multi-line
36 Expect.equals("8", '${fib. 33 Expect.equals(
34 "8",
35 '${fib.
37 length}'); 36 length}');
38 37
39 var map = { "red": 1, "green": 2, "blue": 3 }; 38 var map = {"red": 1, "green": 2, "blue": 3};
40 s = "green has value ${map["green"]}"; 39 s = "green has value ${map["green"]}";
41 Expect.equals("green has value 2", s); 40 Expect.equals("green has value 2", s);
42 41
43 i = 0; 42 i = 0;
44 b() => "${++i}"; 43 b() => "${++i}";
45 s = "aaa ${"bbb ${b()} bbb"} aaa ${b()}"; 44 s = "aaa ${"bbb ${b()} bbb"} aaa ${b()}";
46 Expect.equals("aaa bbb 1 bbb aaa 2", s); 45 Expect.equals("aaa bbb 1 bbb aaa 2", s);
47 46
48 // test multiple levels of nesting, including changing quotes and 47 // test multiple levels of nesting, including changing quotes and
49 // multiline string types 48 // multiline string types
50 s = "a ${(){ return 'b ${(){ return """ 49 s = "a ${(){ return 'b ${(){ return """
51 c""";}()}'; }()} d"; 50 c""";}()}'; }()} d";
52 Expect.equals("a b c d", s); 51 Expect.equals("a b c d", s);
53 } 52 }
54 } 53 }
55 54
56 main() { 55 main() {
57 StringInterpolate2Test.testMain(); 56 StringInterpolate2Test.testMain();
58 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698