OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |