Chromium Code Reviews| Index: tests/compiler/dart2js/reexport_handled_test.dart |
| diff --git a/tests/compiler/dart2js/reexport_handled_test.dart b/tests/compiler/dart2js/reexport_handled_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a98b7c5c503f7156ed76c0a828ab10931a4f481d |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/reexport_handled_test.dart |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library reexport_handled_test; |
| + |
| +import 'dart:uri'; |
| +import 'mock_compiler.dart'; |
| +import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'; |
|
ahe
2013/01/16 17:52:59
Could you "show" what is imported here?
ahe
2013/01/16 17:52:59
Also, add this:
import '../../../sdk/lib/_interna
Johnni Winther
2013/01/17 14:23:09
Nothing apparantly. Removed.
Johnni Winther
2013/01/17 14:23:09
Done.
|
| + |
| +var exportingLibraryUri = new Uri('exporting.dart'); |
|
ahe
2013/01/16 17:52:59
var -> final.
|
| +var exportingLibrarySource = ''' |
|
ahe
2013/01/16 17:52:59
For consistency with other tests, use:
const Stri
|
| +library exporting; |
| +var foo; |
| +'''; |
| + |
| +var reexportingLibraryUri = new Uri('reexporting.dart'); |
|
ahe
2013/01/16 17:52:59
var -> final.
Johnni Winther
2013/01/17 14:23:09
Done.
|
| +var reexportingLibrarySource = ''' |
|
ahe
2013/01/16 17:52:59
const HACKER_STYLE
Johnni Winther
2013/01/17 14:23:09
Done.
|
| +library reexporting; |
| +export 'exporting.dart'; |
| +'''; |
| + |
| +void main() { |
| + var compiler = new MockCompiler(); |
| + compiler.registerSource(exportingLibraryUri, exportingLibrarySource); |
| + compiler.registerSource(reexportingLibraryUri, reexportingLibrarySource); |
| + |
| + // Load exporting library before the reexporting library. |
| + var exportingLibrary = compiler.libraryLoader.loadLibrary( |
| + exportingLibraryUri, null, exportingLibraryUri); |
| + Expect.isTrue(exportingLibrary.exportsHandled); |
| + var foo = findInExports(exportingLibrary, 'foo'); |
| + Expect.isNotNull(foo); |
| + Expect.isTrue(foo.isField()); |
| + |
| + // Load reexporting library when exports are handled on the exporting library. |
| + var reexportingLibrary = compiler.libraryLoader.loadLibrary( |
| + reexportingLibraryUri, null, reexportingLibraryUri); |
| + foo = findInExports(reexportingLibrary, 'foo'); |
| + Expect.isNotNull(foo); |
| + Expect.isTrue(foo.isField()); |
| +} |
| + |
| +Element findInExports(LibraryElement library, String name) { |
| + for (var export in library.exports) { |
| + if (export.name.slowToString() == name) { |
| + return export; |
| + } |
| + } |
| + return null; |
| +} |