| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 import 'memory_compiler.dart'; | 7 import 'memory_compiler.dart'; |
| 8 | 8 |
| 9 import 'package:compiler/src/compiler.dart' | 9 import 'package:compiler/src/compiler.dart' as dart2js; |
| 10 as dart2js; | |
| 11 | 10 |
| 12 void main() { | 11 void main() { |
| 13 asyncTest(() async { | 12 asyncTest(() async { |
| 14 CompilationResult result = | 13 CompilationResult result = |
| 15 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); | 14 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); |
| 16 dart2js.Compiler compiler = result.compiler; | 15 dart2js.Compiler compiler = result.compiler; |
| 17 | 16 |
| 18 lookupLibrary(name) { | 17 lookupLibrary(name) { |
| 19 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); | 18 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); |
| 20 } | 19 } |
| 21 | 20 |
| 22 var main = compiler.mainFunction; | 21 var main = compiler.mainFunction; |
| 23 Expect.isNotNull(main, "Could not find 'main'"); | 22 Expect.isNotNull(main, "Could not find 'main'"); |
| 24 compiler.deferredLoadTask.onResolutionComplete(main); | 23 compiler.deferredLoadTask.onResolutionComplete(main); |
| 25 | 24 |
| 26 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 25 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 27 | 26 |
| 28 var lib = lookupLibrary("memory:lib.dart"); | 27 var lib = lookupLibrary("memory:lib.dart"); |
| 29 var a = lib.find("a"); | 28 var a = lib.find("a"); |
| 30 var b = lib.find("b"); | 29 var b = lib.find("b"); |
| 31 var c = lib.find("c"); | 30 var c = lib.find("c"); |
| 32 var d = lib.find("d"); | 31 var d = lib.find("d"); |
| 33 Expect.equals(outputUnitForElement(a), outputUnitForElement(b)); | 32 Expect.equals(outputUnitForElement(a), outputUnitForElement(b)); |
| 34 Expect.equals(outputUnitForElement(a), outputUnitForElement(c)); | 33 Expect.equals(outputUnitForElement(a), outputUnitForElement(c)); |
| 35 Expect.equals(outputUnitForElement(a), outputUnitForElement(d)); | 34 Expect.equals(outputUnitForElement(a), outputUnitForElement(d)); |
| 36 }); | 35 }); |
| 37 } | 36 } |
| 38 | 37 |
| 39 // Make sure that the implicit references to supers are found by the deferred | 38 // Make sure that the implicit references to supers are found by the deferred |
| 40 // loading dependency mechanism. | 39 // loading dependency mechanism. |
| 41 const Map MEMORY_SOURCE_FILES = const { | 40 const Map MEMORY_SOURCE_FILES = const { |
| 42 "main.dart":""" | 41 "main.dart": """ |
| 43 import "lib.dart" deferred as lib; | 42 import "lib.dart" deferred as lib; |
| 44 | 43 |
| 45 void main() { | 44 void main() { |
| 46 lib.loadLibrary().then((_) { | 45 lib.loadLibrary().then((_) { |
| 47 new lib.A2(); | 46 new lib.A2(); |
| 48 new lib.B2(); | 47 new lib.B2(); |
| 49 new lib.C3(); | 48 new lib.C3(); |
| 50 new lib.D3(10); | 49 new lib.D3(10); |
| 51 }); | 50 }); |
| 52 } | 51 } |
| 53 """, | 52 """, |
| 54 "lib.dart":""" | 53 "lib.dart": """ |
| 55 a() => print("123"); | 54 a() => print("123"); |
| 56 | 55 |
| 57 b() => print("123"); | 56 b() => print("123"); |
| 58 | 57 |
| 59 c() => print("123"); | 58 c() => print("123"); |
| 60 | 59 |
| 61 d() => print("123"); | 60 d() => print("123"); |
| 62 | 61 |
| 63 class B { | 62 class B { |
| 64 B() { | 63 B() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 class D2 { | 105 class D2 { |
| 107 D2(x) { | 106 D2(x) { |
| 108 d(); | 107 d(); |
| 109 } | 108 } |
| 110 } | 109 } |
| 111 | 110 |
| 112 // Implicit redirecting "super" call with a parameter via mixin. | 111 // Implicit redirecting "super" call with a parameter via mixin. |
| 113 class D3 = D2 with D1; | 112 class D3 = D2 with D1; |
| 114 """, | 113 """, |
| 115 }; | 114 }; |
| OLD | NEW |