| 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 'package:compiler/src/io/source_information.dart'; | 10 import 'package:compiler/src/io/source_information.dart'; |
| 11 import "mock_compiler.dart"; | 11 import "mock_compiler.dart"; |
| 12 import 'package:compiler/src/js_backend/js_backend.dart'; | 12 import 'package:compiler/src/js_backend/js_backend.dart'; |
| 13 import 'package:compiler/src/js_emitter/js_emitter.dart'; |
| 13 | 14 |
| 14 Future<CodeBuffer> compileAll(SourceFile sourceFile) { | 15 Future<CodeBuffer> compileAll(SourceFile sourceFile) { |
| 15 MockCompiler compiler = new MockCompiler.internal(); | 16 MockCompiler compiler = new MockCompiler.internal(); |
| 16 Uri uri = new Uri(path: sourceFile.filename); | 17 Uri uri = new Uri(path: sourceFile.filename); |
| 17 compiler.sourceFiles[uri.toString()] = sourceFile; | 18 compiler.sourceFiles[uri.toString()] = sourceFile; |
| 18 JavaScriptBackend backend = compiler.backend; | 19 JavaScriptBackend backend = compiler.backend; |
| 19 return compiler.runCompiler(uri).then((_) { | 20 return compiler.runCompiler(uri).then((_) { |
| 20 return backend.emitter.oldEmitter | 21 // TODO(floitsch): the outputBuffers are only accessible in the full |
| 22 // emitter. |
| 23 OldEmitter fullEmitter = backend.emitter.emitter; |
| 24 return fullEmitter |
| 21 .outputBuffers[compiler.deferredLoadTask.mainOutputUnit]; | 25 .outputBuffers[compiler.deferredLoadTask.mainOutputUnit]; |
| 22 }); | 26 }); |
| 23 } | 27 } |
| 24 | 28 |
| 25 void testSourceMapLocations(String codeWithMarkers) { | 29 void testSourceMapLocations(String codeWithMarkers) { |
| 26 List<int> expectedLocations = new List<int>(); | 30 List<int> expectedLocations = new List<int>(); |
| 27 for (int i = 0; i < codeWithMarkers.length; ++i) { | 31 for (int i = 0; i < codeWithMarkers.length; ++i) { |
| 28 if (codeWithMarkers[i] == '@') { | 32 if (codeWithMarkers[i] == '@') { |
| 29 expectedLocations.add(i - expectedLocations.length); | 33 expectedLocations.add(i - expectedLocations.length); |
| 30 } | 34 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 testSourceMapLocations(FUNCTIONS_TEST); | 110 testSourceMapLocations(FUNCTIONS_TEST); |
| 107 testSourceMapLocations(RETURN_TEST); | 111 testSourceMapLocations(RETURN_TEST); |
| 108 testSourceMapLocations(NOT_TEST); | 112 testSourceMapLocations(NOT_TEST); |
| 109 testSourceMapLocations(UNARY_TEST); | 113 testSourceMapLocations(UNARY_TEST); |
| 110 testSourceMapLocations(BINARY_TEST); | 114 testSourceMapLocations(BINARY_TEST); |
| 111 testSourceMapLocations(SEND_TEST); | 115 testSourceMapLocations(SEND_TEST); |
| 112 testSourceMapLocations(SEND_SET_TEST); | 116 testSourceMapLocations(SEND_SET_TEST); |
| 113 testSourceMapLocations(LOOP_TEST); | 117 testSourceMapLocations(LOOP_TEST); |
| 114 testSourceMapLocations(INTERCEPTOR_TEST); | 118 testSourceMapLocations(INTERCEPTOR_TEST); |
| 115 } | 119 } |
| OLD | NEW |