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

Side by Side Diff: frog/tests/leg_only/literal_string_juxtaposition_test.dart

Issue 10536169: Move frog/tests/{leg,leg_only,frog_native} to tests/compiler/. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months 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
« no previous file with comments | « frog/tests/leg_only/list_factory_test.dart ('k') | frog/tests/leg_only/literals_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 main() {
6 {
7 // Generates identical compile time constants.
8 var s1 = "abcdefgh";
9 var s2 = "abcd" "efgh";
10 var s3 = "ab" "cd" "ef" "gh";
11 var s4 = "a" "b" "c" "d" "e" "f" "g" "h";
12 var s5 = "a" 'b' @"c" @'d' """e""" '''f''' @"""g""" @'''h''';
13 Expect.isTrue(s1 === s2);
14 Expect.isTrue(s1 === s3);
15 Expect.isTrue(s1 === s4);
16 Expect.isTrue(s1 === s5);
17 }
18 {
19 // Separating whitespace isn't necessary for the tokenizer.
20 var s1 = "abcdefgh";
21 var s2 = "abcd""efgh";
22 var s3 = "ab""cd""ef""gh";
23 var s4 = "a""b""c""d""e""f""g""h";
24 var s5 = "a"'b'@"c"@'d'"""e"""'''f'''@"""g"""@'''h''';
25 Expect.isTrue(s1 === s2);
26 Expect.isTrue(s1 === s3);
27 Expect.isTrue(s1 === s4);
28 Expect.isTrue(s1 === s5);
29 // "a""""""b""" should be tokenized as "a" """""b""", aka. "a" '""b'.
30 Expect.isTrue('a""b' === "a""""""b""");
31 // """a""""""""b""" is 'a' '""b'.
32 Expect.isTrue('a""b' === """a""""""""b""");
33 // Raw strings.
34 Expect.isTrue('ab' === "a"@"b");
35 Expect.isTrue('ab' === @"a""b");
36 Expect.isTrue('ab' === @"a"@"b");
37 }
38
39 // Newlines are just whitespace.
40 var ms1 = "abc"
41 "def"
42 "ghi"
43 "jkl";
44 Expect.isTrue("abcdefghijkl" === ms1);
45
46 // Works with multiline strings too.
47 var ms2 = """abc
48 def"""
49 """
50 ghi
51 jkl
52 """;
53 Expect.isTrue("abc\n def ghi\n jkl\n " === ms2, "Multiline: $ms2");
54
55 // Binds stronger than property access (it's considered one literal).
56 Expect.equals(5, "ab" "cde".length, "Associativity");
57
58 // Check that interpolations are handled correctly.
59 {
60 var x = "foo";
61 var y = 42;
62 var z = true;
63 String e1 = "$x$y$z";
64 Expect.equals(e1, "$x" "$y$z");
65 Expect.equals(e1, "$x$y" "$z");
66 Expect.equals(e1, "$x" "$y" "$z");
67 String e2 = "-$x-$y-$z-";
68 Expect.equals(e2, "-" "$x" "-" "$y" "-" "$z" "-", "a");
69 Expect.equals(e2, "-$x" "-" "$y" "-" "$z" "-", "b");
70 Expect.equals(e2, "-" "$x-" "$y" "-" "$z" "-", "c");
71 Expect.equals(e2, "-" "$x" "-$y" "-" "$z" "-", "d");
72 Expect.equals(e2, "-" "$x" "-" "$y-" "$z" "-", "e");
73 Expect.equals(e2, "-" "$x" "-" "$y" "-$z" "-", "f");
74 Expect.equals(e2, "-" "$x" "-" "$y" "-" "$z-", "g");
75 Expect.equals(e2, "-" "$x-$y" "-" "$z" "-", "h");
76 Expect.equals(e2, "-" "$x-$y-$z" "-", "i");
77
78 Expect.equals("-$x-$y-", "-" "$x" "-" "$y" "-");
79 Expect.equals("-$x-$y", "-" "$x" "-" "$y");
80 Expect.equals("-$x$y-", "-" "$x" "$y" "-");
81 Expect.equals("$x-$y-", "$x" "-" "$y" "-");
82
83 Expect.equals("$x$y", "$x" "$y");
84 Expect.equals("$x$y", "$x" "" "$y");
85 Expect.equals("$x$y", "$x" "" "" "$y");
86 Expect.equals("$x-$y", "$x" "-" "$y");
87 Expect.equals("$x-$y", "$x" "-" "" "$y");
88 Expect.equals("$x-$y", "$x" "" "-" "$y");
89 Expect.equals("$x-$y", "$x" "" "-" "" "$y");
90
91 Expect.equals("$x--$y", "$x" "-" "-" "$y");
92 Expect.equals("$x--$y", "$x" "-" "-" "" "$y");
93 Expect.equals("$x--$y", "$x" "-" "" "-" "$y");
94 Expect.equals("$x--$y", "$x" "" "-" "-" "$y");
95
96 Expect.equals("$x---$y", "$x" "-" "-" "-" "$y");
97 Expect.equals("$x---", "$x" "-" "-" "-");
98 Expect.equals("---$y", "-" "-" "-" "$y");
99
100 Expect.equals("$x-$y-$z", "${'$x' '-' '$y'}" "-" "$z");
101
102 Expect.equals(@"-foo-42-true-",
103 @"-" "$x" @"""-""" """$y""" @'-' '$z' @'''-''', "j");
104 Expect.equals(@"-$x-42-true-",
105 @"-" @"$x" @"""-""" """$y""" @'-' '$z' @'''-''', "k");
106 Expect.equals(@"-foo-$y-true-",
107 @"-" "$x" @"""-""" @"""$y""" @'-' '$z' @'''-''', "l");
108 Expect.equals(@"-foo-42-$z-",
109 @"-" "$x" @"""-""" """$y""" @'-' @'$z' @'''-''', "m");
110 }
111 }
OLDNEW
« no previous file with comments | « frog/tests/leg_only/list_factory_test.dart ('k') | frog/tests/leg_only/literals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698