Skip to content

Commit 925e70e

Browse files
committed
Extra tests in preparation for lazy signature making sure the original intent of test is maintained
1 parent b925c16 commit 925e70e

File tree

91 files changed

+40357
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+40357
-108
lines changed

src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts

+32-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ namespace ts {
1313
subScenario: "inferred type from transitive module",
1414
fs: () => projFs,
1515
commandLineArgs: ["--b", "/src", "--verbose"],
16-
incrementalScenarios: [{
17-
buildKind: BuildKind.IncrementalDtsChange,
18-
modifyFs: changeBarParam,
19-
}],
16+
incrementalScenarios: [
17+
{
18+
buildKind: BuildKind.IncrementalDtsChange,
19+
modifyFs: changeBarParam,
20+
},
21+
{
22+
buildKind: BuildKind.IncrementalDtsChange,
23+
modifyFs: changeBarParamBack,
24+
},
25+
],
2026
});
2127

2228
verifyTscSerializedIncrementalEdits({
@@ -25,10 +31,16 @@ namespace ts {
2531
scenario: "inferredTypeFromTransitiveModule",
2632
commandLineArgs: ["--b", "/src", "--verbose"],
2733
modifyFs: changeToIsolatedModules,
28-
incrementalScenarios: [{
29-
buildKind: BuildKind.IncrementalDtsChange,
30-
modifyFs: changeBarParam
31-
}]
34+
incrementalScenarios: [
35+
{
36+
buildKind: BuildKind.IncrementalDtsChange,
37+
modifyFs: changeBarParam
38+
},
39+
{
40+
buildKind: BuildKind.IncrementalDtsChange,
41+
modifyFs: changeBarParamBack,
42+
},
43+
]
3244
});
3345

3446
verifyTscSerializedIncrementalEdits({
@@ -43,6 +55,14 @@ import { default as bar } from './bar';
4355
bar("hello");`);
4456
},
4557
incrementalScenarios: [
58+
{
59+
buildKind: BuildKind.IncrementalDtsChange,
60+
modifyFs: changeBarParam
61+
},
62+
{
63+
buildKind: BuildKind.IncrementalDtsChange,
64+
modifyFs: changeBarParamBack,
65+
},
4666
{
4767
buildKind: BuildKind.IncrementalDtsChange,
4868
modifyFs: changeBarParam
@@ -63,4 +83,8 @@ bar("hello");`);
6383
function changeBarParam(fs: vfs.FileSystem) {
6484
replaceText(fs, "/src/bar.ts", "param: string", "");
6585
}
86+
87+
function changeBarParamBack(fs: vfs.FileSystem) {
88+
replaceText(fs, "/src/bar.ts", "foobar()", "foobar(param: string)");
89+
}
6690
}

src/testRunner/unittests/tsbuild/lateBoundSymbol.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ namespace ts {
55
fs: () => loadProjectFromDisk("tests/projects/lateBoundSymbol"),
66
scenario: "lateBoundSymbol",
77
commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"],
8-
incrementalScenarios: [{
9-
buildKind: BuildKind.IncrementalDtsUnchanged,
10-
modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
11-
}]
8+
incrementalScenarios: [
9+
{
10+
buildKind: BuildKind.IncrementalDtsUnchanged,
11+
modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""),
12+
},
13+
{
14+
buildKind: BuildKind.IncrementalDtsUnchanged,
15+
modifyFs: fs => appendText(fs, "/src/src/main.ts", "const x = 10;"),
16+
},
17+
]
1218
});
1319
});
1420
}

src/testRunner/unittests/tsc/incremental.ts

+31-22
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ const a: string = 10;`, "utf-8"),
264264
buildKind: BuildKind.IncrementalDtsChange,
265265
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
266266
},
267+
{
268+
subScenario: "Modify main file again",
269+
buildKind: BuildKind.IncrementalDtsChange,
270+
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
271+
},
267272
{
268273
subScenario: "Add new file and update main file",
269274
buildKind: BuildKind.IncrementalDtsChange,
@@ -288,7 +293,9 @@ const a: string = 10;`, "utf-8"),
288293
baselinePrograms: true,
289294
});
290295

