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

Side by Side Diff: frog/tests/leg_only/src/StringEscapeTest.dart

Issue 9271037: Inserted string validation as separate task in compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 10 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
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 // Test that string escapes work correctly. 5 // Test that string escapes work correctly.
6 6
7 testSingleCharacterEscapes() { 7 testSingleCharacterEscapes() {
8 List/*<String>*/ examples = [ 8 List/*<String>*/ examples = [
9 "\b\f\n\r\t\v", 9 "\b\f\n\r\t\v",
10 '\b\f\n\r\t\v', 10 '\b\f\n\r\t\v',
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 List/*<int>*/ values = [0, 1, 0x22, 0x27, 0x5c, 0x7f, 0x80, 0xff, 57 List/*<int>*/ values = [0, 1, 0x22, 0x27, 0x5c, 0x7f, 0x80, 0xff,
58 0x100, 0x1000, 0xd7ff, 0xe000, 0xffff]; 58 0x100, 0x1000, 0xd7ff, 0xe000, 0xffff];
59 for (String s in examples) { 59 for (String s in examples) {
60 Expect.equals(values.length, s.length); 60 Expect.equals(values.length, s.length);
61 for (int i = 0; i < values.length; i++) { 61 for (int i = 0; i < values.length; i++) {
62 Expect.equals(values[i], s.charCodeAt(i)); 62 Expect.equals(values[i], s.charCodeAt(i));
63 } 63 }
64 } 64 }
65 // No characters above 0xffff until Leg supports that. 65 // No characters above 0xffff until Leg supports that.
66 var long = 66 var long =
67 "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}\u{0000000}" + 67 "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}" +
68 "\u{1}\u{01}\u{001}\u{00001}" + 68 "\u{1}\u{01}\u{001}\u{00001}" +
69 "\u{ffff}\u{0ffff}\u{00ffff}\u{000ffff}"; 69 "\u{ffff}\u{0ffff}\u{00ffff}";
70 var longValues = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 70 var longValues = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0xffff, 0xffff, 0xffff];
71 0xffff, 0xffff, 0xffff, 0xffff];
72 Expect.equals(longValues.length, long.length); 71 Expect.equals(longValues.length, long.length);
73 for (int i = 0; i < longValues.length; i++) { 72 for (int i = 0; i < longValues.length; i++) {
74 Expect.equals(longValues[i], long.charCodeAt(i)); 73 Expect.equals(longValues[i], long.charCodeAt(i));
75 } 74 }
76 } 75 }
77 76
78 testIdentityEscapes() { 77 testIdentityEscapes() {
79 // All non-control ASCII characters escaped, except those with special 78 // All non-control ASCII characters escaped, except those with special
80 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00). 79 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00).
81 var asciiLiterals = 80 var asciiLiterals =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 testUEscapes(); 118 testUEscapes();
120 // Test \b, \f, \n, \r, \t, \v. 119 // Test \b, \f, \n, \r, \t, \v.
121 testSingleCharacterEscapes(); 120 testSingleCharacterEscapes();
122 // Test all other single character (identity) escaeps. 121 // Test all other single character (identity) escaeps.
123 testIdentityEscapes(); 122 testIdentityEscapes();
124 // Test that quotes are handled correctly. 123 // Test that quotes are handled correctly.
125 testQuotes(); 124 testQuotes();
126 // Test that raw strings are raw. 125 // Test that raw strings are raw.
127 testRawStrings(); 126 testRawStrings();
128 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698