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

Side by Side Diff: pkg/source_maps/test/parser_test.dart

Issue 237123003: Support unmapped areas in source maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adressed comments. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/source_maps/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:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'package:source_maps/source_maps.dart'; 9 import 'package:source_maps/source_maps.dart';
10 import 'common.dart'; 10 import 'common.dart';
11 11
12 const Map<String, dynamic> MAP_WITH_NO_SOURCE_LOCATION = const {
13 'version': 3,
14 'sourceRoot': '',
15 'sources': const ['input.dart'],
16 'names': const [],
17 'mappings': 'A',
18 'file': 'output.dart'
19 };
20
21 const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION = const {
22 'version': 3,
23 'sourceRoot': '',
24 'sources': const ['input.dart'],
25 'names': const [],
26 'mappings': 'AAAA',
27 'file': 'output.dart'
28 };
29
30 const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME = const {
31 'version': 3,
32 'sourceRoot': '',
33 'sources': const ['input.dart'],
34 'names': const ['var'],
35 'mappings': 'AAAAA',
36 'file': 'output.dart'
37 };
38
12 main() { 39 main() {
13 test('parse', () { 40 test('parse', () {
14 var mapping = parseJson(EXPECTED_MAP); 41 var mapping = parseJson(EXPECTED_MAP);
15 check(outputVar1, mapping, inputVar1, false); 42 check(outputVar1, mapping, inputVar1, false);
16 check(outputVar2, mapping, inputVar2, false); 43 check(outputVar2, mapping, inputVar2, false);
17 check(outputFunction, mapping, inputFunction, false); 44 check(outputFunction, mapping, inputFunction, false);
18 check(outputExpr, mapping, inputExpr, false); 45 check(outputExpr, mapping, inputExpr, false);
19 }); 46 });
20 47
21 test('parse + json', () { 48 test('parse + json', () {
22 var mapping = parse(JSON.encode(EXPECTED_MAP)); 49 var mapping = parse(JSON.encode(EXPECTED_MAP));
23 check(outputVar1, mapping, inputVar1, false); 50 check(outputVar1, mapping, inputVar1, false);
24 check(outputVar2, mapping, inputVar2, false); 51 check(outputVar2, mapping, inputVar2, false);
25 check(outputFunction, mapping, inputFunction, false); 52 check(outputFunction, mapping, inputFunction, false);
26 check(outputExpr, mapping, inputExpr, false); 53 check(outputExpr, mapping, inputExpr, false);
27 }); 54 });
28 55
29 test('parse with file', () { 56 test('parse with file', () {
30 var mapping = parseJson(EXPECTED_MAP); 57 var mapping = parseJson(EXPECTED_MAP);
31 check(outputVar1, mapping, inputVar1, true); 58 check(outputVar1, mapping, inputVar1, true);
32 check(outputVar2, mapping, inputVar2, true); 59 check(outputVar2, mapping, inputVar2, true);
33 check(outputFunction, mapping, inputFunction, true); 60 check(outputFunction, mapping, inputFunction, true);
34 check(outputExpr, mapping, inputExpr, true); 61 check(outputExpr, mapping, inputExpr, true);
35 }); 62 });
63
64 test('parse with no source location', () {
65 SingleMapping map = parse(JSON.encode(MAP_WITH_NO_SOURCE_LOCATION));
66 expect(map.lines.length, 1);
67 expect(map.lines.first.entries.length, 1);
68 TargetEntry entry = map.lines.first.entries.first;
69
70 expect(entry.column, 0);
71 expect(entry.sourceUrlId, null);
72 expect(entry.sourceColumn, null);
73 expect(entry.sourceLine, null);
74 expect(entry.sourceNameId, null);
75 });
76
77 test('parse with source location and no name', () {
78 SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION));
79 expect(map.lines.length, 1);
80 expect(map.lines.first.entries.length, 1);
81 TargetEntry entry = map.lines.first.entries.first;
82
83 expect(entry.column, 0);
84 expect(entry.sourceUrlId, 0);
85 expect(entry.sourceColumn, 0);
86 expect(entry.sourceLine, 0);
87 expect(entry.sourceNameId, null);
88 });
89
90 test('parse with source location and name', () {
91 SingleMapping map = parse(JSON.encode(MAP_WITH_SOURCE_LOCATION_AND_NAME));
92 expect(map.lines.length, 1);
93 expect(map.lines.first.entries.length, 1);
94 TargetEntry entry = map.lines.first.entries.first;
95
96 expect(entry.sourceUrlId, 0);
97 expect(entry.sourceUrlId, 0);
98 expect(entry.sourceColumn, 0);
99 expect(entry.sourceLine, 0);
100 expect(entry.sourceNameId, 0);
101 });
36 } 102 }
OLDNEW
« no previous file with comments | « pkg/source_maps/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698