| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 main() { | 5 main() { |
| 6 { | 6 { |
| 7 // Generates identical compile time constants. | 7 // Generates identical compile time constants. |
| 8 var s1 = "abcdefgh"; | 8 var s1 = "abcdefgh"; |
| 9 var s2 = "abcd" "efgh"; | 9 var s2 = "abcd" "efgh"; |
| 10 var s3 = "ab" "cd" "ef" "gh"; | 10 var s3 = "ab" "cd" "ef" "gh"; |
| 11 var s4 = "a" "b" "c" "d" "e" "f" "g" "h"; | 11 var s4 = "a" "b" "c" "d" "e" "f" "g" "h"; |
| 12 var s5 = "a" 'b' @"c" @'d' """e""" '''f''' @"""g""" @'''h'''; | 12 var s5 = "a" 'b' r"c" r'd' """e""" '''f''' r"""g""" r'''h'''; |
| 13 Expect.isTrue(s1 === s2); | 13 Expect.isTrue(s1 === s2); |
| 14 Expect.isTrue(s1 === s3); | 14 Expect.isTrue(s1 === s3); |
| 15 Expect.isTrue(s1 === s4); | 15 Expect.isTrue(s1 === s4); |
| 16 Expect.isTrue(s1 === s5); | 16 Expect.isTrue(s1 === s5); |
| 17 } | 17 } |
| 18 { | 18 { |
| 19 // Separating whitespace isn't necessary for the tokenizer. | 19 // Separating whitespace isn't necessary for the tokenizer. |
| 20 var s1 = "abcdefgh"; | 20 var s1 = "abcdefgh"; |
| 21 var s2 = "abcd""efgh"; | 21 var s2 = "abcd""efgh"; |
| 22 var s3 = "ab""cd""ef""gh"; | 22 var s3 = "ab""cd""ef""gh"; |
| 23 var s4 = "a""b""c""d""e""f""g""h"; | 23 var s4 = "a""b""c""d""e""f""g""h"; |
| 24 var s5 = "a"'b'@"c"@'d'"""e"""'''f'''@"""g"""@'''h'''; | 24 var s5 = "a"'b'r"c"r'd'"""e"""'''f'''r"""g"""r'''h'''; |
| 25 Expect.isTrue(s1 === s2); | 25 Expect.isTrue(s1 === s2); |
| 26 Expect.isTrue(s1 === s3); | 26 Expect.isTrue(s1 === s3); |
| 27 Expect.isTrue(s1 === s4); | 27 Expect.isTrue(s1 === s4); |
| 28 Expect.isTrue(s1 === s5); | 28 Expect.isTrue(s1 === s5); |
| 29 // "a""""""b""" should be tokenized as "a" """""b""", aka. "a" '""b'. | 29 // "a""""""b""" should be tokenized as "a" """""b""", aka. "a" '""b'. |
| 30 Expect.isTrue('a""b' === "a""""""b"""); | 30 Expect.isTrue('a""b' === "a""""""b"""); |
| 31 // """a""""""""b""" is 'a' '""b'. | 31 // """a""""""""b""" is 'a' '""b'. |
| 32 Expect.isTrue('a""b' === """a""""""""b"""); | 32 Expect.isTrue('a""b' === """a""""""""b"""); |
| 33 // Raw strings. | 33 // Raw strings. |
| 34 Expect.isTrue('ab' === "a"@"b"); | 34 Expect.isTrue('ab' === "a"r"b"); |
| 35 Expect.isTrue('ab' === @"a""b"); | 35 Expect.isTrue('ab' === r"a""b"); |
| 36 Expect.isTrue('ab' === @"a"@"b"); | 36 Expect.isTrue('ab' === r"a"r"b"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Newlines are just whitespace. | 39 // Newlines are just whitespace. |
| 40 var ms1 = "abc" | 40 var ms1 = "abc" |
| 41 "def" | 41 "def" |
| 42 "ghi" | 42 "ghi" |
| 43 "jkl"; | 43 "jkl"; |
| 44 Expect.isTrue("abcdefghijkl" === ms1); | 44 Expect.isTrue("abcdefghijkl" === ms1); |
| 45 | 45 |
| 46 // Works with multiline strings too. | 46 // Works with multiline strings too. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 Expect.equals("$x--$y", "$x" "-" "-" "" "$y"); | 92 Expect.equals("$x--$y", "$x" "-" "-" "" "$y"); |
| 93 Expect.equals("$x--$y", "$x" "-" "" "-" "$y"); | 93 Expect.equals("$x--$y", "$x" "-" "" "-" "$y"); |
| 94 Expect.equals("$x--$y", "$x" "" "-" "-" "$y"); | 94 Expect.equals("$x--$y", "$x" "" "-" "-" "$y"); |
| 95 | 95 |
| 96 Expect.equals("$x---$y", "$x" "-" "-" "-" "$y"); | 96 Expect.equals("$x---$y", "$x" "-" "-" "-" "$y"); |
| 97 Expect.equals("$x---", "$x" "-" "-" "-"); | 97 Expect.equals("$x---", "$x" "-" "-" "-"); |
| 98 Expect.equals("---$y", "-" "-" "-" "$y"); | 98 Expect.equals("---$y", "-" "-" "-" "$y"); |
| 99 | 99 |
| 100 Expect.equals("$x-$y-$z", "${'$x' '-' '$y'}" "-" "$z"); | 100 Expect.equals("$x-$y-$z", "${'$x' '-' '$y'}" "-" "$z"); |
| 101 | 101 |
| 102 Expect.equals(@"-foo-42-true-", | 102 Expect.equals(r"-foo-42-true-", |
| 103 @"-" "$x" @"""-""" """$y""" @'-' '$z' @'''-''', "j"); | 103 r"-" "$x" r"""-""" """$y""" r'-' '$z' r'''-''', "j"); |
| 104 Expect.equals(@"-$x-42-true-", | 104 Expect.equals(r"-$x-42-true-", |
| 105 @"-" @"$x" @"""-""" """$y""" @'-' '$z' @'''-''', "k"); | 105 r"-" r"$x" r"""-""" """$y""" r'-' '$z' r'''-''', "k"); |
| 106 Expect.equals(@"-foo-$y-true-", | 106 Expect.equals(r"-foo-$y-true-", |
| 107 @"-" "$x" @"""-""" @"""$y""" @'-' '$z' @'''-''', "l"); | 107 r"-" "$x" r"""-""" r"""$y""" r'-' '$z' r'''-''', "l"); |
| 108 Expect.equals(@"-foo-42-$z-", | 108 Expect.equals(r"-foo-42-$z-", |
| 109 @"-" "$x" @"""-""" """$y""" @'-' @'$z' @'''-''', "m"); | 109 r"-" "$x" r"""-""" """$y""" r'-' r'$z' r'''-''', "m"); |
| 110 } | 110 } |
| 111 } | 111 } |
| OLD | NEW |