Index: test/call_test.ts |
diff --git a/test/call_test.ts b/test/call_test.ts |
index 91b1518770e6a1fe41a145488412e9c77c8c46c2..d7136e93602b677094a3b4de24b89f4c5ab2f21a 100644 |
--- a/test/call_test.ts |
+++ b/test/call_test.ts |
@@ -1,62 +1,64 @@ |
/// <reference path="../typings/mocha/mocha.d.ts"/> |
-import {expectTranslate, expectErroneousCode} from './test_support'; |
+import {expectTranslate} from './test_support'; |
describe('calls', () => { |
it('translates destructuring parameters', () => { |
- expectTranslate('function x({p = null, d = false} = {}) {}') |
- .to.equal('x({p: null, d: false}) {}'); |
- expectErroneousCode('function x({a=false}={a:true})') |
- .to.throw('cannot have both an inner and outer initializer'); |
- expectErroneousCode('function x({a=false}=true)') |
- .to.throw('initializers for named parameters must be object literals'); |
- expectTranslate('class X { constructor() { super({p: 1}); } }').to.equal(`class X { |
- X() : super(p: 1) { |
- /* super call moved to initializer */; |
- } |
+ expectTranslate('function x({p = null, d = false} = {}) {}').to.equal(`@JS() |
+external x(Object p_d /*{p = null, d = false}*/);`); |
+ expectTranslate('function x({a=false}={a:true})').to.equal(`@JS() |
+external x(Object a /*{a=false}*/);`); |
+ expectTranslate('function x({a=false}=true)').to.equal(`@JS() |
+external x(Object a /*{a=false}*/);`); |
+ expectTranslate('class X { constructor() { super({p: 1}); } }').to.equal(`@JS() |
+class X { |
+ // @Ignore |
+ X.fakeConstructor$(); |
+ external factory X(); |
}`); |
}); |
- it('hacks last object literal parameters into named parameter', () => { |
- expectTranslate('f(x, {a: 12, b: 4});').to.equal('f(x, a: 12, b: 4);'); |
- expectTranslate('f({a: 12});').to.equal('f(a: 12);'); |
- expectTranslate('f({"a": 12});').to.equal('f({"a": 12});'); |
- expectTranslate('new X(x, {a: 12, b: 4});').to.equal('new X(x, a: 12, b: 4);'); |
- expectTranslate('f(x, {});').to.equal('f(x, {});'); |
+ it('suppress calls with literal parameters', () => { |
+ expectTranslate('f(x, {a: 12, b: 4});').to.equal(''); |
+ expectTranslate('f({a: 12});').to.equal(''); |
+ expectTranslate('f({"a": 12});').to.equal(''); |
+ expectTranslate('new X(x, {a: 12, b: 4});').to.equal(''); |
+ expectTranslate('f(x, {});').to.equal(''); |
}); |
- it('translates calls', () => { |
- expectTranslate('foo();').to.equal('foo();'); |
- expectTranslate('foo(1, 2);').to.equal('foo(1, 2);'); |
+ it('suppress calls', () => { |
+ expectTranslate('foo();').to.equal(''); |
+ expectTranslate('foo(1, 2);').to.equal(''); |
}); |
- it('translates new calls', () => { |
- expectTranslate('new Foo();').to.equal('new Foo();'); |
- expectTranslate('new Foo(1, 2);').to.equal('new Foo(1, 2);'); |
- expectTranslate('new Foo<number, string>(1, 2);').to.equal('new Foo<num, String>(1, 2);'); |
+ it('suppress new calls', () => { |
+ expectTranslate('new Foo();').to.equal(''); |
+ expectTranslate('new Foo(1, 2);').to.equal(''); |
+ expectTranslate('new Foo<number, string>(1, 2);').to.equal(''); |
}); |
- it('supports generic type parameters', |
- () => { expectTranslate('var s = foo<string>();').to.equal('var s = foo/*< String >*/();'); }); |
- it('translates "super()" constructor calls', () => { |
- expectTranslate('class X { constructor() { super(1); } }').to.equal(`class X { |
- X() : super(1) { |
- /* super call moved to initializer */; |
- } |
+ it('suppress "super()" constructor calls', () => { |
+ expectTranslate('class X { constructor() { super(1); } }').to.equal(`@JS() |
+class X { |
+ // @Ignore |
+ X.fakeConstructor$(); |
+ external factory X(); |
}`); |
- expectErroneousCode('class X { constructor() { if (y) super(1, 2); } }') |
- .to.throw('super calls must be immediate children of their constructors'); |
- expectTranslate('class X { constructor() { a(); super(1); b(); } }').to.equal(`class X { |
- X() : super(1) { |
- a(); |
- /* super call moved to initializer */ |
- ; |
- b(); |
- } |
+ expectTranslate('class X { constructor() { if (y) super(1, 2); } }').to.equal(`@JS() |
+class X { |
+ // @Ignore |
+ X.fakeConstructor$(); |
+ external factory X(); |
+}`); |
+ expectTranslate('class X { constructor() { a(); super(1); b(); } }').to.equal(`@JS() |
+class X { |
+ // @Ignore |
+ X.fakeConstructor$(); |
+ external factory X(); |
}`); |
}); |
- it('translates "super.x()" super method calls', () => { |
- expectTranslate('class X { y() { super.z(1); } }').to.equal(`class X { |
- y() { |
- super.z(1); |
- } |
+ it('ignore "super.x()" super method calls', () => { |
+ expectTranslate('class X { y() { super.z(1); } }').to.equal(`@JS() |
+class X { |
+ // @Ignore |
+ X.fakeConstructor$(); |
+ external y(); |
}`); |
}); |
- it('transpiles new calls without arguments', |
- () => { expectTranslate('new Foo;').to.equal('new Foo();'); }); |
+ it('suppress new calls without arguments', () => { expectTranslate('new Foo;').to.equal(''); }); |
}); |