Update tests

This commit is contained in:
Kanchalai Tanglertsampan
2017-03-22 15:10:19 -07:00
parent c798489eb1
commit c62f4f5888
8 changed files with 102 additions and 13 deletions

View File

@@ -1,12 +0,0 @@
// @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,14 @@
// @module: commonjs
// @target: es6
// @noImplicitAny: false
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
var a = ["./0"];
import(...["PathModule"]);
var p1 = import(...a);
const p2 = import();
const p3 = import(,);
const p4 = import("pathToModule", "secondModule");

View File

@@ -0,0 +1,17 @@
// @module: umd
// @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: umd
// @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: umd
// @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

@@ -0,0 +1,26 @@
// @module: commonjs
// @target: es6
// @noImplicitAny: false
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
declare const directory: string;
declare const moduleFile: number;
import(`${directory}\${moduleFile}`);
import(getSpecifier());
var p1 = import(getSpecifier());
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
p1.then(zero => {
return zero.foo(); // ok, zero is any
});
let j: string;
var p3 = import(j=getSpecifier());
function * loadModule(directories: string[]) {
for (const directory of directories) {
const path = `${directory}\moduleFile`;
import(yield path);
}
}

View File

@@ -4,10 +4,14 @@
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
});
});
var p3 = import(["path1", "path2"]);
var p4 = import(()=>"PathToModule");