291-
const jsxLibraryContent = `
296+
describe("when synthesized imports are added to files", () => {
297+
function getJsxLibraryContent() {
298+
return `
292299
export {};
293300
declare global {
294301
namespace JSX {
@@ -300,29 +307,31 @@ declare global {
300307
}
301308
}
302309
}`;
310+
}
303311

304-
verifyTsc({
305-
scenario: "react-jsx-emit-mode",
306-
subScenario: "with no backing types found doesn't crash",
307-
fs: () => loadProjectFromFiles({
308-
"/src/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
309-
"/src/project/node_modules/@types/react/index.d.ts": jsxLibraryContent, // doesn't contain a jsx-runtime definition
310-
"/src/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
311-
"/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } })
312-
}),
313-
commandLineArgs: ["--p", "src/project"]
314-
});
312+
verifyTsc({
313+
scenario: "react-jsx-emit-mode",
314+
subScenario: "with no backing types found doesn't crash",
315+
fs: () => loadProjectFromFiles({
316+
"/src/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
317+
"/src/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition
318+
"/src/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
319+
"/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } })
320+
}),
321+
commandLineArgs: ["--p", "src/project"]
322+
});
315323

316-
verifyTsc({
317-
scenario: "react-jsx-emit-mode",
318-
subScenario: "with no backing types found doesn't crash under --strict",
319-
fs: () => loadProjectFromFiles({
320-
"/src/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
321-
"/src/project/node_modules/@types/react/index.d.ts": jsxLibraryContent, // doesn't contain a jsx-runtime definition
322-
"/src/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
323-
"/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } })
324-
}),
325-
commandLineArgs: ["--p", "src/project", "--strict"]
324+
verifyTsc({
325+
scenario: "react-jsx-emit-mode",
326+
subScenario: "with no backing types found doesn't crash under --strict",
327+
fs: () => loadProjectFromFiles({
328+
"/src/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
329+
"/src/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition
330+
"/src/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
331+
"/src/project/tsconfig.json": JSON.stringify({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } })
332+
}),
333+
commandLineArgs: ["--p", "src/project", "--strict"]
334+
});
326335
});
327336
});
328337
}

src/testRunner/unittests/tscWatch/emit.ts

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ namespace ts.tscWatch {
2626
caption: "Make change in the file",
2727
change: sys => sys.writeFile("/a/a.ts", "let x = 11"),
2828
timeouts: runQueuedTimeoutCallbacks
29+
},
30+
{
31+
caption: "Make change in the file again",
32+
change: sys => sys.writeFile("/a/a.ts", "let xy = 11"),
33+
timeouts: runQueuedTimeoutCallbacks
2934
}
3035
]
3136
});
@@ -410,6 +415,11 @@ export var x = Foo();`
410415
caption: "Append content to f1",
411416
change: sys => sys.appendFile("/a/b/f1.ts", "export function foo2() { return 2; }"),
412417
timeouts: checkSingleTimeoutQueueLengthAndRun,
418+
},
419+
{
420+
caption: "Again Append content to f1",
421+
change: sys => sys.appendFile("/a/b/f1.ts", "export function fooN() { return 2; }"),
422+
timeouts: checkSingleTimeoutQueueLengthAndRun,
413423
}
414424
],
415425
});

src/testRunner/unittests/tscWatch/emitAndErrorUpdates.ts

+42-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ namespace ts.tscWatch {
2727
changes,
2828
baselineIncremental
2929
});
30+
verifyTscWatch({
31+
scenario: "emitAndErrorUpdates",
32+
subScenario: `incremental/${subScenario}`,
33+
commandLineArgs: ["--w", "--i"],
34+
sys: () => createWatchedSystem(
35+
[...files(), configFile(), lib?.() || libFile],
36+
{ currentDirectory: currentDirectory || projectRoot }
37+
),
38+
changes,
39+
baselineIncremental
40+
});
3041
}
3142

