Some tests to cover transpilation of different syntax

This commit is contained in:
Sheetal Nandi 2015-10-20 17:16:39 -07:00
parent 8f03d00dc0
commit 57362f6017
12 changed files with 195 additions and 0 deletions

View File

@ -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;
})();

View File

@ -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))
}
}

View File

@ -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
}
}

View File

@ -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++) {
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
};
}

View File

@ -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))
};
}

View File

@ -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
};
}

View File

@ -0,0 +1,9 @@
// @jsExtensions: js
// @out: out.js
// @FileName: a.js
class c {
method(a) {
let x = a => this.method(a);
}
}

View File

@ -0,0 +1,9 @@
// @jsExtensions: js
// @out: out.js
// @FileName: a.js
function foo(a) {
for (let a = 0; a < 10; a++) {
// do something
}
}

View File

@ -0,0 +1,12 @@
// @jsExtensions: js
// @out: out.js
// @FileName: a.js
function foo() {
var a = 10;
var b = "Hello";
return {
a,
b
};
}