| OLD | NEW |
| 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 "package:compiler/src/io/code_output.dart"; | 8 import "package:compiler/src/io/code_output.dart"; |
| 9 import 'package:compiler/src/io/source_file.dart'; | 9 import 'package:compiler/src/io/source_file.dart'; |
| 10 import "mock_compiler.dart"; | 10 import "mock_compiler.dart"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 void testSourceMapLocations(String codeWithMarkers) { | 24 void testSourceMapLocations(String codeWithMarkers) { |
| 25 List<int> expectedLocations = new List<int>(); | 25 List<int> expectedLocations = new List<int>(); |
| 26 for (int i = 0; i < codeWithMarkers.length; ++i) { | 26 for (int i = 0; i < codeWithMarkers.length; ++i) { |
| 27 if (codeWithMarkers[i] == '@') { | 27 if (codeWithMarkers[i] == '@') { |
| 28 expectedLocations.add(i - expectedLocations.length); | 28 expectedLocations.add(i - expectedLocations.length); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 String code = codeWithMarkers.replaceAll('@', ''); | 31 String code = codeWithMarkers.replaceAll('@', ''); |
| 32 | 32 |
| 33 SourceFile sourceFile = new StringSourceFile('<test script>', code); | 33 SourceFile sourceFile = new StringSourceFile.fromName('<test script>', code); |
| 34 asyncTest(() => compileAll(sourceFile).then((CodeOutput output) { | 34 asyncTest(() => compileAll(sourceFile).then((CodeOutput output) { |
| 35 Set<int> locations = new Set<int>(); | 35 Set<int> locations = new Set<int>(); |
| 36 output.forEachSourceLocation((int offset, var sourcePosition) { | 36 output.forEachSourceLocation((int offset, var sourcePosition) { |
| 37 if (sourcePosition != null && sourcePosition.sourceFile == sourceFile) { | 37 if (sourcePosition != null && |
| 38 sourcePosition.sourceUri == sourceFile.uri) { |
| 38 locations.add(sourcePosition.token.charOffset); | 39 locations.add(sourcePosition.token.charOffset); |
| 39 } | 40 } |
| 40 }); | 41 }); |
| 41 | 42 |
| 42 for (int i = 0; i < expectedLocations.length; ++i) { | 43 for (int i = 0; i < expectedLocations.length; ++i) { |
| 43 int expectedLocation = expectedLocations[i]; | 44 int expectedLocation = expectedLocations[i]; |
| 44 if (!locations.contains(expectedLocation)) { | 45 if (!locations.contains(expectedLocation)) { |
| 45 int originalLocation = expectedLocation + i; | 46 int originalLocation = expectedLocation + i; |
| 46 SourceFile sourceFileWithMarkers = | 47 SourceFile sourceFileWithMarkers = |
| 47 new StringSourceFile('<test script>', codeWithMarkers); | 48 new StringSourceFile.fromName('<test script>', codeWithMarkers); |
| 48 String message = sourceFileWithMarkers.getLocationMessage( | 49 String message = sourceFileWithMarkers.getLocationMessage( |
| 49 'Missing location', originalLocation, originalLocation + 1); | 50 'Missing location', originalLocation, originalLocation + 1); |
| 50 Expect.fail(message); | 51 Expect.fail(message); |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 })); | 54 })); |
| 54 } | 55 } |
| 55 | 56 |
| 56 String FUNCTIONS_TEST = ''' | 57 String FUNCTIONS_TEST = ''' |
| 57 @void main() { print(test(15)); @} | 58 @void main() { print(test(15)); @} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 testSourceMapLocations(FUNCTIONS_TEST); | 105 testSourceMapLocations(FUNCTIONS_TEST); |
| 105 testSourceMapLocations(RETURN_TEST); | 106 testSourceMapLocations(RETURN_TEST); |
| 106 testSourceMapLocations(NOT_TEST); | 107 testSourceMapLocations(NOT_TEST); |
| 107 testSourceMapLocations(UNARY_TEST); | 108 testSourceMapLocations(UNARY_TEST); |
| 108 testSourceMapLocations(BINARY_TEST); | 109 testSourceMapLocations(BINARY_TEST); |
| 109 testSourceMapLocations(SEND_TEST); | 110 testSourceMapLocations(SEND_TEST); |
| 110 testSourceMapLocations(SEND_SET_TEST); | 111 testSourceMapLocations(SEND_SET_TEST); |
| 111 testSourceMapLocations(LOOP_TEST); | 112 testSourceMapLocations(LOOP_TEST); |
| 112 testSourceMapLocations(INTERCEPTOR_TEST); | 113 testSourceMapLocations(INTERCEPTOR_TEST); |
| 113 } | 114 } |
| OLD | NEW |