3243
function changeCompilerOptions(input: VerifyEmitAndErrorUpdates, additionalOptions: CompilerOptions): File {
@@ -97,6 +108,16 @@ console.log(b.c.d);`
97108
subScenario: `deepImportChanges/${subScenario}`,
98109
files: () => [aFile, bFile, cFile],
99110
changes: [
111+
{
112+
caption: "Rename property d to d2 of class C to initialize signatures",
113+
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
114+
timeouts: runQueuedTimeoutCallbacks,
115+
},
116+
{
117+
caption: "Rename property d2 to d of class C to revert back to original text",
118+
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d2", "d")),
119+
timeouts: runQueuedTimeoutCallbacks,
120+
},
100121
{
101122
caption: "Rename property d to d2 of class C",
102123
change: sys => sys.writeFile(cFile.path, cFile.content.replace("d", "d2")),
@@ -197,11 +218,21 @@ getPoint().c.x;`
197218
subScenario: "file not exporting a deep multilevel import that changes",
198219
files: () => [aFile, bFile, cFile, dFile, eFile],
199220
changes: [
221+
{
222+
caption: "Rename property x2 to x of interface Coords to initialize signatures",
223+
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
224+
timeouts: runQueuedTimeoutCallbacks,
225+
},
226+
{
227+
caption: "Rename property x to x2 of interface Coords to revert back to original text",
228+
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x: number", "x2: number")),
229+
timeouts: runQueuedTimeoutCallbacks,
230+
},
200231
{
201232
caption: "Rename property x2 to x of interface Coords",
202233
change: sys => sys.writeFile(aFile.path, aFile.content.replace("x2", "x")),
203234
timeouts: runQueuedTimeoutCallbacks,
204-
}
235+
},
205236
]
206237
});
207238
});
@@ -260,6 +291,16 @@ export class Data {
260291
files: () => [lib1ToolsInterface, lib1ToolsPublic, app, lib2Public, lib1Public, ...files],
261292
configFile: () => config,
262293
changes: [
294+
{
295+
caption: "Rename property title to title2 of interface ITest to initialize signatures",
296+
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),
297+
timeouts: runQueuedTimeoutCallbacks,
298+
},
299+
{
300+
caption: "Rename property title2 to title of interface ITest to revert back to original text",
301+
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title2", "title")),
302+
timeouts: runQueuedTimeoutCallbacks,
303+
},
263304
{
264305
caption: "Rename property title to title2 of interface ITest",
265306
change: sys => sys.writeFile(lib1ToolsInterface.path, lib1ToolsInterface.content.replace("title", "title2")),

src/testRunner/unittests/tscWatch/programUpdates.ts

+10
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ namespace ts.tscWatch {
122122
return createWatchedSystem([libFile, commonFile1, commonFile2, configFile]);
123123
},
124124
changes: [
125+
{
126+
caption: "change file to ensure signatures are updated",
127+
change: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
128+
timeouts: checkSingleTimeoutQueueLengthAndRun,
129+
},
125130
{
126131
caption: "delete file2",
127132
change: sys => sys.deleteFile(commonFile2.path),
@@ -171,6 +176,11 @@ namespace ts.tscWatch {
171176
return createWatchedSystem([libFile, commonFile1, commonFile2, configFile]);
172177
},
173178
changes: [
179+
{
180+
caption: "change file to ensure signatures are updated",
181+
change: sys => sys.appendFile(commonFile2.path, ";let xy = 10;"),
182+
timeouts: checkSingleTimeoutQueueLengthAndRun,
183+
},
174184
{
175185
caption: "Change config",
176186
change: sys => sys.writeFile(configFilePath, `{

src/testRunner/unittests/tsserver/compileOnSave.ts

+4
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,13 @@ function bar() {
952952

953953
// Change file1 get affected file list
954954
verifyLocalEdit(file1, "hello", "world");
955+
verifyLocalEdit(file1, "world", "hello");
956+
verifyLocalEdit(file1, "hello", "world");
955957

956958
// Change file2 get affected file list = will return only file2 if --declaration otherwise all files
957959
verifyLocalEdit(file2, "world", "hello", /*returnsAllFilesAsAffected*/ !declaration);
960+
verifyLocalEdit(file2, "hello", "world");
961+
verifyLocalEdit(file2, "world", "hello");
958962

959963
function verifyFileSave(file: File) {
960964
const response = session.executeCommandSeq<protocol.CompileOnSaveEmitFileRequest>({

0 commit comments

Comments
 (0)