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

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

Issue 19019006: Fix bug in source-maps parsing: parser failed when most information could be (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
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 /// Common input/output used by builder, parser and end2end tests 5 /// Common input/output used by builder, parser and end2end tests
6 library test.common; 6 library test.common;
7 7
8 import 'package:source_maps/source_maps.dart'; 8 import 'package:source_maps/source_maps.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 /// Content of the source file 11 /// Content of the source file
12 const String INPUT = ''' 12 const String INPUT = '''
13 /** this is a comment. */ 13 /** this is a comment. */
14 int longVar1 = 3; 14 int longVar1 = 3;
15 15
16 // this is a comment too 16 // this is a comment too
17 int longName(int longVar2) { 17 int longName(int longVar2) {
18 return longVar1 + longVar2; 18 return longVar1 + longVar2;
19 } 19 }
20 '''; 20 ''';
21 var input = new SourceFile.text('input.dart', INPUT); 21 var input = new SourceFile.text('input.dart', INPUT);
22 22
23 /// A span in the input file 23 /// A span in the input file
24 Span ispan(int start, int end, [bool isIdentifier = false]) => 24 Span ispan(int start, int end, [bool isIdentifier = false]) =>
25 new FileSpan(input, start, end, isIdentifier); 25 new FileSpan(input, start, end, isIdentifier);
26 26
27 Span inputVar1 = ispan(30, 38, true); 27 Span inputVar1 = ispan(30, 38, true);
28 Span inputFunction = ispan(74, 82, true); 28 Span inputFunction = ispan(74, 82, true);
29 Span inputVar2 = ispan(87, 95, true); 29 Span inputVar2 = ispan(87, 95, true);
30
31 Span inputVar1NoSymbol = ispan(30, 38);
32 Span inputFunctionNoSymbol = ispan(74, 82);
33 Span inputVar2NoSymbol = ispan(87, 95);
34
30 Span inputExpr = ispan(108, 127); 35 Span inputExpr = ispan(108, 127);
31 36
32 /// Content of the target file 37 /// Content of the target file
33 const String OUTPUT = ''' 38 const String OUTPUT = '''
34 var x = 3; 39 var x = 3;
35 f(y) => x + y; 40 f(y) => x + y;
36 '''; 41 ''';
37 var output = new SourceFile.text('output.dart', OUTPUT); 42 var output = new SourceFile.text('output.dart', OUTPUT);
38 43
39 /// A span in the output file 44 /// A span in the output file
40 Span ospan(int start, int end, [bool isIdentifier = false]) => 45 Span ospan(int start, int end, [bool isIdentifier = false]) =>
41 new FileSpan(output, start, end, isIdentifier); 46 new FileSpan(output, start, end, isIdentifier);
42 47
43 Span outputVar1 = ospan(4, 5, true); 48 Span outputVar1 = ospan(4, 5, true);
44 Span outputFunction = ospan(11, 12, true); 49 Span outputFunction = ospan(11, 12, true);
45 Span outputVar2 = ospan(13, 14, true); 50 Span outputVar2 = ospan(13, 14, true);
51 Span outputVar1NoSymbol = ospan(4, 5);
52 Span outputFunctionNoSymbol = ospan(11, 12);
53 Span outputVar2NoSymbol = ospan(13, 14);
46 Span outputExpr = ospan(19, 24); 54 Span outputExpr = ospan(19, 24);
47 55
48 /// Expected output mapping when recording the following four mappings: 56 /// Expected output mapping when recording the following four mappings:
49 /// inputVar1 <= outputVar1 57 /// inputVar1 <= outputVar1
50 /// inputFunction <= outputFunction 58 /// inputFunction <= outputFunction
51 /// inputVar2 <= outputVar2 59 /// inputVar2 <= outputVar2
52 /// inputExpr <= outputExpr 60 /// inputExpr <= outputExpr
53 /// 61 ///
54 /// This mapping is stored in the tests so we can independently test the builder 62 /// This mapping is stored in the tests so we can independently test the builder
55 /// and parser algorithms without relying entirely on end2end tests. 63 /// and parser algorithms without relying entirely on end2end tests.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 expect(span.end.line, inputSpan.end.line); 96 expect(span.end.line, inputSpan.end.line);
89 expect(span.end.column, inputSpan.end.column); 97 expect(span.end.column, inputSpan.end.column);
90 expect(span.end.offset, span.start.offset + inputSpan.text.length); 98 expect(span.end.offset, span.start.offset + inputSpan.text.length);
91 if (realOffsets) expect(span.end.offset, inputSpan.end.offset); 99 if (realOffsets) expect(span.end.offset, inputSpan.end.offset);
92 } else { 100 } else {
93 expect(span.end.offset, span.start.offset); 101 expect(span.end.offset, span.start.offset);
94 expect(span.end.line, span.start.line); 102 expect(span.end.line, span.start.line);
95 expect(span.end.column, span.start.column); 103 expect(span.end.column, span.start.column);
96 } 104 }
97 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698