Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tests/compiler/dart2js_extra/literal_string_juxtaposition_test.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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' r"c" r'd' """e""" '''f''' r"""g""" r'''h'''; 12 var s5 = "a" 'b' r"c" r'd' """e""" '''f''' r"""g""" r'''h''';
13 Expect.isTrue(s1 === s2); 13 Expect.isTrue(identical(s1, s2));
14 Expect.isTrue(s1 === s3); 14 Expect.isTrue(identical(s1, s3));
15 Expect.isTrue(s1 === s4); 15 Expect.isTrue(identical(s1, s4));
16 Expect.isTrue(s1 === s5); 16 Expect.isTrue(identical(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'r"c"r'd'"""e"""'''f'''r"""g"""r'''h'''; 24 var s5 = "a"'b'r"c"r'd'"""e"""'''f'''r"""g"""r'''h''';
25 Expect.isTrue(s1 === s2); 25 Expect.isTrue(identical(s1, s2));
26 Expect.isTrue(s1 === s3); 26 Expect.isTrue(identical(s1, s3));
27 Expect.isTrue(s1 === s4); 27 Expect.isTrue(identical(s1, s4));
28 Expect.isTrue(s1 === s5); 28 Expect.isTrue(identical(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(identical('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(identical('a""b', """a""""""""b"""));
33 // Raw strings. 33 // Raw strings.
34 Expect.isTrue('ab' === "a"r"b"); 34 Expect.isTrue(identical('ab', "a"r"b"));
35 Expect.isTrue('ab' === r"a""b"); 35 Expect.isTrue(identical('ab', r"a""b"));
36 Expect.isTrue('ab' === r"a"r"b"); 36 Expect.isTrue(identical('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(identical("abcdefghijkl", ms1));
45 45
46 // Works with multiline strings too. 46 // Works with multiline strings too.
47 var ms2 = """abc 47 var ms2 = """abc
48 def""" 48 def"""
49 """ 49 """
50 ghi 50 ghi
51 jkl 51 jkl
52 """; 52 """;
53 Expect.isTrue("abc\n def ghi\n jkl\n " === ms2, "Multiline: $ms2"); 53 Expect.isTrue(identical("abc\n def ghi\n jkl\n ", ms2), "Multiline: $ms2") ;
54 54
55 // Binds stronger than property access (it's considered one literal). 55 // Binds stronger than property access (it's considered one literal).
56 Expect.equals(5, "ab" "cde".length, "Associativity"); 56 Expect.equals(5, "ab" "cde".length, "Associativity");
57 57
58 // Check that interpolations are handled correctly. 58 // Check that interpolations are handled correctly.
59 { 59 {
60 var x = "foo"; 60 var x = "foo";
61 var y = 42; 61 var y = 42;
62 var z = true; 62 var z = true;
63 String e1 = "$x$y$z"; 63 String e1 = "$x$y$z";
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Expect.equals(r"-foo-42-true-", 102 Expect.equals(r"-foo-42-true-",
103 r"-" "$x" r"""-""" """$y""" r'-' '$z' r'''-''', "j"); 103 r"-" "$x" r"""-""" """$y""" r'-' '$z' r'''-''', "j");
104 Expect.equals(r"-$x-42-true-", 104 Expect.equals(r"-$x-42-true-",
105 r"-" r"$x" r"""-""" """$y""" r'-' '$z' r'''-''', "k"); 105 r"-" r"$x" r"""-""" """$y""" r'-' '$z' r'''-''', "k");
106 Expect.equals(r"-foo-$y-true-", 106 Expect.equals(r"-foo-$y-true-",
107 r"-" "$x" r"""-""" r"""$y""" r'-' '$z' r'''-''', "l"); 107 r"-" "$x" r"""-""" r"""$y""" r'-' '$z' r'''-''', "l");
108 Expect.equals(r"-foo-42-$z-", 108 Expect.equals(r"-foo-42-$z-",
109 r"-" "$x" r"""-""" """$y""" r'-' r'$z' r'''-''', "m"); 109 r"-" "$x" r"""-""" """$y""" r'-' r'$z' r'''-''', "m");
110 } 110 }
111 } 111 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_extra/bailout_on_continue_test.dart ('k') | tests/compiler/dart2js_extra/nan_negate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698