OLD | NEW |
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.end2end_test; | 5 library test.end2end_test; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 import 'package:source_maps/source_maps.dart'; | 8 import 'package:source_maps/source_maps.dart'; |
9 import 'common.dart'; | 9 import 'common.dart'; |
10 | 10 |
11 main() { | 11 main() { |
12 test('end-to-end setup', () { | 12 test('end-to-end setup', () { |
13 expect(inputVar1.text, 'longVar1'); | 13 expect(inputVar1.text, 'longVar1'); |
14 expect(inputFunction.text, 'longName'); | 14 expect(inputFunction.text, 'longName'); |
15 expect(inputVar2.text, 'longVar2'); | 15 expect(inputVar2.text, 'longVar2'); |
| 16 expect(inputVar1NoSymbol.text, 'longVar1'); |
| 17 expect(inputFunctionNoSymbol.text, 'longName'); |
| 18 expect(inputVar2NoSymbol.text, 'longVar2'); |
16 expect(inputExpr.text, 'longVar1 + longVar2'); | 19 expect(inputExpr.text, 'longVar1 + longVar2'); |
17 | 20 |
18 expect(outputVar1.text, 'x'); | 21 expect(outputVar1.text, 'x'); |
19 expect(outputFunction.text, 'f'); | 22 expect(outputFunction.text, 'f'); |
20 expect(outputVar2.text, 'y'); | 23 expect(outputVar2.text, 'y'); |
| 24 expect(outputVar1NoSymbol.text, 'x'); |
| 25 expect(outputFunctionNoSymbol.text, 'f'); |
| 26 expect(outputVar2NoSymbol.text, 'y'); |
21 expect(outputExpr.text, 'x + y'); | 27 expect(outputExpr.text, 'x + y'); |
22 }); | 28 }); |
23 | 29 |
24 test('build + parse', () { | 30 test('build + parse', () { |
25 var map = (new SourceMapBuilder() | 31 var map = (new SourceMapBuilder() |
26 ..addSpan(inputVar1, outputVar1) | 32 ..addSpan(inputVar1, outputVar1) |
27 ..addSpan(inputFunction, outputFunction) | 33 ..addSpan(inputFunction, outputFunction) |
28 ..addSpan(inputVar2, outputVar2) | 34 ..addSpan(inputVar2, outputVar2) |
29 ..addSpan(inputExpr, outputExpr)) | 35 ..addSpan(inputExpr, outputExpr)) |
30 .build(output.url); | 36 .build(output.url); |
31 var mapping = parseJson(map); | 37 var mapping = parseJson(map); |
32 check(outputVar1, mapping, inputVar1, false); | 38 check(outputVar1, mapping, inputVar1, false); |
33 check(outputVar2, mapping, inputVar2, false); | 39 check(outputVar2, mapping, inputVar2, false); |
34 check(outputFunction, mapping, inputFunction, false); | 40 check(outputFunction, mapping, inputFunction, false); |
35 check(outputExpr, mapping, inputExpr, false); | 41 check(outputExpr, mapping, inputExpr, false); |
36 }); | 42 }); |
37 | 43 |
| 44 test('build + parse - no symbols', () { |
| 45 var map = (new SourceMapBuilder() |
| 46 ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) |
| 47 ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) |
| 48 ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) |
| 49 ..addSpan(inputExpr, outputExpr)) |
| 50 .build(output.url); |
| 51 var mapping = parseJson(map); |
| 52 check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); |
| 53 check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); |
| 54 check(outputFunctionNoSymbol, mapping, inputFunctionNoSymbol, false); |
| 55 check(outputExpr, mapping, inputExpr, false); |
| 56 }); |
| 57 |
| 58 test('build + parse, repeated entries', () { |
| 59 var map = (new SourceMapBuilder() |
| 60 ..addSpan(inputVar1, outputVar1) |
| 61 ..addSpan(inputVar1, outputVar1) |
| 62 ..addSpan(inputFunction, outputFunction) |
| 63 ..addSpan(inputFunction, outputFunction) |
| 64 ..addSpan(inputVar2, outputVar2) |
| 65 ..addSpan(inputVar2, outputVar2) |
| 66 ..addSpan(inputExpr, outputExpr) |
| 67 ..addSpan(inputExpr, outputExpr)) |
| 68 .build(output.url); |
| 69 var mapping = parseJson(map); |
| 70 check(outputVar1, mapping, inputVar1, false); |
| 71 check(outputVar2, mapping, inputVar2, false); |
| 72 check(outputFunction, mapping, inputFunction, false); |
| 73 check(outputExpr, mapping, inputExpr, false); |
| 74 }); |
| 75 |
| 76 test('build + parse - no symbols, repeated entries', () { |
| 77 var map = (new SourceMapBuilder() |
| 78 ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) |
| 79 ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol) |
| 80 ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) |
| 81 ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol) |
| 82 ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) |
| 83 ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol) |
| 84 ..addSpan(inputExpr, outputExpr)) |
| 85 .build(output.url); |
| 86 var mapping = parseJson(map); |
| 87 check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false); |
| 88 check(outputVar2NoSymbol, mapping, inputVar2NoSymbol, false); |
| 89 check(outputFunctionNoSymbol, mapping, inputFunctionNoSymbol, false); |
| 90 check(outputExpr, mapping, inputExpr, false); |
| 91 }); |
| 92 |
38 test('build + parse with file', () { | 93 test('build + parse with file', () { |
39 var json = (new SourceMapBuilder() | 94 var json = (new SourceMapBuilder() |
40 ..addSpan(inputVar1, outputVar1) | 95 ..addSpan(inputVar1, outputVar1) |
41 ..addSpan(inputFunction, outputFunction) | 96 ..addSpan(inputFunction, outputFunction) |
42 ..addSpan(inputVar2, outputVar2) | 97 ..addSpan(inputVar2, outputVar2) |
43 ..addSpan(inputExpr, outputExpr)) | 98 ..addSpan(inputExpr, outputExpr)) |
44 .toJson(output.url); | 99 .toJson(output.url); |
45 var mapping = parse(json); | 100 var mapping = parse(json); |
46 check(outputVar1, mapping, inputVar1, true); | 101 check(outputVar1, mapping, inputVar1, true); |
47 check(outputVar2, mapping, inputVar2, true); | 102 check(outputVar2, mapping, inputVar2, true); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 152 |
98 // Start of the last line | 153 // Start of the last line |
99 var oOffset = out.length - 2; | 154 var oOffset = out.length - 2; |
100 var iOffset = INPUT.length - 2; | 155 var iOffset = INPUT.length - 2; |
101 check(new FileSpan(file, oOffset, oOffset, false), mapping, | 156 check(new FileSpan(file, oOffset, oOffset, false), mapping, |
102 ispan(iOffset, iOffset), true); | 157 ispan(iOffset, iOffset), true); |
103 check(new FileSpan(file, oOffset + 1, oOffset + 1, false), mapping, | 158 check(new FileSpan(file, oOffset + 1, oOffset + 1, false), mapping, |
104 ispan(iOffset, iOffset), true); | 159 ispan(iOffset, iOffset), true); |
105 }); | 160 }); |
106 } | 161 } |
OLD | NEW |