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 // Test of [qualifiedNamesIn] and [canNamesResolveStaticallyTo]. | 5 // Test of [qualifiedNamesIn] and [canNamesResolveStaticallyTo]. |
6 library trydart.qualified_names_test; | 6 library trydart.qualified_names_test; |
7 | 7 |
8 import 'package:dart2js_incremental/library_updater.dart' show | 8 import 'package:dart2js_incremental/library_updater.dart' show |
9 canNamesResolveStaticallyTo, | 9 canNamesResolveStaticallyTo, |
10 qualifiedNamesIn; | 10 qualifiedNamesIn; |
11 | 11 |
12 import 'compiler_test_case.dart'; | 12 import 'compiler_test_case.dart'; |
13 | 13 |
14 typedef Checker(LibraryElement script); | 14 typedef Checker(LibraryElement script); |
15 | 15 |
16 class NameTestCase extends CompilerTestCase { | 16 class NameTestCase extends CompilerTestCase { |
17 final Checker check; | 17 final Checker check; |
18 | 18 |
19 NameTestCase(String source, this.check) | 19 NameTestCase(String source, this.check) |
20 : super(source); | 20 : super(source); |
21 | 21 |
22 Future run() => mainApp.then(check); | 22 Future run() => loadMainApp().then(check); |
23 } | 23 } |
24 | 24 |
25 main() { | 25 main() { |
26 runTests(tests.map((l) => new NameTestCase(l.first, l.last)).toList()); | 26 runTests(tests.map((l) => new NameTestCase(l.first, l.last)).toList()); |
27 } | 27 } |
28 | 28 |
29 final List tests = [ | 29 final List tests = [ |
30 ["main() { x; }", | 30 ["main() { x; }", |
31 (LibraryElement script) { | 31 (LibraryElement script) { |
32 var names = qualifiedNamesIn(script.findLocal("main")); | 32 var names = qualifiedNamesIn(script.findLocal("main")); |
(...skipping 22 matching lines...) Expand all Loading... |
55 var y = script.findLocal("y"); | 55 var y = script.findLocal("y"); |
56 var z = script.findLocal("z"); | 56 var z = script.findLocal("z"); |
57 var w = script.findLocal("w"); | 57 var w = script.findLocal("w"); |
58 Expect.isTrue(canNamesResolveStaticallyTo(names, main, script)); | 58 Expect.isTrue(canNamesResolveStaticallyTo(names, main, script)); |
59 Expect.isTrue(canNamesResolveStaticallyTo(names, x, script)); | 59 Expect.isTrue(canNamesResolveStaticallyTo(names, x, script)); |
60 Expect.isFalse(canNamesResolveStaticallyTo(names, y, script)); | 60 Expect.isFalse(canNamesResolveStaticallyTo(names, y, script)); |
61 Expect.isFalse(canNamesResolveStaticallyTo(names, z, script)); | 61 Expect.isFalse(canNamesResolveStaticallyTo(names, z, script)); |
62 Expect.isFalse(canNamesResolveStaticallyTo(names, w, script)); | 62 Expect.isFalse(canNamesResolveStaticallyTo(names, w, script)); |
63 }], | 63 }], |
64 ]; | 64 ]; |
OLD | NEW |