OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Regression test for issue #24839 - http://dartbug.com/24839 | 7 // Regression test for issue #24839 - http://dartbug.com/24839 |
8 | 8 |
9 const u1 = null; | 9 const u1 = null; |
10 const int u2 = null; | 10 const int u2 = null; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 const ss2 = "$s2"; | 44 const ss2 = "$s2"; |
45 const ss3 = "$s3"; | 45 const ss3 = "$s3"; |
46 const ss4 = "$s4"; | 46 const ss4 = "$s4"; |
47 const sb1 = "$b1"; | 47 const sb1 = "$b1"; |
48 const sb2 = "$b2"; | 48 const sb2 = "$b2"; |
49 const sb3 = "$b3"; | 49 const sb3 = "$b3"; |
50 const sb4 = "$b4"; | 50 const sb4 = "$b4"; |
51 | 51 |
52 // Constant variables in interpolation. | 52 // Constant variables in interpolation. |
53 const interpolation1 = | 53 const interpolation1 = |
54 "$u1 $u2 $u3 $u4 $u5 $u6 $n1 $n2 $n3 $n4 $n5 $n6 $s1 $s2 $s3 $s4 $b1 $b2 $b3 $
b4"; | 54 "$u1 $u2 $u3 $u4 $u5 $u6 $n1 $n2 $n3 $n4 $n5 $n6 $s1 $s2 $s3 $s4 $b1 $b2 $b3
$b4"; |
55 // Constant expressions in interpolation. | 55 // Constant expressions in interpolation. |
56 // (Single string, the linebreak to fit this into 80 chars is inside an | 56 // (Single string, the linebreak to fit this into 80 chars is inside an |
57 // interpolation, which is allowed, even for single-line strings). | 57 // interpolation, which is allowed, even for single-line strings). |
58 const interpolation2 = | 58 const interpolation2 = |
59 "${u1} ${u2} ${u3} ${u4} ${u5} ${u6} ${n1} ${n2} ${n3} ${n4} ${n5} ${n6} ${ | 59 "${u1} ${u2} ${u3} ${u4} ${u5} ${u6} ${n1} ${n2} ${n3} ${n4} ${n5} ${n6} ${ |
60 s1} ${s2} ${s3} ${s4} ${b1} ${b2} ${b3} ${b4}"; | 60 s1} ${s2} ${s3} ${s4} ${b1} ${b2} ${b3} ${b4}"; |
61 // Adjacent string literals are combined. | 61 // Adjacent string literals are combined. |
62 const interpolation3 = | 62 const interpolation3 = "$u1 $u2 $u3 $u4 $u5 " |
63 "$u1 $u2 $u3 $u4 $u5 " '$u6 $n1 $n2 $n3 $n4 ' | 63 '$u6 $n1 $n2 $n3 $n4 ' |
64 """$n5 $n6 $s1 $s2 $s3 """ '''$s4 $b1 $b2 $b3 $b4'''; | 64 """$n5 $n6 $s1 $s2 $s3 """ |
| 65 '''$s4 $b1 $b2 $b3 $b4'''; |
65 // Nested interpolations. | 66 // Nested interpolations. |
66 const interpolation4 = | 67 const interpolation4 = "${"$u1 $u2 $u3 $u4 $u5 " '$u6 $n1 $n2 $n3 $n4'} ${ |
67 "${"$u1 $u2 $u3 $u4 $u5 " '$u6 $n1 $n2 $n3 $n4'} ${ | |
68 """$n5 $n6 $s1 $s2 $s3 """ '''$s4 $b1 $b2 $b3 $b4'''}"; | 68 """$n5 $n6 $s1 $s2 $s3 """ '''$s4 $b1 $b2 $b3 $b4'''}"; |
69 | 69 |
70 main() { | 70 main() { |
71 Expect.equals(u1.toString(), su1); | 71 Expect.equals(u1.toString(), su1); |
72 Expect.equals(u2.toString(), su2); | 72 Expect.equals(u2.toString(), su2); |
73 Expect.equals(u3.toString(), su3); | 73 Expect.equals(u3.toString(), su3); |
74 Expect.equals(u4.toString(), su4); | 74 Expect.equals(u4.toString(), su4); |
75 Expect.equals(u5.toString(), su5); | 75 Expect.equals(u5.toString(), su5); |
76 Expect.equals(u6.toString(), su6); | 76 Expect.equals(u6.toString(), su6); |
77 Expect.equals(n1.toString(), sn1); | 77 Expect.equals(n1.toString(), sn1); |
78 Expect.equals(n2.toString(), sn2); | 78 Expect.equals(n2.toString(), sn2); |
79 Expect.equals(n3.toString(), sn3); | 79 Expect.equals(n3.toString(), sn3); |
80 Expect.equals(n4.toString(), sn4); | 80 Expect.equals(n4.toString(), sn4); |
81 Expect.equals(n5.toString(), sn5); | 81 Expect.equals(n5.toString(), sn5); |
82 Expect.equals(n6.toString(), sn6); | 82 Expect.equals(n6.toString(), sn6); |
83 Expect.equals(s1.toString(), ss1); | 83 Expect.equals(s1.toString(), ss1); |
84 Expect.equals(s2.toString(), ss2); | 84 Expect.equals(s2.toString(), ss2); |
85 Expect.equals(s3.toString(), ss3); | 85 Expect.equals(s3.toString(), ss3); |
86 Expect.equals(s4.toString(), ss4); | 86 Expect.equals(s4.toString(), ss4); |
87 Expect.equals(b1.toString(), sb1); | 87 Expect.equals(b1.toString(), sb1); |
88 Expect.equals(b2.toString(), sb2); | 88 Expect.equals(b2.toString(), sb2); |
89 Expect.equals(b3.toString(), sb3); | 89 Expect.equals(b3.toString(), sb3); |
90 Expect.equals(b4.toString(), sb4); | 90 Expect.equals(b4.toString(), sb4); |
91 var expect = "null null null null null null 42 3.1415 37 4.6692 2.71828 87 " | 91 var expect = "null null null null null null 42 3.1415 37 4.6692 2.71828 87 " |
92 "s1 s2 s1s2 s4 true false false true"; | 92 "s1 s2 s1s2 s4 true false false true"; |
93 Expect.equals(expect, interpolation1); | 93 Expect.equals(expect, interpolation1); |
94 Expect.equals(expect, interpolation2); | 94 Expect.equals(expect, interpolation2); |
95 Expect.equals(expect, interpolation3); | 95 Expect.equals(expect, interpolation3); |
96 Expect.equals(expect, interpolation4); | 96 Expect.equals(expect, interpolation4); |
97 } | 97 } |
OLD | NEW |