| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (c) 2014, 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 library string_escaping_test; |  | 
| 6 |  | 
| 7 import 'dart:async'; |  | 
| 8 import 'dart:mirrors'; |  | 
| 9 import 'package:observatory/service_io.dart'; |  | 
| 10 import 'package:unittest/unittest.dart'; |  | 
| 11 import 'test_helper.dart'; |  | 
| 12 |  | 
| 13 var ascii; |  | 
| 14 var latin1; |  | 
| 15 var unicode; |  | 
| 16 var hebrew; |  | 
| 17 var singleQuotes; |  | 
| 18 var doubleQuotes; |  | 
| 19 var newLines; |  | 
| 20 var tabs; |  | 
| 21 var suggrogatePairs; |  | 
| 22 var nullInTheMiddle; |  | 
| 23 var escapedUnicodeEscape; |  | 
| 24 var longStringEven; |  | 
| 25 var longStringOdd; |  | 
| 26 var malformedWithLeadSurrogate; |  | 
| 27 var malformedWithTrailSurrogate; |  | 
| 28 |  | 
| 29 void script() { |  | 
| 30   ascii = "Hello, World!"; |  | 
| 31   latin1 = "blåbærgrød"; |  | 
| 32   unicode = "Îñţérñåţîöñåļîžåţîờñ"; |  | 
| 33   hebrew = "שלום רב שובך צפורה נחמדת";  // Right-to-left text. |  | 
| 34   singleQuotes = "'One,' he said."; |  | 
| 35   doubleQuotes = '"Two," he said.'; |  | 
| 36   newLines = "Windows\r\nSmalltalk\rUnix\n"; |  | 
| 37   tabs = "One\tTwo\tThree"; |  | 
| 38   suggrogatePairs = "1𝄞2𝄞𝄞3𝄞𝄞𝄞"; |  | 
| 39   nullInTheMiddle = "There are four\u0000 words."; |  | 
| 40   escapedUnicodeEscape = "Should not be A: \\u0041"; |  | 
| 41 |  | 
| 42   // A surrogate pair will cross the preferred truncation boundry. |  | 
| 43   longStringEven = ".."; |  | 
| 44   for (int i = 0; i < 512; i++) longStringEven += "𝄞"; |  | 
| 45   longStringOdd = "."; |  | 
| 46   for (int i = 0; i < 512; i++) longStringOdd += "𝄞"; |  | 
| 47 |  | 
| 48   malformedWithLeadSurrogate = "before" + "𝄞"[0] + "after"; |  | 
| 49   malformedWithTrailSurrogate = "before" + "𝄞"[1] + "after"; |  | 
| 50 } |  | 
| 51 |  | 
| 52 var tests = [ |  | 
| 53 |  | 
| 54 (Isolate isolate) => |  | 
| 55   isolate.rootLib.load().then((Library lib) { |  | 
| 56     expectFullString(String varName, String varValueAsString) { |  | 
| 57       Field field = lib.variables.singleWhere((v) => v.name == varName); |  | 
| 58       Instance value = field.value; |  | 
| 59       expect(value.valueAsString, equals(varValueAsString)); |  | 
| 60       expect(value.valueAsStringIsTruncated, isFalse); |  | 
| 61     } |  | 
| 62     expectTruncatedString(String varName, String varValueAsString) { |  | 
| 63       Field field = lib.variables.singleWhere((v) => v.name == varName); |  | 
| 64       Instance value = field.value; |  | 
| 65       expect(varValueAsString, startsWith(value.valueAsString)); |  | 
| 66       expect(value.valueAsStringIsTruncated, isTrue); |  | 
| 67     } |  | 
| 68 |  | 
| 69     script();  // Need to initialize variables in the testing isolate. |  | 
| 70     expectFullString('ascii', ascii); |  | 
| 71     expectFullString('latin1', latin1); |  | 
| 72     expectFullString('unicode', unicode); |  | 
| 73     expectFullString('hebrew', hebrew); |  | 
| 74     expectFullString('singleQuotes', singleQuotes); |  | 
| 75     expectFullString('doubleQuotes', doubleQuotes); |  | 
| 76     expectFullString('newLines', newLines); |  | 
| 77     expectFullString('tabs', tabs); |  | 
| 78     expectFullString('suggrogatePairs', suggrogatePairs); |  | 
| 79     expectFullString('nullInTheMiddle', nullInTheMiddle); |  | 
| 80     expectTruncatedString('longStringEven', longStringEven); |  | 
| 81     expectTruncatedString('longStringOdd', longStringOdd); |  | 
| 82     expectFullString('malformedWithLeadSurrogate', malformedWithLeadSurrogate); |  | 
| 83     expectFullString('malformedWithTrailSurrogate', malformedWithTrailSurrogate)
    ; |  | 
| 84   }), |  | 
| 85 |  | 
| 86 ]; |  | 
| 87 |  | 
| 88 main(args) => runIsolateTests(args, tests, testeeBefore: script); |  | 
| OLD | NEW | 
|---|