Skip to content

Commit 1b0d020

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests and update baselines
1 parent a2d9fd4 commit 1b0d020

36 files changed

+511
-54
lines changed

tests/baselines/reference/importCallExpressionCheckReturntype1.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class C {
2929
exports.C = C;
3030
//// [1.js]
3131
"use strict";
32+
var __resolved = new Promise(function (resolve) { resolve(); });
3233
Object.defineProperty(exports, "__esModule", { value: true });
33-
let p1 = Promise.resolve().then(() => require("./defaultPath"));
34-
let p2 = Promise.resolve().then(() => require("./defaultPath"));
35-
let p3 = Promise.resolve().then(() => require("./defaultPath"));
34+
let p1 = __resolved.then(function () { return require("./defaultPath"); });
35+
let p2 = __resolved.then(function () { return require("./defaultPath"); });
36+
let p3 = __resolved.then(function () { return require("./defaultPath"); });

tests/baselines/reference/importCallExpressionDeclarationEmit1.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ function returnDynamicLoad(path: string) {
1515
}
1616

1717
//// [importCallExpressionDeclarationEmit1.js]
18-
Promise.resolve().then(() => require(getSpecifier()));
19-
var p0 = Promise.resolve().then(() => require(`${directory}\${moduleFile}`));
20-
var p1 = Promise.resolve().then(() => require(getSpecifier()));
21-
const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath"));
18+
var __resolved = new Promise(function (resolve) { resolve(); });
19+
__resolved.then(function () { return require(getSpecifier()); });
20+
var p0 = __resolved.then(function () { return require(`${directory}\${moduleFile}`); });
21+
var p1 = __resolved.then(function () { return require(getSpecifier()); });
22+
const p2 = __resolved.then(function () { return require(whatToLoad ? getSpecifier() : "defaulPath"); });
2223
function returnDynamicLoad(path) {
23-
return Promise.resolve().then(() => require(path));
24+
return __resolved.then(function () { return require(path); });
2425
}
2526

2627

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// [tests/cases/conformance/es2018/dynamicImport/importCallExpressionES5AMD.ts] ////
2+
3+
//// [0.ts]
4+
export function foo() { return "foo"; }
5+
6+
//// [1.ts]
7+
import("./0");
8+
var p1 = import("./0");
9+
p1.then(zero => {
10+
return zero.foo();
11+
});
12+
13+
function foo() {
14+
const p2 = import("./0");
15+
}
16+
17+
//// [0.js]
18+
define(["require", "exports"], function (require, exports) {
19+
"use strict";
20+
Object.defineProperty(exports, "__esModule", { value: true });
21+
function foo() { return "foo"; }
22+
exports.foo = foo;
23+
});
24+
//// [1.js]
25+
define(["require", "exports"], function (require, exports) {
26+
"use strict";
27+
new Promise(function (_a, _b) { require(["./0"], _a, _b); });
28+
var p1 = new Promise(function (_a, _b) { require(["./0"], _a, _b); });
29+
p1.then(function (zero) {
30+
return zero.foo();
31+
});
32+
function foo() {
33+
var p2 = new Promise(function (_a, _b) { require(["./0"], _a, _b); });
34+
}
35+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/conformance/es2018/dynamicImport/0.ts ===
2+
export function foo() { return "foo"; }
3+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
4+
5+
=== tests/cases/conformance/es2018/dynamicImport/1.ts ===
6+
import("./0");
7+
var p1 = import("./0");
8+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
9+
10+
p1.then(zero => {
11+
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
12+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
13+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
14+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
15+
16+
return zero.foo();
17+
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
18+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
19+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
20+
21+
});
22+
23+
function foo() {
24+
>foo : Symbol(foo, Decl(1.ts, 4, 3))
25+
26+
const p2 = import("./0");
27+
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
=== tests/cases/conformance/es2018/dynamicImport/0.ts ===
2+
export function foo() { return "foo"; }
3+
>foo : () => string
4+
>"foo" : "foo"
5+
6+
=== tests/cases/conformance/es2018/dynamicImport/1.ts ===
7+
import("./0");
8+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
9+
>"./0" : "./0"
10+
11+
var p1 = import("./0");
12+
>p1 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
13+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
14+
>"./0" : "./0"
15+
16+
p1.then(zero => {
17+
>p1.then(zero => { return zero.foo();}) : Promise<string>
18+
>p1.then : <TResult1 = typeof "tests/cases/conformance/es2018/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/es2018/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
19+
>p1 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
20+
>then : <TResult1 = typeof "tests/cases/conformance/es2018/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/es2018/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
21+
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/es2018/dynamicImport/0") => string
22+
>zero : typeof "tests/cases/conformance/es2018/dynamicImport/0"
23+
24+
return zero.foo();
25+
>zero.foo() : string
26+
>zero.foo : () => string
27+
>zero : typeof "tests/cases/conformance/es2018/dynamicImport/0"
28+
>foo : () => string
29+
30+
});
31+
32+
function foo() {
33+
>foo : () => void
34+
35+
const p2 = import("./0");
36+
>p2 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
37+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
38+
>"./0" : "./0"
39+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [tests/cases/conformance/es2018/dynamicImport/importCallExpressionES5CJS.ts] ////
2+
3+
//// [0.ts]
4+
export function foo() { return "foo"; }
5+
6+
//// [1.ts]
7+
import("./0");
8+
var p1 = import("./0");
9+
p1.then(zero => {
10+
return zero.foo();
11+
});
12+
13+
function foo() {
14+
const p2 = import("./0");
15+
}
16+
17+
//// [0.js]
18+
"use strict";
19+
Object.defineProperty(exports, "__esModule", { value: true });
20+
function foo() { return "foo"; }
21+
exports.foo = foo;
22+
//// [1.js]
23+
var __resolved = new Promise(function (resolve) { resolve(); });
24+
__resolved.then(function () { return require("./0"); });
25+
var p1 = __resolved.then(function () { return require("./0"); });
26+
p1.then(function (zero) {
27+
return zero.foo();
28+
});
29+
function foo() {
30+
var p2 = __resolved.then(function () { return require("./0"); });
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/conformance/es2018/dynamicImport/0.ts ===
2+
export function foo() { return "foo"; }
3+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
4+
5+
=== tests/cases/conformance/es2018/dynamicImport/1.ts ===
6+
import("./0");
7+
var p1 = import("./0");
8+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
9+
10+
p1.then(zero => {
11+
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
12+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
13+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
14+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
15+
16+
return zero.foo();
17+
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
18+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
19+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
20+
21+
});
22+
23+
function foo() {
24+
>foo : Symbol(foo, Decl(1.ts, 4, 3))
25+
26+
const p2 = import("./0");
27+
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
=== tests/cases/conformance/es2018/dynamicImport/0.ts ===
2+
export function foo() { return "foo"; }
3+
>foo : () => string
4+
>"foo" : "foo"
5+
6+
=== tests/cases/conformance/es2018/dynamicImport/1.ts ===
7+
import("./0");
8+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
9+
>"./0" : "./0"
10+
11+
var p1 = import("./0");
12+
>p1 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
13+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
14+
>"./0" : "./0"
15+
16+
p1.then(zero => {
17+
>p1.then(zero => { return zero.foo();}) : Promise<string>
18+
>p1.then : <TResult1 = typeof "tests/cases/conformance/es2018/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/es2018/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
19+
>p1 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
20+
>then : <TResult1 = typeof "tests/cases/conformance/es2018/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/es2018/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
21+
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/es2018/dynamicImport/0") => string
22+
>zero : typeof "tests/cases/conformance/es2018/dynamicImport/0"
23+
24+
return zero.foo();
25+
>zero.foo() : string
26+
>zero.foo : () => string
27+
>zero : typeof "tests/cases/conformance/es2018/dynamicImport/0"
28+
>foo : () => string
29+
30+
});
31+
32+
function foo() {
33+
>foo : () => void
34+
35+
const p2 = import("./0");
36+
>p2 : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
37+
>import("./0") : Promise<typeof "tests/cases/conformance/es2018/dynamicImport/0">
38+
>"./0" : "./0"
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [tests/cases/conformance/es2018/dynamicImport/importCallExpressionES5System.ts] ////
2+
3+
//// [0.ts]
4+
export function foo() { return "foo"; }
5+
6+
//// [1.ts]
7+
import("./0");
8+
var p1 = import("./0");
9+
p1.then(zero => {
10+
return zero.foo();
11+
});
12+
13+
function foo() {
14+
const p2 = import("./0");
15+
}
16+
17+
//// [0.js]
18+
System.register([], function (exports_1, context_1) {
19+
"use strict";
20+
var __moduleName = context_1 && context_1.id;
21+
function foo() { return "foo"; }
22+
exports_1("foo", foo);
23+
return {
24+
setters: [],
25+
execute: function () {
26+
}
27+
};
28+
});
29+
//// [1.js]
30+
System.register([], function (exports_1, context_1) {
31+
var __moduleName = context_1 && context_1.id;
32+
function foo() {
33+
var p2 = context_1.import("./0");
34+
}
35+
var p1;
36+
return {
37+
setters: [],
38+
execute: function () {
39+
context_1.import("./0");
40+
p1 = context_1.import("./0");
41+
p1.then(function (zero) {
42+
return zero.foo();
43+
});
44+
}
45+
};
46+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/conformance/es2018/dynamicImport/0.ts ===
2+
export function foo() { return "foo"; }
3+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
4+
5+
=== tests/cases/conformance/es2018/dynamicImport/1.ts ===
6+
import("./0");
7+
var p1 = import("./0");
8+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
9+
10+
p1.then(zero => {
11+
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
12+
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
13+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
14+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
15+
16+
return zero.foo();
17+
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
18+
>zero : Symbol(zero, Decl(1.ts, 2, 8))
19+
>foo : Symbol(foo, Decl(0.ts, 0, 0))
20+
21+
});
22+
23+
function foo() {
24+
>foo : Symbol(foo, Decl(1.ts, 4, 3))
25+
26+
const p2 = import("./0");
27+
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
28+
}

0 commit comments

Comments
 (0)