Skip to content

Commit 7f5103f

Browse files
authored
Add an extra test case related to control flow of element access using non-const variable (#56893)
1 parent 539d84a commit 7f5103f

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//// [tests/cases/conformance/controlFlow/controlFlowElementAccessNoCrash1.ts] ////
2+
3+
=== controlFlowElementAccessNoCrash1.ts ===
4+
interface TestTscEdit {
5+
>TestTscEdit : Symbol(TestTscEdit, Decl(controlFlowElementAccessNoCrash1.ts, 0, 0))
6+
7+
caption: string;
8+
>caption : Symbol(TestTscEdit.caption, Decl(controlFlowElementAccessNoCrash1.ts, 0, 23))
9+
10+
commandLineArgs?: readonly string[];
11+
>commandLineArgs : Symbol(TestTscEdit.commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 1, 18))
12+
}
13+
14+
interface TestTscCompile {
15+
>TestTscCompile : Symbol(TestTscCompile, Decl(controlFlowElementAccessNoCrash1.ts, 3, 1))
16+
17+
subScenario: string;
18+
>subScenario : Symbol(TestTscCompile.subScenario, Decl(controlFlowElementAccessNoCrash1.ts, 5, 26))
19+
20+
commandLineArgs: readonly string[];
21+
>commandLineArgs : Symbol(TestTscCompile.commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 6, 22))
22+
}
23+
24+
interface VerifyTscEditDiscrepanciesInput {
25+
>VerifyTscEditDiscrepanciesInput : Symbol(VerifyTscEditDiscrepanciesInput, Decl(controlFlowElementAccessNoCrash1.ts, 8, 1))
26+
27+
index: number;
28+
>index : Symbol(VerifyTscEditDiscrepanciesInput.index, Decl(controlFlowElementAccessNoCrash1.ts, 10, 43))
29+
30+
edits: readonly TestTscEdit[];
31+
>edits : Symbol(VerifyTscEditDiscrepanciesInput.edits, Decl(controlFlowElementAccessNoCrash1.ts, 11, 16))
32+
>TestTscEdit : Symbol(TestTscEdit, Decl(controlFlowElementAccessNoCrash1.ts, 0, 0))
33+
34+
commandLineArgs: TestTscCompile["commandLineArgs"];
35+
>commandLineArgs : Symbol(VerifyTscEditDiscrepanciesInput.commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 12, 32))
36+
>TestTscCompile : Symbol(TestTscCompile, Decl(controlFlowElementAccessNoCrash1.ts, 3, 1))
37+
}
38+
39+
function testTscCompile(input: TestTscCompile) {}
40+
>testTscCompile : Symbol(testTscCompile, Decl(controlFlowElementAccessNoCrash1.ts, 14, 1))
41+
>input : Symbol(input, Decl(controlFlowElementAccessNoCrash1.ts, 16, 24))
42+
>TestTscCompile : Symbol(TestTscCompile, Decl(controlFlowElementAccessNoCrash1.ts, 3, 1))
43+
44+
function verifyTscEditDiscrepancies({
45+
>verifyTscEditDiscrepancies : Symbol(verifyTscEditDiscrepancies, Decl(controlFlowElementAccessNoCrash1.ts, 16, 49))
46+
47+
index,
48+
>index : Symbol(index, Decl(controlFlowElementAccessNoCrash1.ts, 18, 37))
49+
50+
edits,
51+
>edits : Symbol(edits, Decl(controlFlowElementAccessNoCrash1.ts, 19, 8))
52+
53+
commandLineArgs,
54+
>commandLineArgs : Symbol(commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 20, 8))
55+
56+
}: VerifyTscEditDiscrepanciesInput) {
57+
>VerifyTscEditDiscrepanciesInput : Symbol(VerifyTscEditDiscrepanciesInput, Decl(controlFlowElementAccessNoCrash1.ts, 8, 1))
58+
59+
const { caption } = edits[index];
60+
>caption : Symbol(caption, Decl(controlFlowElementAccessNoCrash1.ts, 23, 9))
61+
>edits : Symbol(edits, Decl(controlFlowElementAccessNoCrash1.ts, 19, 8))
62+
>index : Symbol(index, Decl(controlFlowElementAccessNoCrash1.ts, 18, 37))
63+
64+
testTscCompile({
65+
>testTscCompile : Symbol(testTscCompile, Decl(controlFlowElementAccessNoCrash1.ts, 14, 1))
66+
67+
subScenario: caption,
68+
>subScenario : Symbol(subScenario, Decl(controlFlowElementAccessNoCrash1.ts, 24, 18))
69+
>caption : Symbol(caption, Decl(controlFlowElementAccessNoCrash1.ts, 23, 9))
70+
71+
commandLineArgs: edits[index].commandLineArgs || commandLineArgs,
72+
>commandLineArgs : Symbol(commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 25, 25))
73+
>edits[index].commandLineArgs : Symbol(TestTscEdit.commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 1, 18))
74+
>edits : Symbol(edits, Decl(controlFlowElementAccessNoCrash1.ts, 19, 8))
75+
>index : Symbol(index, Decl(controlFlowElementAccessNoCrash1.ts, 18, 37))
76+
>commandLineArgs : Symbol(TestTscEdit.commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 1, 18))
77+
>commandLineArgs : Symbol(commandLineArgs, Decl(controlFlowElementAccessNoCrash1.ts, 20, 8))
78+
79+
});
80+
}
81+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//// [tests/cases/conformance/controlFlow/controlFlowElementAccessNoCrash1.ts] ////
2+
3+
=== controlFlowElementAccessNoCrash1.ts ===
4+
interface TestTscEdit {
5+
caption: string;
6+
>caption : string
7+
8+
commandLineArgs?: readonly string[];
9+
>commandLineArgs : readonly string[] | undefined
10+
}
11+
12+
interface TestTscCompile {
13+
subScenario: string;
14+
>subScenario : string
15+
16+
commandLineArgs: readonly string[];
17+
>commandLineArgs : readonly string[]
18+
}
19+
20+
interface VerifyTscEditDiscrepanciesInput {
21+
index: number;
22+
>index : number
23+
24+
edits: readonly TestTscEdit[];
25+
>edits : readonly TestTscEdit[]
26+
27+
commandLineArgs: TestTscCompile["commandLineArgs"];
28+
>commandLineArgs : readonly string[]
29+
}
30+
31+
function testTscCompile(input: TestTscCompile) {}
32+
>testTscCompile : (input: TestTscCompile) => void
33+
>input : TestTscCompile
34+
35+
function verifyTscEditDiscrepancies({
36+
>verifyTscEditDiscrepancies : ({ index, edits, commandLineArgs, }: VerifyTscEditDiscrepanciesInput) => void
37+
38+
index,
39+
>index : number
40+
41+
edits,
42+
>edits : readonly TestTscEdit[]
43+
44+
commandLineArgs,
45+
>commandLineArgs : readonly string[]
46+
47+
}: VerifyTscEditDiscrepanciesInput) {
48+
const { caption } = edits[index];
49+
>caption : string
50+
>edits[index] : TestTscEdit
51+
>edits : readonly TestTscEdit[]
52+
>index : number
53+
54+
testTscCompile({
55+
>testTscCompile({ subScenario: caption, commandLineArgs: edits[index].commandLineArgs || commandLineArgs, }) : void
56+
>testTscCompile : (input: TestTscCompile) => void
57+
>{ subScenario: caption, commandLineArgs: edits[index].commandLineArgs || commandLineArgs, } : { subScenario: string; commandLineArgs: readonly string[]; }
58+
59+
subScenario: caption,
60+
>subScenario : string
61+
>caption : string
62+
63+
commandLineArgs: edits[index].commandLineArgs || commandLineArgs,
64+
>commandLineArgs : readonly string[]
65+
>edits[index].commandLineArgs || commandLineArgs : readonly string[]
66+
>edits[index].commandLineArgs : readonly string[] | undefined
67+
>edits[index] : TestTscEdit
68+
>edits : readonly TestTscEdit[]
69+
>index : number
70+
>commandLineArgs : readonly string[] | undefined
71+
>commandLineArgs : readonly string[]
72+
73+
});
74+
}
75+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
interface TestTscEdit {
5+
caption: string;
6+
commandLineArgs?: readonly string[];
7+
}
8+
9+
interface TestTscCompile {
10+
subScenario: string;
11+
commandLineArgs: readonly string[];
12+
}
13+
14+
interface VerifyTscEditDiscrepanciesInput {
15+
index: number;
16+
edits: readonly TestTscEdit[];
17+
commandLineArgs: TestTscCompile["commandLineArgs"];
18+
}
19+
20+
function testTscCompile(input: TestTscCompile) {}
21+
22+
function verifyTscEditDiscrepancies({
23+
index,
24+
edits,
25+
commandLineArgs,
26+
}: VerifyTscEditDiscrepanciesInput) {
27+
const { caption } = edits[index];
28+
testTscCompile({
29+
subScenario: caption,
30+
commandLineArgs: edits[index].commandLineArgs || commandLineArgs,
31+
});
32+
}

0 commit comments

Comments
 (0)