| 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 // Test that String interpolation works in the code generated by the leg | 5 // Test that String interpolation works in the code generated by the leg |
| 6 // compiler. | 6 // compiler. |
| 7 | 7 |
| 8 | 8 |
| 9 int ifun() => 37; | 9 int ifun() => 37; |
| 10 double dfun() => 2.71828; | 10 double dfun() => 2.71828; |
| 11 bool bfun() => true; | 11 bool bfun() => true; |
| 12 String sfun() => "sfun"; | 12 String sfun() => "sfun"; |
| 13 void nfun() => null; | 13 void nfun() => null; |
| 14 | 14 |
| 15 | 15 |
| 16 void testEscapes() { | 16 void testEscapes() { |
| 17 // Test that escaping the '$' prevents string interpolation. | 17 // Test that escaping the '$' prevents string interpolation. |
| 18 String x = "NOT HERE"; | 18 String x = "NOT HERE"; |
| 19 Expect.equals(@'a${x}', 'a\${x}'); | 19 Expect.equals(r'a${x}', 'a\${x}'); |
| 20 Expect.equals(@'a$x', 'a\$x'); | 20 Expect.equals(r'a$x', 'a\$x'); |
| 21 Expect.equals(@'a${x}', '''a\${x}'''); | 21 Expect.equals(r'a${x}', '''a\${x}'''); |
| 22 Expect.equals(@'a$x', '''a\$x'''); | 22 Expect.equals(r'a$x', '''a\$x'''); |
| 23 Expect.equals(@'a${x}', "a\${x}"); | 23 Expect.equals(r'a${x}', "a\${x}"); |
| 24 Expect.equals(@'a$x', "a\$x"); | 24 Expect.equals(r'a$x', "a\$x"); |
| 25 Expect.equals(@'a${x}', """a\${x}"""); | 25 Expect.equals(r'a${x}', """a\${x}"""); |
| 26 Expect.equals(@'a$x', """a\$x"""); | 26 Expect.equals(r'a$x', """a\$x"""); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 void testMultiLine() { | 30 void testMultiLine() { |
| 31 var a = "string"; | 31 var a = "string"; |
| 32 var b = 42; | 32 var b = 42; |
| 33 var c = 3.1415; | 33 var c = 3.1415; |
| 34 var d = false; | 34 var d = false; |
| 35 var n = null; | 35 var n = null; |
| 36 | 36 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Lotsa-nested. | 117 // Lotsa-nested. |
| 118 Expect.equals("42", "${'${"${'${"${'${"$b"}'}"}'}"}'}"); | 118 Expect.equals("42", "${'${"${'${"${'${"$b"}'}"}'}"}'}"); |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 void main() { | 122 void main() { |
| 123 testSimple(); | 123 testSimple(); |
| 124 testMultiLine(); | 124 testMultiLine(); |
| 125 testEscapes(); | 125 testEscapes(); |
| 126 } | 126 } |
| OLD | NEW |