| Index: test/module_test.ts
|
| diff --git a/test/module_test.ts b/test/module_test.ts
|
| index 2d59cfa46b5e44b19d05c47255900ab6e76da648..12987f7bda4e61dcf886947b439fa05eece6a0eb 100644
|
| --- a/test/module_test.ts
|
| +++ b/test/module_test.ts
|
| @@ -2,7 +2,7 @@
|
| import chai = require('chai');
|
| import main = require('../lib/main');
|
| import ModuleTranspiler from '../lib/module';
|
| -import {FacadeConverter} from '../lib/facade_converter';
|
| +import {FacadeConverter, NameRewriter} from '../lib/facade_converter';
|
|
|
| import {expectTranslate, expectErroneousCode, translateSources} from './test_support';
|
|
|
| @@ -21,24 +21,29 @@ describe('imports', () => {
|
| expectTranslate('import {x} from "./y"').to.equal('import "y.dart" show x;');
|
| expectTranslate('import {x} from "../y"').to.equal('import "../y.dart" show x;');
|
| });
|
| - it('handles ignored annotations in imports', () => {
|
| - expectTranslate('import {CONST, CONST_EXPR, IMPLEMENTS, ABSTRACT} from "x"').to.equal('');
|
| - expectTranslate('import {x, IMPLEMENTS} from "./x"').to.equal('import "x.dart" show x;');
|
| - });
|
| it('fails for renamed imports', () => {
|
| expectErroneousCode('import {Foo as Bar} from "baz";')
|
| .to.throw(/import\/export renames are unsupported in Dart/);
|
| });
|
| - it('fails for empty import specs',
|
| - () => { expectErroneousCode('import {} from "baz";').to.throw(/empty import list/); });
|
| + it('empty import spec generates safe Dart code',
|
| + () => { expectTranslate('import {} from "baz";').to.equal(''); });
|
| });
|
|
|
| describe('exports', () => {
|
| // Dart exports are implicit, everything non-private is exported by the library.
|
| - it('allows variable exports',
|
| - () => { expectTranslate('export var x = 12;').to.equal('var x = 12;'); });
|
| - it('allows class exports',
|
| - () => { expectTranslate('export class X {}').to.equal('class X {}'); });
|
| + it('allows variable exports', () => {
|
| + expectTranslate('export var x = 12;').to.equal(`@JS()
|
| +external get x;
|
| +@JS()
|
| +external set x(v);`);
|
| + });
|
| + it('allows class exports', () => {
|
| + expectTranslate('export class X {}').to.equal(`@JS()
|
| +class X {
|
| + // @Ignore
|
| + X.fakeConstructor$();
|
| +}`);
|
| + });
|
| it('allows export declarations',
|
| () => { expectTranslate('export * from "X";').to.equal('export "package:X.dart";'); });
|
| it('allows export declarations',
|
| @@ -62,14 +67,21 @@ describe('library name', () => {
|
| let modTranspiler: ModuleTranspiler;
|
| beforeEach(() => {
|
| transpiler = new main.Transpiler({failFast: true, generateLibraryName: true, basePath: '/a'});
|
| - modTranspiler = new ModuleTranspiler(transpiler, new FacadeConverter(transpiler), true);
|
| + modTranspiler = new ModuleTranspiler(
|
| + transpiler, new FacadeConverter(transpiler, '', new NameRewriter(), false), true);
|
| });
|
| it('adds a library name', () => {
|
| let results = translateSources(
|
| {'/a/b/c.ts': 'var x;'}, {failFast: true, generateLibraryName: true, basePath: '/a'});
|
| - chai.expect(results['/a/b/c.ts']).to.equal(`library b.c;
|
| + chai.expect(results['/a/b/c.ts']).to.equal(`@JS()
|
| +library b.c;
|
| +
|
| +import "package:js/js.dart";
|
|
|
| -var x;
|
| +@JS()
|
| +external get x;
|
| +@JS()
|
| +external set x(v);
|
| `);
|
| });
|
| it('leaves relative paths alone',
|
|
|