| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:convert'; |
| 6 import 'package:source_maps/source_maps.dart'; |
| 7 import 'package:unittest/unittest.dart'; |
| 8 import 'load.dart'; |
| 9 import 'save.dart'; |
| 10 |
| 11 const String SOURCEMAP = ''' |
| 12 { |
| 13 "version": 3, |
| 14 "file": "out.js", |
| 15 "sourceRoot": "", |
| 16 "sources": ["sdk/lib/_internal/compiler/js_lib/js_primitives.dart","hello_worl
d.dart","sdk/lib/_internal/compiler/js_lib/internal_patch.dart"], |
| 17 "names": ["printString","main","printToConsole"], |
| 18 "mappings": "A;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;eAoBAA;;;AAIIA;;;;AAOAA;;;AAKAA;;;AAMAA;
;;GAOJA;;sC;;QC5CAC;;ICYEC;GDRFD;;;;A;A;A;;;A;;;A;A;A;A;A;A;A;;;;;;A;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A
;C;;;;;;;;;;;;;;;;;;;;;;;;;;;;A" |
| 19 }'''; |
| 20 |
| 21 const String HUMAN_READABLE_SOURCE_MAP = ''' |
| 22 { |
| 23 "file": "out.js", |
| 24 "sourceRoot": "", |
| 25 "sources": { |
| 26 "0": "out.js.map", |
| 27 "1": "test.dart", |
| 28 "2": "out.js" |
| 29 }, |
| 30 "lines": [ |
| 31 {"target": "3,3-", "source": "1:2,17"}, |
| 32 {"target": "4,3-", "source": "1:3,17"}, |
| 33 {"target": "5,3-15", "source": "1:4,17"}, |
| 34 {"target": "5,15-20", "source": "1:5,17"}, |
| 35 {"target": "5,20-", "source": "1:6,4"}, |
| 36 {"target": "6,3-", "source": "1:7,17"}, |
| 37 {"target": "7,3-", "source": "1:8,17"}, |
| 38 {"target": "8,1-", "source": "1:9,1"}, |
| 39 {"target": "10,3-", "source": "1:11,17"}, |
| 40 {"target": "11,3-", "source": "1:12,17"}, |
| 41 {"target": "12,3-", "source": "1:13,17"}, |
| 42 {"target": "13,3-", "source": "1:14,17"}, |
| 43 {"target": "14,1-", "source": "1:15,4"} |
| 44 ] |
| 45 }'''; |
| 46 |
| 47 void main() { |
| 48 test('read/write', () { |
| 49 SingleMapping sourceMap = |
| 50 new SingleMapping.fromJson(JSON.decode(SOURCEMAP)); |
| 51 String humanReadable = convertToHumanReadableSourceMap(sourceMap); |
| 52 SingleMapping sourceMap2 = convertFromHumanReadableSourceMap(humanReadable); |
| 53 String humanReadable2 = convertToHumanReadableSourceMap(sourceMap2); |
| 54 SingleMapping sourceMap3 = |
| 55 convertFromHumanReadableSourceMap(humanReadable2); |
| 56 String humanReadable3 = convertToHumanReadableSourceMap(sourceMap3); |
| 57 |
| 58 // Target line entries without sourceUrl are removed. |
| 59 //expect(sourceMap.toJson(), equals(sourceMap2.toJson())); |
| 60 expect(sourceMap2.toJson(), equals(sourceMap3.toJson())); |
| 61 expect(JSON.decode(humanReadable), equals(JSON.decode(humanReadable2))); |
| 62 expect(JSON.decode(humanReadable2), equals(JSON.decode(humanReadable3))); |
| 63 }); |
| 64 |
| 65 test('write/read', () { |
| 66 SingleMapping sourceMap = |
| 67 convertFromHumanReadableSourceMap(HUMAN_READABLE_SOURCE_MAP); |
| 68 print(sourceMap); |
| 69 String humanReadable = convertToHumanReadableSourceMap(sourceMap); |
| 70 print(humanReadable); |
| 71 SingleMapping sourceMap2 = convertFromHumanReadableSourceMap(humanReadable); |
| 72 expect(JSON.decode(HUMAN_READABLE_SOURCE_MAP), |
| 73 equals(JSON.decode(humanReadable))); |
| 74 expect(sourceMap.toJson(), equals(sourceMap2.toJson())); |
| 75 }); |
| 76 } |
| OLD | NEW |