| 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 | 4 |
| 5 // Tests for string interpolation | 5 // Tests for string interpolation |
| 6 class StringInterpolationTest { | 6 class StringInterpolationTest { |
| 7 | 7 |
| 8 StringInterpolationTest() {} | 8 StringInterpolationTest() {} |
| 9 | 9 |
| 10 static void m() {} |
| 11 |
| 10 static final int i = 1; | 12 static final int i = 1; |
| 11 static final String a = "<hi>"; | 13 static final String a = "<hi>"; |
| 12 | 14 |
| 13 int j; | 15 int j; |
| 14 int k; | 16 int k; |
| 15 | 17 |
| 16 static testMain(bool alwaysFalse) { | 18 static testMain(bool alwaysFalse) { |
| 17 var test = new StringInterpolationTest(); | 19 var test = new StringInterpolationTest(); |
| 18 test.j = 3; | 20 test.j = 3; |
| 19 test.k = 5; | 21 test.k = 5; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 Expect.equals("\$", "escaped \${3+2}"[12]); | 52 Expect.equals("\$", "escaped \${3+2}"[12]); |
| 51 Expect.equals("{", "escaped \${3+2}"[13]); | 53 Expect.equals("{", "escaped \${3+2}"[13]); |
| 52 Expect.equals("3", "escaped \${3+2}"[14]); | 54 Expect.equals("3", "escaped \${3+2}"[14]); |
| 53 Expect.equals("+", "escaped \${3+2}"[15]); | 55 Expect.equals("+", "escaped \${3+2}"[15]); |
| 54 Expect.equals("2", "escaped \${3+2}"[16]); | 56 Expect.equals("2", "escaped \${3+2}"[16]); |
| 55 Expect.equals("}", "escaped \${3+2}"[17]); | 57 Expect.equals("}", "escaped \${3+2}"[17]); |
| 56 | 58 |
| 57 if (alwaysFalse) { | 59 if (alwaysFalse) { |
| 58 "${i.toHorse()}"; /// 01: static type warning | 60 "${i.toHorse()}"; /// 01: static type warning |
| 59 } | 61 } |
| 62 |
| 63 Expect.equals("${m}", "$m"); |
| 60 } | 64 } |
| 61 | 65 |
| 62 String embedParams(int z) { | 66 String embedParams(int z) { |
| 63 return "param = ${z}"; | 67 return "param = ${z}"; |
| 64 } | 68 } |
| 65 | 69 |
| 66 String embedSingleField() { | 70 String embedSingleField() { |
| 67 return "j = ${j}"; | 71 return "j = ${j}"; |
| 68 } | 72 } |
| 69 | 73 |
| 70 String embedMultipleFields() { | 74 String embedMultipleFields() { |
| 71 return "j = ${j}; k = ${k}"; | 75 return "j = ${j}; k = ${k}"; |
| 72 } | 76 } |
| 73 } | 77 } |
| 74 | 78 |
| 75 main() { | 79 main() { |
| 76 StringInterpolationTest.testMain(false); | 80 StringInterpolationTest.testMain(false); |
| 77 } | 81 } |
| OLD | NEW |