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

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

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test program testing string interpolation of expressions.
5
6
7 class StringInterpolate2Test {
8
9 static var F1;
10
11 static void testMain() {
12
13 F1 = "1 + 5 = ${1+5}";
14
15 Expect.equals("1 + 5 = 6", F1);
16
17 var fib = [1, 1, 2, 3, 5, 8, 13, 21];
18
19 var i = 5;
20 var s = "${i}";
21 Expect.equals("5", s);
22
23 s = "fib(${i}) = ${fib[i]}";
24 Expect.equals("fib(5) = 8", s);
25
26 i = 5;
27 s = "$i squared is ${((x) => x*x)(i)}";
28 Expect.equals("5 squared is 25", s);
29
30 Expect.equals("8", "${fib.length}");
31 // test single quote
32 Expect.equals("8", '${fib.length}');
33 // test multi-line
34 Expect.equals("8", '${fib.
35 length}');
36
37 var map = { "red": 1, "green": 2, "blue": 3 };
38 s = "green has value ${map["green"]}";
39 Expect.equals("green has value 2", s);
40
41 i = 0;
42 b() => "${++i}";
43 s = "aaa ${"bbb ${b()} bbb"} aaa ${b()}";
44 Expect.equals("aaa bbb 1 bbb aaa 2", s);
45
46 // test multiple levels of nesting, including changing quotes and
47 // multiline string types
48 s = "a ${(){ return 'b ${(){ return """
49 c""";}()}'; }()} d";
50 Expect.equals("a b c d", s);
51 }
52 }
53
54 main() {
55 StringInterpolate2Test.testMain();
56 }
OLDNEW
« no previous file with comments | « tests/language/src/StringInterpolate2NegativeTest.dart ('k') | tests/language/src/StringInterpolateNPETest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698