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

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

Issue 12207008: Move source maps package to the dart repo, so it can be used by other internal (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updates Created 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/source_maps/test/parser_test.dart ('k') | pkg/source_maps/test/run.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.printer_test;
6
7 import 'dart:json' as json;
8 import 'package:unittest/unittest.dart';
9 import 'package:source_maps/printer.dart';
10 import 'package:source_maps/span.dart';
11 import 'common.dart';
12
13 main() {
14 test('printer', () {
15 var printer = new Printer('output.dart');
16 printer..add('var ')
17 ..mark(inputVar1)
18 ..add('x = 3;\n')
19 ..mark(inputFunction)
20 ..add('f(')
21 ..mark(inputVar2)
22 ..add('y) => ')
23 ..mark(inputExpr)
24 ..add('x + y;\n');
25 expect(printer.text, OUTPUT);
26 expect(printer.map, json.stringify(EXPECTED_MAP));
27 });
28
29 test('printer projecting marks', () {
30 var out = INPUT.replaceAll('long', '_s');
31 var printer = new Printer('output2.dart');
32
33 var segments = INPUT.split('long');
34 expect(segments.length, 6);
35 printer..mark(ispan(0, 0))
36 ..add(segments[0], projectMarks: true)
37 ..mark(inputVar1)
38 ..add('_s')
39 ..add(segments[1], projectMarks: true)
40 ..mark(inputFunction)
41 ..add('_s')
42 ..add(segments[2], projectMarks: true)
43 ..mark(inputVar2)
44 ..add('_s')
45 ..add(segments[3], projectMarks: true)
46 ..mark(inputExpr)
47 ..add('_s')
48 ..add(segments[4], projectMarks: true)
49 ..add('_s')
50 ..add(segments[5], projectMarks: true);
51
52 expect(printer.text, out);
53 // 8 new lines in the source map:
54 expect(printer.map.split(';').length, 8);
55
56 asFixed(Span s) => new FixedSpan(s.sourceUrl,
57 s.start.offset, s.start.line, s.start.column,
58 text: s.text, isIdentifier: s.isIdentifier);
59
60 // The result is the same if we use fixed positions
61 var printer2 = new Printer('output2.dart');
62 printer2..mark(new FixedSpan('input.dart', 0, 0, 0))
63 ..add(segments[0], projectMarks: true)
64 ..mark(asFixed(inputVar1))
65 ..add('_s')
66 ..add(segments[1], projectMarks: true)
67 ..mark(asFixed(inputFunction))
68 ..add('_s')
69 ..add(segments[2], projectMarks: true)
70 ..mark(asFixed(inputVar2))
71 ..add('_s')
72 ..add(segments[3], projectMarks: true)
73 ..mark(asFixed(inputExpr))
74 ..add('_s')
75 ..add(segments[4], projectMarks: true)
76 ..add('_s')
77 ..add(segments[5], projectMarks: true);
78
79 expect(printer2.text, out);
80 expect(printer2.map, printer.map);
81 });
82 }
OLDNEW
« no previous file with comments | « pkg/source_maps/test/parser_test.dart ('k') | pkg/source_maps/test/run.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698