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

Side by Side Diff: tests/compiler/dart2js/source_mapping_test.dart

Issue 27510003: Scanner for UTF-8 byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes compiler tests Created 7 years, 2 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:async'; 5 import 'dart:async';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"; 8 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
9 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
10 import "mock_compiler.dart"; 10 import "mock_compiler.dart";
(...skipping 10 matching lines...) Expand all
21 21
22 void testSourceMapLocations(String codeWithMarkers) { 22 void testSourceMapLocations(String codeWithMarkers) {
23 List<int> expectedLocations = new List<int>(); 23 List<int> expectedLocations = new List<int>();
24 for (int i = 0; i < codeWithMarkers.length; ++i) { 24 for (int i = 0; i < codeWithMarkers.length; ++i) {
25 if (codeWithMarkers[i] == '@') { 25 if (codeWithMarkers[i] == '@') {
26 expectedLocations.add(i - expectedLocations.length); 26 expectedLocations.add(i - expectedLocations.length);
27 } 27 }
28 } 28 }
29 String code = codeWithMarkers.replaceAll('@', ''); 29 String code = codeWithMarkers.replaceAll('@', '');
30 30
31 SourceFile sourceFile = new SourceFile('<test script>', code); 31 SourceFile sourceFile = new StringSourceFile('<test script>', code);
32 asyncTest(() => compileAll(sourceFile).then((CodeBuffer buffer) { 32 asyncTest(() => compileAll(sourceFile).then((CodeBuffer buffer) {
33 Set<int> locations = new Set<int>(); 33 Set<int> locations = new Set<int>();
34 buffer.forEachSourceLocation((int offset, var sourcePosition) { 34 buffer.forEachSourceLocation((int offset, var sourcePosition) {
35 if (sourcePosition != null && sourcePosition.sourceFile == sourceFile) { 35 if (sourcePosition != null && sourcePosition.sourceFile == sourceFile) {
36 locations.add(sourcePosition.token.charOffset); 36 locations.add(sourcePosition.token.charOffset);
37 } 37 }
38 }); 38 });
39 39
40 for (int i = 0; i < expectedLocations.length; ++i) { 40 for (int i = 0; i < expectedLocations.length; ++i) {
41 int expectedLocation = expectedLocations[i]; 41 int expectedLocation = expectedLocations[i];
42 if (!locations.contains(expectedLocation)) { 42 if (!locations.contains(expectedLocation)) {
43 int originalLocation = expectedLocation + i; 43 int originalLocation = expectedLocation + i;
44 SourceFile sourceFileWithMarkers = new SourceFile('<test script>', 44 SourceFile sourceFileWithMarkers = new StringSourceFile('<test script>',
45 codeWithMarkers); 45 codeWithMarkers);
kasperl 2013/10/18 06:44:57 Fix indentation.
lukas 2013/10/18 08:39:46 Done.
46 String message = sourceFileWithMarkers.getLocationMessage( 46 String message = sourceFileWithMarkers.getLocationMessage(
47 'Missing location', originalLocation, originalLocation + 1, true, 47 'Missing location', originalLocation, originalLocation + 1, true,
48 (s) => s); 48 (s) => s);
49 Expect.fail(message); 49 Expect.fail(message);
50 } 50 }
51 } 51 }
52 })); 52 }));
53 } 53 }
54 54
55 String FUNCTIONS_TEST = ''' 55 String FUNCTIONS_TEST = '''
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 testSourceMapLocations(FUNCTIONS_TEST); 103 testSourceMapLocations(FUNCTIONS_TEST);
104 testSourceMapLocations(RETURN_TEST); 104 testSourceMapLocations(RETURN_TEST);
105 testSourceMapLocations(NOT_TEST); 105 testSourceMapLocations(NOT_TEST);
106 testSourceMapLocations(UNARY_TEST); 106 testSourceMapLocations(UNARY_TEST);
107 testSourceMapLocations(BINARY_TEST); 107 testSourceMapLocations(BINARY_TEST);
108 testSourceMapLocations(SEND_TEST); 108 testSourceMapLocations(SEND_TEST);
109 testSourceMapLocations(SEND_SET_TEST); 109 testSourceMapLocations(SEND_SET_TEST);
110 testSourceMapLocations(LOOP_TEST); 110 testSourceMapLocations(LOOP_TEST);
111 testSourceMapLocations(INTERCEPTOR_TEST); 111 testSourceMapLocations(INTERCEPTOR_TEST);
112 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698