Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Unified Diff: test/module_test.ts

Issue 2225953002: Strip more unused features. (Closed) Base URL: git@github.com:dart-lang/js_facade_gen.git@master
Patch Set: Fix types Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/main_test.ts ('k') | test/statement_test.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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',
« no previous file with comments | « test/main_test.ts ('k') | test/statement_test.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698