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

Side by Side Diff: runtime/observatory/tests/service/string_escaping_test.dart

Issue 2085683003: Fix string_escaping_test exiting early by re-writing to use async-await. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 library string_escaping_test; 6 library string_escaping_test;
7 7
8 import 'package:observatory/service_io.dart'; 8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
(...skipping 30 matching lines...) Expand all
41 // A surrogate pair will cross the preferred truncation boundry. 41 // A surrogate pair will cross the preferred truncation boundry.
42 longStringEven = ".."; 42 longStringEven = "..";
43 for (int i = 0; i < 512; i++) longStringEven += "𝄞"; 43 for (int i = 0; i < 512; i++) longStringEven += "𝄞";
44 longStringOdd = "."; 44 longStringOdd = ".";
45 for (int i = 0; i < 512; i++) longStringOdd += "𝄞"; 45 for (int i = 0; i < 512; i++) longStringOdd += "𝄞";
46 46
47 malformedWithLeadSurrogate = "before" + "𝄞"[0] + "after"; 47 malformedWithLeadSurrogate = "before" + "𝄞"[0] + "after";
48 malformedWithTrailSurrogate = "before" + "𝄞"[1] + "after"; 48 malformedWithTrailSurrogate = "before" + "𝄞"[1] + "after";
49 } 49 }
50 50
51 testStrings(Isolate isolate) async {
52 Library lib = isolate.rootLibrary;
53 await lib.load();
54 for (var variable in lib.variables) {
55 await variable.load();
56 }
57
58 expectFullString(String varName, String varValueAsString) {
59 Field field = lib.variables.singleWhere((v) => v.name == varName);
60 Instance value = field.staticValue;
61 expect(value.valueAsString, equals(varValueAsString));
62 expect(value.valueAsStringIsTruncated, isFalse);
63 }
64
65 expectTruncatedString(String varName, String varValueAsString) {
66 Field field = lib.variables.singleWhere((v) => v.name == varName);
67 Instance value = field.staticValue;
68 print(value.valueAsString);
69 expect(varValueAsString, startsWith(value.valueAsString));
70 expect(value.valueAsStringIsTruncated, isTrue);
71 }
72
73 script(); // Need to initialize variables in the testing isolate.
74 expectFullString('ascii', ascii);
75 expectFullString('latin1', latin1);
76 expectFullString('unicode', unicode);
77 expectFullString('hebrew', hebrew);
78 expectFullString('singleQuotes', singleQuotes);
79 expectFullString('doubleQuotes', doubleQuotes);
80 expectFullString('newLines', newLines);
81 expectFullString('tabs', tabs);
82 expectFullString('suggrogatePairs', suggrogatePairs);
83 expectFullString('nullInTheMiddle', nullInTheMiddle);
84 expectTruncatedString('longStringEven', longStringEven);
85 expectTruncatedString('longStringOdd', longStringOdd);
86 expectFullString('malformedWithLeadSurrogate', malformedWithLeadSurrogate);
87 expectFullString('malformedWithTrailSurrogate', malformedWithTrailSurrogate);
88 }
89
51 var tests = [ 90 var tests = [
52 91 testStrings,
53 (Isolate isolate) =>
54 isolate.rootLibrary.load().then((Library lib) {
55 expectFullString(String varName, String varValueAsString) {
56 Field field = lib.variables.singleWhere((v) => v.name == varName);
57 field.load().then((_) {
58 Instance value = field.staticValue;
59 expect(value.valueAsString, equals(varValueAsString));
60 expect(value.valueAsStringIsTruncated, isFalse);
61 });
62 }
63 expectTruncatedString(String varName, String varValueAsString) {
64 Field field = lib.variables.singleWhere((v) => v.name == varName);
65 field.load().then((_) {
66 Instance value = field.staticValue;
67 expect(varValueAsString, startsWith(value.valueAsString));
68 expect(value.valueAsStringIsTruncated, isTrue);
69 });
70 }
71
72 script(); // Need to initialize variables in the testing isolate.
73 expectFullString('ascii', ascii);
74 expectFullString('latin1', latin1);
75 expectFullString('unicode', unicode);
76 expectFullString('hebrew', hebrew);
77 expectFullString('singleQuotes', singleQuotes);
78 expectFullString('doubleQuotes', doubleQuotes);
79 expectFullString('newLines', newLines);
80 expectFullString('tabs', tabs);
81 expectFullString('suggrogatePairs', suggrogatePairs);
82 expectFullString('nullInTheMiddle', nullInTheMiddle);
83 expectTruncatedString('longStringEven', longStringEven);
84 expectTruncatedString('longStringOdd', longStringOdd);
85 expectFullString('malformedWithLeadSurrogate', malformedWithLeadSurrogate);
86 expectFullString('malformedWithTrailSurrogate', malformedWithTrailSurrogate) ;
87 }),
88
89 ]; 92 ];
90 93
91 main(args) => runIsolateTests(args, tests, testeeBefore: script); 94 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698