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

Unified Diff: test/main_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/literal_test.ts ('k') | test/module_test.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/main_test.ts
diff --git a/test/main_test.ts b/test/main_test.ts
index 971459209ad4432c6876d1671e4a1ce9673a3e66..bd8b2a9f3af4ce72cb5ec0b19d06bab8d06661f8 100644
--- a/test/main_test.ts
+++ b/test/main_test.ts
@@ -4,111 +4,147 @@
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;
+ 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
+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 {
+ // @Ignore
+ A.fakeConstructor$();
+
+ /// ctor
+ external factory A();
}`);
- expectTranslate(`function f() {
-// A
-a
-// B
-b
-}`).to.equal(`f() {
- // A
- a;
- // B
- b;
+ });
+ 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.`);
+ });
+ it('multiple line comment', () => {
+ expectTranslate(`/**
+ * Method to do blah.
+ * Bla bla bla.
+ * Foo bar.
+ */`).to.equal(`/// Method to do blah.
+/// Bla bla bla.
+/// Foo bar.`);
+ });
+ it('multiple line comment', () => {
+ expectTranslate(`class Foo {
+/**
+* Method to do blah.
+* Bla bla bla.
+* Foo bar.
+*/
+ bar();
+}`).to.equal(`@JS()
+class Foo {
+ // @Ignore
+ Foo.fakeConstructor$();
+
+ /// Method to do blah.
+ /// Bla bla bla.
+ /// Foo bar.
+ external bar();
}`);
- });
- it('keeps ctor comments', () => {
- expectTranslate('/** A */ class A {\n /** ctor */ constructor() {}}').to.equal(`/** A */
-class A {
- /** ctor */ A() {}
+
+ expectTranslate(`class Foo {
+// Baz.
+// Bla bla bla.
+// Foo bar.
+
+// Bla.
+bar();
+}`).to.equal(`@JS()
+class Foo {
+ // @Ignore
+ Foo.fakeConstructor$();
+
+ /// Baz.
+ /// Bla bla bla.
+ /// Foo bar.
+
+ /// Bla.
+ external bar();
}`);
- });
- 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/);
- });
- });
+ });
+ });
describe('output paths', () => {
it('writes within the path', () => {
« no previous file with comments | « test/literal_test.ts ('k') | test/module_test.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698