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

Side by Side Diff: runtime/bin/vmservice/observatory/test/string_escaping_test.dart

Issue 542363003: Don't double-escape in strings in the VM Service, and don't use \u0000 to determine the string lengt (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
(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
27 void script() {
turnidge 2014/09/09 16:12:31 Nice.
28 ascii = "Hello, World!";
29 latin1 = "blåbærgrød";
30 unicode = "Îñţérñåţîöñåļîžåţîờñ";
31 hebrew = "שלום רב שובך צפורה נחמדת"; // Right-to-left text.
32 singleQuotes = "'One,' he said.";
33 doubleQuotes = '"Two," he said.';
34 newLines = "Windows\r\nSmalltalk\rUnix\n";
35 tabs = "One\tTwo\tThree";
36 suggrogatePairs = "1𝄞2𝄞𝄞3𝄞𝄞𝄞";
37 nullInTheMiddle = "There are four\u0000 words.";
38 escapedUnicodeEscape = "Should not be A: \\u0041";
39
40 // A surrogate pair will cross the preferred truncation boundry.
41 longStringEven = "..";
42 for (int i = 0; i < 512; i++) longStringEven += "𝄞";
43 longStringOdd = ".";
44 for (int i = 0; i < 512; i++) longStringOdd += "𝄞";
45 }
46
47 var tests = [
48
49 (Isolate isolate) =>
50 isolate.rootLib.load().then((Library lib) {
51 expectFullString(String varName, String varValueAsString) {
52 ServiceMap field = lib.variables.singleWhere((v) => v.name == varName);
53 Instance value = field['value'];
54 expect(value.valueAsString, equals(varValueAsString));
55 expect(value.valueAsStringIsTruncated, isFalse);
56 }
57 expectTruncatedString(String varName, String varValueAsString) {
58 ServiceMap field = lib.variables.singleWhere((v) => v.name == varName);
59 Instance value = field['value'];
60 expect(varValueAsString, startsWith(value.valueAsString));
61 expect(value.valueAsStringIsTruncated, isTrue);
62 }
63
64 script(); // Need to initialize variables in the testing isolate.
65 expectFullString('ascii', ascii);
66 expectFullString('latin1', latin1);
67 expectFullString('unicode', unicode);
68 expectFullString('hebrew', hebrew);
69 expectFullString('singleQuotes', singleQuotes);
70 expectFullString('doubleQuotes', doubleQuotes);
71 expectFullString('newLines', newLines);
72 expectFullString('tabs', tabs);
73 expectFullString('suggrogatePairs', suggrogatePairs);
74 expectFullString('nullInTheMiddle', nullInTheMiddle); /// 01: ok
75 expectTruncatedString('longStringEven', longStringEven);
76 expectTruncatedString('longStringOdd', longStringOdd);
77 }),
78
79 ];
80
81 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698