Chromium Code Reviews| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // Exercises compile-time string constants | 7 // Exercises compile-time string constants |
| 8 | 8 |
| 9 const yz = "y" + "z"; | |
| 10 | |
| 9 main() { | 11 main() { |
| 10 // Constant comparisons are independent of the quotes used. | 12 // Constant comparisons are independent of the quotes used. |
| 11 Expect.isTrue(identical("abcd", 'abcd')); | 13 Expect.isTrue(identical("abcd", 'abcd')); |
| 12 Expect.isTrue(identical('abcd', "abcd")); | 14 Expect.isTrue(identical('abcd', "abcd")); |
| 13 Expect.isTrue(identical("ab\"cd", 'ab"cd')); | 15 Expect.isTrue(identical("ab\"cd", 'ab"cd')); |
| 14 Expect.isTrue(identical('ab\'cd', "ab'cd")); | 16 Expect.isTrue(identical('ab\'cd', "ab'cd")); |
| 15 | 17 |
| 16 // String concatenation works even when quotes are different. | 18 // String concatenation works even when quotes are different. |
| 17 Expect.isTrue(identical("abcd", "ab" "cd")); | 19 Expect.isTrue(identical("abcd", "ab" "cd")); |
| 18 Expect.isTrue(identical("abcd", "ab" 'cd')); | 20 Expect.isTrue(identical("abcd", "ab" 'cd')); |
| 19 Expect.isTrue(identical("abcd", 'ab' 'cd')); | 21 Expect.isTrue(identical("abcd", 'ab' 'cd')); |
| 20 Expect.isTrue(identical("abcd", 'ab' "cd")); | 22 Expect.isTrue(identical("abcd", 'ab' "cd")); |
| 21 | 23 |
| 22 // Or when there are more than 2 contatenations. | 24 // Or when there are more than 2 contatenations. |
| 23 Expect.isTrue(identical("abcd", "a" "b" "cd")); | 25 Expect.isTrue(identical("abcd", "a" "b" "cd")); |
| 24 Expect.isTrue(identical("abcd", "a" "b" "c" "d")); | 26 Expect.isTrue(identical("abcd", "a" "b" "c" "d")); |
| 25 Expect.isTrue(identical('abcd', 'a' 'b' 'c' 'd')); | 27 Expect.isTrue(identical('abcd', 'a' 'b' 'c' 'd')); |
| 26 Expect.isTrue(identical("abcd", "a" "b" 'c' "d")); | 28 Expect.isTrue(identical("abcd", "a" "b" 'c' "d")); |
| 27 Expect.isTrue(identical("abcd", 'a' 'b' 'c' 'd')); | 29 Expect.isTrue(identical("abcd", 'a' 'b' 'c' 'd')); |
| 28 Expect.isTrue(identical("abcd", 'a' "b" 'c' "d")); | 30 Expect.isTrue(identical("abcd", 'a' "b" 'c' "d")); |
| 29 | 31 |
| 30 Expect.isTrue(identical("a'b'cd", "a" "'b'" 'c' "d")); | 32 Expect.isTrue(identical("a'b'cd", "a" "'b'" 'c' "d")); |
| 31 Expect.isTrue(identical("a\"b\"cd", "a" '"b"' 'c' "d")); | 33 Expect.isTrue(identical("a\"b\"cd", "a" '"b"' 'c' "d")); |
| 32 Expect.isTrue(identical("a\"b\"cd", "a" '"b"' 'c' "d")); | 34 Expect.isTrue(identical("a\"b\"cd", "a" '"b"' 'c' "d")); |
| 33 Expect.isTrue(identical("a'b'cd", 'a' "'b'" 'c' "d")); | 35 Expect.isTrue(identical("a'b'cd", 'a' "'b'" 'c' "d")); |
| 34 Expect.isTrue(identical('a\'b\'cd', "a" "'b'" 'c' "d")); | 36 Expect.isTrue(identical('a\'b\'cd', "a" "'b'" 'c' "d")); |
| 35 Expect.isTrue(identical('a"b"cd', 'a' '"b"' 'c' "d")); | 37 Expect.isTrue(identical('a"b"cd', 'a' '"b"' 'c' "d")); |
| 36 Expect.isTrue(identical("a\"b\"cd", 'a' '"b"' 'c' "d")); | 38 Expect.isTrue(identical("a\"b\"cd", 'a' '"b"' 'c' "d")); |
| 39 | |
| 40 const a = identical("ab", "a" + "b"); | |
| 41 Expect.isTrue(a); | |
| 42 | |
| 43 const b = identical("xyz", "x" + yz); | |
| 44 Expect.isTrue(b); | |
| 45 | |
| 46 const c = identical("12", "1" "2"); | |
| 47 Expect.isTrue(c); | |
| 48 | |
| 49 const d = identical("zyz", "z$yz"); | |
| 50 Expect.isTrue(d); | |
|
Lasse Reichstein Nielsen
2016/01/05 18:55:13
Maybe also test without the const declarations.
An
Lasse Reichstein Nielsen
2016/01/05 18:56:15
(I think it will succeed after this patch, I just
hausner
2016/01/05 19:05:34
I've talked to Gilad about this. He said that the
| |
| 37 } | 51 } |
| OLD | NEW |