| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.test.memory_source_file_helper; | 5 library dart2js.test.memory_source_file_helper; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import "../../async_helper.dart"; |
| 8 import 'memory_compiler.dart'; | 9 import 'memory_compiler.dart'; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 10 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; | 11 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; |
| 11 | 12 |
| 12 const Map MEMORY_SOURCE_FILES = const { | 13 const Map MEMORY_SOURCE_FILES = const { |
| 13 'main.dart': r""" | 14 'main.dart': r""" |
| 14 | 15 |
| 15 library main; | 16 library main; |
| 16 | 17 |
| 17 import 'dart:async' as async show Future; | 18 import 'dart:async' as async show Future; |
| 18 | 19 |
| 19 var variable; | 20 var variable; |
| 20 | 21 |
| 21 method(a, [b]) {} | 22 method(a, [b]) {} |
| 22 | 23 |
| 23 class Class<A> { | 24 class Class<A> { |
| 24 var field; | 25 var field; |
| 25 var variable; | 26 var variable; |
| 26 method(c, {d}) {} | 27 method(c, {d}) {} |
| 27 } | 28 } |
| 28 | 29 |
| 29 class Subclass<B> extends Class<B> { | 30 class Subclass<B> extends Class<B> { |
| 30 var subfield; | 31 var subfield; |
| 31 } | 32 } |
| 32 """, | 33 """, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 void main() { | 36 void main() { |
| 36 mirrorSystemFor(MEMORY_SOURCE_FILES).then( | 37 asyncTest(() => mirrorSystemFor(MEMORY_SOURCE_FILES).then( |
| 37 (MirrorSystem mirrors) => test(mirrors), | 38 (MirrorSystem mirrors) => test(mirrors), |
| 38 onError: (e) => Expect.fail('$e')); | 39 onError: (e) => Expect.fail('$e'))); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void test(MirrorSystem mirrors) { | 42 void test(MirrorSystem mirrors) { |
| 42 LibraryMirror dartCore = mirrors.libraries[Uri.parse('dart:core')]; | 43 LibraryMirror dartCore = mirrors.libraries[Uri.parse('dart:core')]; |
| 43 Expect.isNotNull(dartCore); | 44 Expect.isNotNull(dartCore); |
| 44 | 45 |
| 45 LibraryMirror dartAsync = mirrors.libraries[Uri.parse('dart:async')]; | 46 LibraryMirror dartAsync = mirrors.libraries[Uri.parse('dart:async')]; |
| 46 Expect.isNotNull(dartAsync); | 47 Expect.isNotNull(dartAsync); |
| 47 | 48 |
| 48 LibraryMirror library = mirrors.libraries[Uri.parse('memory:main.dart')]; | 49 LibraryMirror library = mirrors.libraries[Uri.parse('memory:main.dart')]; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 Expect.equals(Subclass_subfield, | 253 Expect.equals(Subclass_subfield, |
| 253 lookupQualifiedInScope(library, 'Subclass.subfield')); | 254 lookupQualifiedInScope(library, 'Subclass.subfield')); |
| 254 | 255 |
| 255 Expect.equals(Future_, lookupQualifiedInScope(library, 'async.Future')); | 256 Expect.equals(Future_, lookupQualifiedInScope(library, 'async.Future')); |
| 256 Expect.isTrue( | 257 Expect.isTrue( |
| 257 lookupQualifiedInScope(library, 'async.Future.then') is MethodMirror); | 258 lookupQualifiedInScope(library, 'async.Future.then') is MethodMirror); |
| 258 // `Timer` should not be found through the prefix `async.Future`. | 259 // `Timer` should not be found through the prefix `async.Future`. |
| 259 Expect.isNull( | 260 Expect.isNull( |
| 260 lookupQualifiedInScope(library, 'async.Future.Timer')); | 261 lookupQualifiedInScope(library, 'async.Future.Timer')); |
| 261 } | 262 } |
| OLD | NEW |