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 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 void testMain() { |
10 | 10 |
11 static void testMain() { | 11 var F1 = "1 + 5 = ${1+5}"; |
12 | 12 |
13 Expect.equals("1 + 5 = 6", F1); | 13 Expect.equals("1 + 5 = 6", F1); |
14 | 14 |
15 var fib = [1, 1, 2, 3, 5, 8, 13, 21]; | 15 var fib = [1, 1, 2, 3, 5, 8, 13, 21]; |
16 | 16 |
17 var i = 5; | 17 var i = 5; |
18 var s = "${i}"; | 18 var s = "${i}"; |
19 Expect.equals("5", s); | 19 Expect.equals("5", s); |
20 | 20 |
21 s = "fib(${i}) = ${fib[i]}"; | 21 s = "fib(${i}) = ${fib[i]}"; |
(...skipping 20 matching lines...) Expand all Loading... |
42 // multiline string types | 42 // multiline string types |
43 s = "a ${(){ return 'b ${(){ return """ | 43 s = "a ${(){ return 'b ${(){ return """ |
44 c""";}()}'; }()} d"; | 44 c""";}()}'; }()} d"; |
45 Expect.equals("a b c d", s); | 45 Expect.equals("a b c d", s); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 main() { | 49 main() { |
50 StringInterpolate2Test.testMain(); | 50 StringInterpolate2Test.testMain(); |
51 } | 51 } |
OLD | NEW |