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

Unified Diff: test/declaration_test.ts

Issue 2394683003: JS Interop Facade generation polish.
Patch Set: more cleanup Created 4 years, 2 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 | « lib/type.ts ('k') | test/js_interop_test.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/declaration_test.ts
diff --git a/test/declaration_test.ts b/test/declaration_test.ts
index 31829e8689dacf9bbb4966aa967266b51e917283..e1ef311818ce2b0c55f0354d4bf69c69f05e7276 100644
--- a/test/declaration_test.ts
+++ b/test/declaration_test.ts
@@ -392,6 +392,62 @@ abstract class X {
external factory X({String x, y});
}`);
});
+
+ it('supports interfaces with constructors', () => {
+ expectTranslate(`
+interface XStatic {
+ new (a: string, b): X;
+ foo();
+}
+
+declare var X: XStatic;
+`).to.equal(`@JS("X")
+abstract class XStatic {
+ external factory XStatic(String a, b);
+ external foo();
+}
+
+@JS()
+external XStatic get X;
+@JS()
+external set X(XStatic v);`);
+
+ expectTranslate(`
+interface XStatic {
+ new (a: string, b): XStatic;
+ foo();
+}
+
+declare module Foo {
+ declare var X: XStatic;
+}
+`).to.equal(`@JS("Foo.X")
+abstract class XStatic {
+ external factory XStatic(String a, b);
+ external foo();
+}
+
+// Module Foo
+@JS("Foo.X")
+external XStatic get X;
+@JS("Foo.X")
+external set X(XStatic v);
+// End module Foo`);
+
+ // Case where we cannot find a variable matching the interface so it is unsafe to give the
+ // interface a constructor.
+ expectTranslate(`
+interface XStatic {
+ new (a: string|bool, b): XStatic;
+ foo();
+}`).to.equal(`@anonymous
+@JS()
+abstract class XStatic {
+ // Constructors on anonymous interfaces are not yet supported.
+ /*external factory XStatic(String|bool a, b);*/
+ external foo();
+}`);
+ });
});
describe('single call signature interfaces', () => {
« no previous file with comments | « lib/type.ts ('k') | test/js_interop_test.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698