From 57362f60170528e269968023eab97fb962e43838 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 20 Oct 2015 17:16:39 -0700 Subject: [PATCH] Some tests to cover transpilation of different syntax --- ...ationClassMethodContainingArrowFunction.js | 18 ++++++++++++++ ...ClassMethodContainingArrowFunction.symbols | 18 ++++++++++++++ ...onClassMethodContainingArrowFunction.types | 20 ++++++++++++++++ .../jsFileCompilationLetBeingRenamed.js | 13 ++++++++++ .../jsFileCompilationLetBeingRenamed.symbols | 14 +++++++++++ .../jsFileCompilationLetBeingRenamed.types | 18 ++++++++++++++ .../jsFileCompilationShortHandProperty.js | 20 ++++++++++++++++ ...jsFileCompilationShortHandProperty.symbols | 20 ++++++++++++++++ .../jsFileCompilationShortHandProperty.types | 24 +++++++++++++++++++ ...ationClassMethodContainingArrowFunction.ts | 9 +++++++ .../jsFileCompilationLetBeingRenamed.ts | 9 +++++++ .../jsFileCompilationShortHandProperty.ts | 12 ++++++++++ 12 files changed, 195 insertions(+) create mode 100644 tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.js create mode 100644 tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.symbols create mode 100644 tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.types create mode 100644 tests/baselines/reference/jsFileCompilationLetBeingRenamed.js create mode 100644 tests/baselines/reference/jsFileCompilationLetBeingRenamed.symbols create mode 100644 tests/baselines/reference/jsFileCompilationLetBeingRenamed.types create mode 100644 tests/baselines/reference/jsFileCompilationShortHandProperty.js create mode 100644 tests/baselines/reference/jsFileCompilationShortHandProperty.symbols create mode 100644 tests/baselines/reference/jsFileCompilationShortHandProperty.types create mode 100644 tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts create mode 100644 tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts create mode 100644 tests/cases/compiler/jsFileCompilationShortHandProperty.ts diff --git a/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.js b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.js new file mode 100644 index 00000000000..836b39380ea --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.js @@ -0,0 +1,18 @@ +//// [a.js] + +class c { + method(a) { + let x = a => this.method(a); + } +} + +//// [out.js] +var c = (function () { + function c() { + } + c.prototype.method = function (a) { + var _this = this; + var x = function (a) { return _this.method(a); }; + }; + return c; +})(); diff --git a/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.symbols b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.symbols new file mode 100644 index 00000000000..8db5aa87a5b --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.js === + +class c { +>c : Symbol(c, Decl(a.js, 0, 0)) + + method(a) { +>method : Symbol(method, Decl(a.js, 1, 9)) +>a : Symbol(a, Decl(a.js, 2, 11)) + + let x = a => this.method(a); +>x : Symbol(x, Decl(a.js, 3, 11)) +>a : Symbol(a, Decl(a.js, 3, 15)) +>this.method : Symbol(method, Decl(a.js, 1, 9)) +>this : Symbol(c, Decl(a.js, 0, 0)) +>method : Symbol(method, Decl(a.js, 1, 9)) +>a : Symbol(a, Decl(a.js, 3, 15)) + } +} diff --git a/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.types b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.types new file mode 100644 index 00000000000..f429cc88516 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationClassMethodContainingArrowFunction.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.js === + +class c { +>c : c + + method(a) { +>method : (a: any) => void +>a : any + + let x = a => this.method(a); +>x : (a: any) => void +>a => this.method(a) : (a: any) => void +>a : any +>this.method(a) : void +>this.method : (a: any) => void +>this : this +>method : (a: any) => void +>a : any + } +} diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js new file mode 100644 index 00000000000..c9e16f35981 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js @@ -0,0 +1,13 @@ +//// [a.js] + +function foo(a) { + for (let a = 0; a < 10; a++) { + // do something + } +} + +//// [out.js] +function foo(a) { + for (var a_1 = 0; a_1 < 10; a_1++) { + } +} diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.symbols b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.symbols new file mode 100644 index 00000000000..6b0934c6591 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/a.js === + +function foo(a) { +>foo : Symbol(foo, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 1, 13)) + + for (let a = 0; a < 10; a++) { +>a : Symbol(a, Decl(a.js, 2, 12)) +>a : Symbol(a, Decl(a.js, 2, 12)) +>a : Symbol(a, Decl(a.js, 2, 12)) + + // do something + } +} diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types new file mode 100644 index 00000000000..094f59d2022 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/a.js === + +function foo(a) { +>foo : (a: any) => void +>a : any + + for (let a = 0; a < 10; a++) { +>a : number +>0 : number +>a < 10 : boolean +>a : number +>10 : number +>a++ : number +>a : number + + // do something + } +} diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.js b/tests/baselines/reference/jsFileCompilationShortHandProperty.js new file mode 100644 index 00000000000..1dc269146a6 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.js @@ -0,0 +1,20 @@ +//// [a.js] + +function foo() { + var a = 10; + var b = "Hello"; + return { + a, + b + }; +} + +//// [out.js] +function foo() { + var a = 10; + var b = "Hello"; + return { + a: a, + b: b + }; +} diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.symbols b/tests/baselines/reference/jsFileCompilationShortHandProperty.symbols new file mode 100644 index 00000000000..fb42d121c80 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.js === + +function foo() { +>foo : Symbol(foo, Decl(a.js, 0, 0)) + + var a = 10; +>a : Symbol(a, Decl(a.js, 2, 7)) + + var b = "Hello"; +>b : Symbol(b, Decl(a.js, 3, 7)) + + return { + a, +>a : Symbol(a, Decl(a.js, 4, 12)) + + b +>b : Symbol(b, Decl(a.js, 5, 10)) + + }; +} diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.types b/tests/baselines/reference/jsFileCompilationShortHandProperty.types new file mode 100644 index 00000000000..e4dd1755ceb --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/a.js === + +function foo() { +>foo : () => { a: number; b: string; } + + var a = 10; +>a : number +>10 : number + + var b = "Hello"; +>b : string +>"Hello" : string + + return { +>{ a, b } : { a: number; b: string; } + + a, +>a : number + + b +>b : string + + }; +} diff --git a/tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts b/tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts new file mode 100644 index 00000000000..225d73324c7 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationClassMethodContainingArrowFunction.ts @@ -0,0 +1,9 @@ +// @jsExtensions: js +// @out: out.js + +// @FileName: a.js +class c { + method(a) { + let x = a => this.method(a); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts b/tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts new file mode 100644 index 00000000000..6206ee8901b --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts @@ -0,0 +1,9 @@ +// @jsExtensions: js +// @out: out.js + +// @FileName: a.js +function foo(a) { + for (let a = 0; a < 10; a++) { + // do something + } +} \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationShortHandProperty.ts b/tests/cases/compiler/jsFileCompilationShortHandProperty.ts new file mode 100644 index 00000000000..13871de60d8 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationShortHandProperty.ts @@ -0,0 +1,12 @@ +// @jsExtensions: js +// @out: out.js + +// @FileName: a.js +function foo() { + var a = 10; + var b = "Hello"; + return { + a, + b + }; +} \ No newline at end of file