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

Side by Side Diff: test/parser_test.dart

Issue 2736983002: Enabling adding and querying for source maps in a MappingBundle. (Closed)
Patch Set: Enabling adding and querying for source maps in a MappingBundle. Created 3 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test.parser_test; 5 library test.parser_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:source_maps/source_maps.dart'; 9 import 'package:source_maps/source_maps.dart';
10 import 'package:source_span/source_span.dart'; 10 import 'package:source_span/source_span.dart';
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 mapUrl: "file:///path/to/map"); 255 mapUrl: "file:///path/to/map");
256 256
257 expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl, 257 expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl,
258 Uri.parse("file:///path/to/pkg/input1.dart")); 258 Uri.parse("file:///path/to/pkg/input1.dart"));
259 expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl, 259 expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl,
260 Uri.parse("file:///path/to/pkg/input2.dart")); 260 Uri.parse("file:///path/to/pkg/input2.dart"));
261 expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl, 261 expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl,
262 Uri.parse("file:///path/to/pkg/input3.dart")); 262 Uri.parse("file:///path/to/pkg/input3.dart"));
263 }); 263 });
264 264
265 test('build bundle incrementally', () {
266 var mapping = new MappingBundle();
267
268 mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1,
269 mapUrl: "file:///path/to/map"));
270 expect(mapping.spanFor(0, 0, uri: "output.dart").sourceUrl,
271 Uri.parse("file:///path/to/pkg/input1.dart"));
272
273 expect(mapping.containsMapping("output2.dart"), isFalse);
274 mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_2,
275 mapUrl: "file:///path/to/map"));
276 expect(mapping.containsMapping("output2.dart"), isTrue);
277 expect(mapping.spanFor(0, 0, uri: "output2.dart").sourceUrl,
278 Uri.parse("file:///path/to/pkg/input2.dart"));
279
280 expect(mapping.containsMapping("3/output.dart"), isFalse);
281 mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_3,
282 mapUrl: "file:///path/to/map"));
283 expect(mapping.containsMapping("3/output.dart"), isTrue);
284 expect(mapping.spanFor(0, 0, uri: "3/output.dart").sourceUrl,
285 Uri.parse("file:///path/to/pkg/input3.dart"));
286 });
287
265 // Test that the source map can handle cases where the uri passed in is 288 // Test that the source map can handle cases where the uri passed in is
266 // not from the expected host but it is still unambiguous which source 289 // not from the expected host but it is still unambiguous which source
267 // map should be used. 290 // map should be used.
268 test('different paths', () { 291 test('different paths', () {
269 expect( 292 expect(
270 mapping 293 mapping
271 .spanForLocation(new SourceLocation(0, 294 .spanForLocation(new SourceLocation(0,
272 sourceUrl: Uri.parse('http://localhost/output.dart'))) 295 sourceUrl: Uri.parse('http://localhost/output.dart')))
273 .sourceUrl, 296 .sourceUrl,
274 Uri.parse("file:///path/to/pkg/input1.dart")); 297 Uri.parse("file:///path/to/pkg/input1.dart"));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 mapping = parseJsonExtended(expected); 335 mapping = parseJsonExtended(expected);
313 expect(mapping.toJson(), equals(expected)); 336 expect(mapping.toJson(), equals(expected));
314 } 337 }
315 // Invalid for this case 338 // Invalid for this case
316 expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws); 339 expect(() => parseJson(SOURCE_MAP_BUNDLE as dynamic), throws);
317 340
318 var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE); 341 var mapping = parseJsonExtended(SOURCE_MAP_BUNDLE);
319 expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE)); 342 expect(mapping.toJson(), equals(SOURCE_MAP_BUNDLE));
320 }); 343 });
321 } 344 }
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