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

Side by Side Diff: tests/corelib/stacktrace_current_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import "dart:convert" show LineSplitter; 5 import "dart:convert" show LineSplitter;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 void main() { 9 void main() {
10 var st0; 10 var st0;
11 var st1; 11 var st1;
12 // Primitive way to get stack trace,. 12 // Primitive way to get stack trace,.
13 try { throw 0; } catch (_, s) { st0 = s; } 13 try {
14 throw 0;
15 } catch (_, s) {
16 st0 = s;
17 }
14 st1 = StackTrace.current; 18 st1 = StackTrace.current;
15 19
16 var st0s = findMain(st0); 20 var st0s = findMain(st0);
17 var st1s = findMain(st1); 21 var st1s = findMain(st1);
18 // Stack traces are not equal (contains at least a different line number, 22 // Stack traces are not equal (contains at least a different line number,
19 // and possible different frame numbers). 23 // and possible different frame numbers).
20 // They are *similar*, so check that they agree on everything but numbers. 24 // They are *similar*, so check that they agree on everything but numbers.
21 var digits = new RegExp(r"\d+"); 25 var digits = new RegExp(r"\d+");
22 Expect.equals(st0s.replaceAll(digits, "0"), st1s.replaceAll(digits, "0")); 26 Expect.equals(st0s.replaceAll(digits, "0"), st1s.replaceAll(digits, "0"));
23 } 27 }
24 28
25 String findMain(StackTrace stack) { 29 String findMain(StackTrace stack) {
26 var string = "$stack"; 30 var string = "$stack";
27 var lines = LineSplitter.split(string).toList(); 31 var lines = LineSplitter.split(string).toList();
28 while (lines.isNotEmpty && !lines.first.contains("main")) { 32 while (lines.isNotEmpty && !lines.first.contains("main")) {
29 lines.removeAt(0); 33 lines.removeAt(0);
30 } 34 }
31 return lines.join("\n"); 35 return lines.join("\n");
32 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698