Index: test/main_test.ts |
diff --git a/test/main_test.ts b/test/main_test.ts |
index 971459209ad4432c6876d1671e4a1ce9673a3e66..4bb7830ec4fd0d9702f8503efd115dbc36b13428 100644 |
--- a/test/main_test.ts |
+++ b/test/main_test.ts |
@@ -4,111 +4,109 @@ |
import chai = require('chai'); |
import main = require('../lib/main'); |
-import {expectTranslate, expectErroneousCode} from './test_support'; |
+import {expectTranslate} from './test_support'; |
describe('main transpiler functionality', () => { |
- describe('comments', () => { |
- it('keeps leading comments', () => { |
- expectTranslate(` |
-function f() { |
-/* A */ a; |
-/* B */ b; |
-}`).to.equal(`f() { |
- /* A */ a; |
- /* B */ b; |
-}`); |
- expectTranslate(`function f() { |
-// A |
-a |
+ describe( |
+ 'comments', () => { |
+ it('keeps leading comments', |
+ () => { |
+ expectTranslate(`/* A */ var a; |
+/* B */ var b;`).to.equal(`/* A */ |
+@JS() |
+external get a; |
+@JS() |
+external set a(v); |
+/* B */ @JS() |
+external get b; |
+@JS() |
+external set b(v);`); |
+ expectTranslate(`// A |
+var a; |
// B |
-b |
-}`).to.equal(`f() { |
- // A |
- a; |
- // B |
- b; |
-}`); |
- }); |
- it('keeps ctor comments', () => { |
- expectTranslate('/** A */ class A {\n /** ctor */ constructor() {}}').to.equal(`/** A */ |
+var b;`).to.equal(`// A |
+@JS() |
+external get a; |
+@JS() |
+external set a(v); |
+// B |
+@JS() |
+external get b; |
+@JS() |
+external set b(v);`); |
+ }); |
+ it('keeps ctor comments', () => { |
+ expectTranslate('/** A */ class A {\n /** ctor */ constructor() {}}').to.equal(`/** A */ |
+@JS() |
class A { |
- /** ctor */ A() {} |
+ // @Ignore |
+ A.fakeConstructor$(); |
+ /** ctor */ external factory A(); |
}`); |
- }); |
- it('translates links to dart doc format', () => { |
- expectTranslate('/** {@link this/place} */ a').to.equal('/** [this/place] */ a;'); |
- expectTranslate('/* {@link 1} {@link 2} */ a').to.equal('/* [1] [2] */ a;'); |
- }); |
- it('removes @module doc tags', () => { |
- expectTranslate(`/** @module |
- * This is a module for doing X. |
- */`).to.equal(`/** |
- * This is a module for doing X. |
- */`); |
- }); |
- it('removes @description doc tags', () => { |
- expectTranslate(`/** @description |
- * This is a module for doing X. |
- */`).to.equal(`/** |
- * This is a module for doing X. |
- */`); |
- }); |
- it('removes @depracted doc tags', () => { |
- expectTranslate(`/** |
- * Use SomethingElse instead. |
- * @deprecated |
- */`).to.equal(`/** |
- * Use SomethingElse instead. |
- * |
- */`); |
- }); |
- it('removes @param doc tags', () => { |
- expectTranslate(`/** |
- * Method to do blah. |
- * @param doc Document. |
- */`).to.equal(`/** |
- * Method to do blah. |
- * |
- */`); |
- }); |
- it('removes @return doc tags', () => { |
- expectTranslate(`/** |
- * Method to do blah. |
- * @return {String} |
- */`).to.equal(`/** |
- * Method to do blah. |
- * |
- */`); |
- }); |
- it('removes @throws doc tags', () => { |
- expectTranslate(`/** |
- * Method to do blah. |
- * @throws ArgumentException If arguments are wrong |
- */`).to.equal(`/** |
- * Method to do blah. |
- * |
- */`); |
- }); |
- }); |
- |
- describe('errors', () => { |
- it('reports multiple errors', () => { |
- // Reports both the private field not having an underbar and protected being unsupported. |
- let errorLines = new RegExp( |
- 'delete operator is unsupported\n' + |
- '.*void operator is unsupported'); |
- expectErroneousCode('delete x["y"]; void z;').to.throw(errorLines); |
- }); |
- it('reports relative paths in errors', () => { |
- chai.expect(() => expectTranslate({'/a/b/c.ts': 'delete x["y"];'}, {basePath: '/a'})) |
- .to.throw(/^b\/c.ts:1/); |
- }); |
- it('reports errors across multiple files', () => { |
- expectErroneousCode({'a.ts': 'delete x["y"];', 'b.ts': 'delete x["y"];'}, { |
- failFast: false |
- }).to.throw(/^a\.ts.*\nb\.ts/); |
- }); |
- }); |
+ }); |
+ it('translates links to dart doc format', () => { |
+ expectTranslate('/** {@link this/place} */ var a').to.equal(`/** [this/place] */ |
+@JS() |
+external get a; |
+@JS() |
+external set a(v);`); |
+ expectTranslate('/* {@link 1} {@link 2} */ var a').to.equal(`/* [1] [2] */ |
+@JS() |
+external get a; |
+@JS() |
+external set a(v);`); |
+ }); |
+ it('removes @module doc tags', () => { |
+ expectTranslate(`/** @module |
+ * This is a module for doing X. |
+ */`).to.equal(`/** |
+ * This is a module for doing X. |
+ */`); |
+ }); |
+ it('removes @description doc tags', () => { |
+ expectTranslate(`/** @description |
+ * This is a module for doing X. |
+ */`).to.equal(`/** |
+ * This is a module for doing X. |
+ */`); |
+ }); |
+ it('removes @depracted doc tags', () => { |
+ expectTranslate(`/** |
+ * Use SomethingElse instead. |
+ * @deprecated |
+ */`).to.equal(`/** |
+ * Use SomethingElse instead. |
+ * |
+ */`); |
+ }); |
+ it('removes @param doc tags', () => { |
+ expectTranslate(`/** |
+ * Method to do blah. |
+ * @param doc Document. |
+ */`).to.equal(`/** |
+ * Method to do blah. |
+ * |
+ */`); |
+ }); |
+ it('removes @return doc tags', () => { |
+ expectTranslate(`/** |
+ * Method to do blah. |
+ * @return {String} |
+ */`).to.equal(`/** |
+ * Method to do blah. |
+ * |
+ */`); |
+ }); |
+ it('removes @throws doc tags', () => { |
+ expectTranslate(`/** |
+ * Method to do blah. |
+ * @throws ArgumentException If arguments are wrong |
+ */`).to.equal(`/** |
+ * Method to do blah. |
+ * |
+ */`); |
+ }); |
+ }); |
describe('output paths', () => { |
it('writes within the path', () => { |