Add tests

This commit is contained in:
Kanchalai Tanglertsampan
2017-03-21 15:08:15 -07:00
parent 871d6095ef
commit 15ca0af646
15 changed files with 201 additions and 4 deletions

View File

@@ -8,4 +8,8 @@ import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
})
})
function foo() {
const p2 = import("./0");
}

View File

@@ -0,0 +1,12 @@
// @module: commonjs
// @target: es6
// @noImplicitAny: false
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
import(getSpecifier());
var p1 = import(getSpecifier());
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
p1.then(zero => {
return zero.foo(); // ok, zero is any
});

View File

@@ -0,0 +1,13 @@
// @module: commonjs
// @target: es6
// @noImplicitAny: false
declare function getSpecifier(): boolean;
declare var whatToLoad: boolean;
// Error specifier is not assignable to string
import(getSpecifier());
var p1 = import(getSpecifier());
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
p1.then(zero => {
return zero.foo(); // ok, zero is any
});

View File

@@ -0,0 +1,15 @@
// @module: es2015
// @target: esnext
// @filename: 0.ts
export function foo() { return "foo"; }
// @filename: 1.ts
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
})
function foo() {
const p2 = import("./0");
}

View File

@@ -8,4 +8,8 @@ import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
});
function foo() {
const p2 = import("./0");
}

View File

@@ -0,0 +1,17 @@
// @module: amd
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
// @filename: 2.ts
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
x.then(value => {
let b = new value.B();
b.print();
})
}
foo(import("./0"));

View File

@@ -0,0 +1,14 @@
// @module: amd
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
// @filename: 2.ts
async function foo() {
class C extends (await import("./0")).B {}
var c = new C();
c.print();
}
foo();

View File

@@ -0,0 +1,26 @@
// @module: amd
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
// @filename: 1.ts
export function backup() { return "backup"; }
// @filename: 2.ts
declare var console: any;
class C {
private myModule = import("./0");
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async err => {
console.log(err);
let one = await import("./1");
console.log(one.backup());
});
}
}

View File

@@ -8,4 +8,8 @@ import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
});
function foo() {
const p2 = import("./0");
}

View File

@@ -0,0 +1,15 @@
// @module: system
// @target: esnext
// @filename: 0.ts
export function foo() { return "foo"; }
// @filename: 1.ts
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}

View File

@@ -0,0 +1,17 @@
// @module: system
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
// @filename: 2.ts
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
x.then(value => {
let b = new value.B();
b.print();
})
}
foo(import("./0"));

View File

@@ -0,0 +1,14 @@
// @module: system
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
// @filename: 2.ts
async function foo() {
class C extends (await import("./0")).B {}
var c = new C();
c.print();
}
foo();

View File

@@ -0,0 +1,26 @@
// @module: system
// @target: esnext
// @filename: 0.ts
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
// @filename: 1.ts
export function backup() { return "backup"; }
// @filename: 2.ts
declare var console: any;
class C {
private myModule = import("./0");
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async err => {
console.log(err);
let one = await import("./1");
console.log(one.backup());
});
}
}

View File

@@ -8,4 +8,8 @@ import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
});
function foo() {
const p2 = import("./0");
}

View File

@@ -0,0 +1,12 @@
// @module: es2018
// @target: esnext
// @filename: 0.ts
// @noImplicitAny: true
// @filename: 1.ts
declare function ValidSomeCondition(): boolean;
import(ValidSomeCondition() ? "./0" : "externalModule"); // implicit any error
var p1 = import(ValidSomeCondition() ? "./0" : "externalModule"); // implicit any error
p1.then(zero => {
return zero.foo(); // ok
});