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 "../../../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"; |
11 import 'parser_helper.dart'; | 11 import '../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend
.dart'; |
12 | 12 |
13 Future<CodeBuffer> compileAll(SourceFile sourceFile) { | 13 Future<CodeBuffer> compileAll(SourceFile sourceFile) { |
14 MockCompiler compiler = new MockCompiler(); | 14 MockCompiler compiler = new MockCompiler(); |
15 Uri uri = new Uri(path: sourceFile.filename); | 15 Uri uri = new Uri(path: sourceFile.filename); |
16 compiler.sourceFiles[uri.toString()] = sourceFile; | 16 compiler.sourceFiles[uri.toString()] = sourceFile; |
| 17 JavaScriptBackend backend = compiler.backend; |
17 return compiler.runCompiler(uri).then((_) { | 18 return compiler.runCompiler(uri).then((_) { |
18 return compiler.backend.emitter.mainBuffer; | 19 return backend.emitter.mainBuffer; |
19 }); | 20 }); |
20 } | 21 } |
21 | 22 |
22 void testSourceMapLocations(String codeWithMarkers) { | 23 void testSourceMapLocations(String codeWithMarkers) { |
23 List<int> expectedLocations = new List<int>(); | 24 List<int> expectedLocations = new List<int>(); |
24 for (int i = 0; i < codeWithMarkers.length; ++i) { | 25 for (int i = 0; i < codeWithMarkers.length; ++i) { |
25 if (codeWithMarkers[i] == '@') { | 26 if (codeWithMarkers[i] == '@') { |
26 expectedLocations.add(i - expectedLocations.length); | 27 expectedLocations.add(i - expectedLocations.length); |
27 } | 28 } |
28 } | 29 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 testSourceMapLocations(FUNCTIONS_TEST); | 104 testSourceMapLocations(FUNCTIONS_TEST); |
104 testSourceMapLocations(RETURN_TEST); | 105 testSourceMapLocations(RETURN_TEST); |
105 testSourceMapLocations(NOT_TEST); | 106 testSourceMapLocations(NOT_TEST); |
106 testSourceMapLocations(UNARY_TEST); | 107 testSourceMapLocations(UNARY_TEST); |
107 testSourceMapLocations(BINARY_TEST); | 108 testSourceMapLocations(BINARY_TEST); |
108 testSourceMapLocations(SEND_TEST); | 109 testSourceMapLocations(SEND_TEST); |
109 testSourceMapLocations(SEND_SET_TEST); | 110 testSourceMapLocations(SEND_SET_TEST); |
110 testSourceMapLocations(LOOP_TEST); | 111 testSourceMapLocations(LOOP_TEST); |
111 testSourceMapLocations(INTERCEPTOR_TEST); | 112 testSourceMapLocations(INTERCEPTOR_TEST); |
112 } | 113 } |
OLD | NEW |