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

Side by Side Diff: test/source_map_stack_trace_test.dart

Issue 1108053006: Don't crash when mapping stack chains. (Closed) Base URL: git@github.com:dart-lang/source_map_stack_trace.git@master
Patch Set: Created 5 years, 7 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 | « pubspec.yaml ('k') | 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) 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 'package:source_maps/source_maps.dart'; 5 import 'package:source_maps/source_maps.dart';
6 import 'package:source_span/source_span.dart'; 6 import 'package:source_span/source_span.dart';
7 import 'package:stack_trace/stack_trace.dart'; 7 import 'package:stack_trace/stack_trace.dart';
8 import 'package:source_map_stack_trace/source_map_stack_trace.dart'; 8 import 'package:source_map_stack_trace/source_map_stack_trace.dart';
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 new SourceLocation(12, line: 9, column: 1), 115 new SourceLocation(12, line: 9, column: 1),
116 "\n" * 4)); 116 "\n" * 4));
117 117
118 var mapping = parseJson(builder.build("foo.dart.js.map")); 118 var mapping = parseJson(builder.build("foo.dart.js.map"));
119 var frame = mapStackTrace(mapping, trace, sdkRoot: "sdk/").frames.first; 119 var frame = mapStackTrace(mapping, trace, sdkRoot: "sdk/").frames.first;
120 expect(frame.uri, equals(Uri.parse("dart:async/foo.dart"))); 120 expect(frame.uri, equals(Uri.parse("dart:async/foo.dart")));
121 expect(frame.line, equals(2)); 121 expect(frame.line, equals(2));
122 expect(frame.column, equals(4)); 122 expect(frame.column, equals(4));
123 }); 123 });
124 124
125 test("converts a stack chain", () {
126 var trace = new Chain([
127 new Trace.parse("foo.dart.js 10:11 foo"),
128 new Trace.parse("foo.dart.js 10:11 bar")
129 ]);
130 var traces = mapStackTrace(_simpleMapping, trace).traces;
131
132 var frame = traces.first.frames.single;
133 expect(frame.uri, equals(Uri.parse("foo.dart")));
134 expect(frame.member, equals("foo"));
135 expect(frame.line, equals(2));
136 expect(frame.column, equals(4));
137
138 frame = traces.last.frames.single;
139 expect(frame.uri, equals(Uri.parse("foo.dart")));
140 expect(frame.member, equals("bar"));
141 expect(frame.line, equals(2));
142 expect(frame.column, equals(4));
143 });
144
125 group("cleans up", () { 145 group("cleans up", () {
126 test("Firefox junk", () { 146 test("Firefox junk", () {
127 expect(_prettify("foo/<"), equals("foo")); 147 expect(_prettify("foo/<"), equals("foo"));
128 expect(_prettify("foo<"), equals("foo")); 148 expect(_prettify("foo<"), equals("foo"));
129 }); 149 });
130 150
131 test("arity indicators", () { 151 test("arity indicators", () {
132 expect(_prettify(r"foo$1"), equals("foo")); 152 expect(_prettify(r"foo$1"), equals("foo"));
133 expect(_prettify(r"foo$1234"), equals("foo")); 153 expect(_prettify(r"foo$1234"), equals("foo"));
134 }); 154 });
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 equals("Foo.<fn>")); 188 equals("Foo.<fn>"));
169 }); 189 });
170 }); 190 });
171 } 191 }
172 192
173 /// Runs the mapper's prettification logic on [member] and returns the result. 193 /// Runs the mapper's prettification logic on [member] and returns the result.
174 String _prettify(String member) { 194 String _prettify(String member) {
175 var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]); 195 var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]);
176 return mapStackTrace(_simpleMapping, trace).frames.first.member; 196 return mapStackTrace(_simpleMapping, trace).frames.first.member;
177 } 197 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698