Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor switch support in
NodePath#getCompletionRecords
(#13030)
- Loading branch information
Showing
13 changed files
with
502 additions
and
95 deletions.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
...l-do-expressions/test/fixtures/do-expression-switch-case/condition-before-break/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
const x = n => function () { | ||
switch (n) { | ||
case 0: | ||
if (true) return void 0; | ||
if (true) { | ||
return void 0; | ||
} | ||
|
||
} | ||
}(); |
38 changes: 38 additions & 0 deletions
38
...l-do-expressions/test/fixtures/do-expression-switch-case/declaration-before-break/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const x = (n) => do { | ||
switch (n) { | ||
case 0: | ||
case 6: | ||
const b = 1; | ||
break; | ||
case 1: { | ||
("a"); | ||
{ | ||
const c = 1; | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
case 2: | ||
case 3: { | ||
("b"); | ||
if (n === 2) { | ||
const c = 1; | ||
} else { | ||
("c"); | ||
} | ||
{ | ||
break; | ||
} | ||
} | ||
default: | ||
"bar"; | ||
} | ||
}; | ||
|
||
expect(x(0)).toBeUndefined(); | ||
expect(x(1)).toBeUndefined(); | ||
expect(x(2)).toBeUndefined(); | ||
expect(x(3)).toBe("c"); | ||
expect(x(6)).toBeUndefined(); | ||
expect(x(7)).toBe("bar"); |
30 changes: 26 additions & 4 deletions
30
...-do-expressions/test/fixtures/do-expression-switch-case/declaration-before-break/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
const x = (n) => do { | ||
switch (n) { | ||
case 0: | ||
case 6: | ||
case 0: | ||
case 6: | ||
const b = 1; | ||
break; | ||
default: 'bar'; | ||
case 1: { | ||
("a"); | ||
{ | ||
const c = 1; | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
case 2: | ||
case 3: { | ||
("b"); | ||
if (n === 2) { | ||
const c = 1; | ||
} else { | ||
("c"); | ||
} | ||
{ | ||
break; | ||
} | ||
} | ||
default: | ||
"bar"; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ const x = n => function () { | |
} | ||
|
||
case 3: | ||
return void 0; | ||
{ | ||
return void 0; | ||
} | ||
|
||
case 4: | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
47 changes: 47 additions & 0 deletions
47
...l-do-expressions/test/fixtures/do-expression-switch-case/fallthrough-multiblock/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const x = n => function () { | ||
switch (n) { | ||
case 0: | ||
{ | ||
"a"; | ||
} | ||
{ | ||
"b"; | ||
} | ||
; | ||
|
||
case 1: | ||
{ | ||
return "c"; | ||
} | ||
{ | ||
"d"; | ||
} | ||
; | ||
|
||
case 2: | ||
"a"; | ||
"b"; | ||
|
||
case 3: | ||
{} | ||
{ | ||
return void 0; | ||
} | ||
|
||
case 4: | ||
{ | ||
"a"; | ||
} | ||
{ | ||
"b"; | ||
} | ||
|
||
case 5: | ||
return "c"; | ||
|
||
case 6: | ||
{} | ||
|
||
case 7: | ||
} | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...roposal-do-expressions/test/fixtures/do-expression-switch-case/nested-break-block/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const x = (n) => do { | ||
switch (n) { | ||
case 0: | ||
{ "a"; { break; } } | ||
{ "b"; }; | ||
case 1: | ||
{ "c"; } | ||
{ "d"; { { { { break; }}}}}; | ||
case 2: | ||
case 3: | ||
{ "e"; { if (true) { break; } } } | ||
{ break; } | ||
case 4: | ||
{ "g"; { { break; "h"; } "i" } } | ||
case 5: | ||
case 6: | ||
if (n === 5) { | ||
"j" | ||
} else { | ||
"k" | ||
} | ||
{ break; "l" } | ||
case 7: | ||
} | ||
} | ||
|
||
expect(x(0)).toBe('a') | ||
expect(x(1)).toBe('d') | ||
expect(x(2)).toBeUndefined() | ||
expect(x(3)).toBeUndefined() | ||
expect(x(4)).toBe("g") | ||
expect(x(5)).toBe("j") | ||
expect(x(6)).toBe("k") | ||
expect(x(7)).toBeUndefined() |
25 changes: 25 additions & 0 deletions
25
...oposal-do-expressions/test/fixtures/do-expression-switch-case/nested-break-block/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const x = (n) => do { | ||
switch (n) { | ||
case 0: | ||
{ "a"; { break; } } | ||
{ "b"; }; | ||
case 1: | ||
{ "c"; } | ||
{ "d"; { { { { break; }}}}}; | ||
case 2: | ||
case 3: | ||
{ "e"; { if (true) { break; } } } | ||
{ break; } | ||
case 4: | ||
{ "g"; { { break; "h"; } "i" } } | ||
case 5: | ||
case 6: | ||
if (n === 5) { | ||
"j" | ||
} else { | ||
"k" | ||
} | ||
{ break; "l" } | ||
case 7: | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...posal-do-expressions/test/fixtures/do-expression-switch-case/nested-break-block/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const x = n => function () { | ||
switch (n) { | ||
case 0: | ||
{ | ||
return "a"; | ||
{} | ||
} | ||
{ | ||
"b"; | ||
} | ||
; | ||
|
||
case 1: | ||
{ | ||
"c"; | ||
} | ||
{ | ||
return "d"; | ||
{ | ||
{ | ||
{ | ||
{} | ||
} | ||
} | ||
} | ||
} | ||
; | ||
|
||
case 2: | ||
case 3: | ||
{ | ||
"e"; | ||
{ | ||
if (true) { | ||
return void 0; | ||
} | ||
} | ||
} | ||
{} | ||
|
||
case 4: | ||
{ | ||
return "g"; | ||
{ | ||
{ | ||
"h"; | ||
} | ||
"i"; | ||
} | ||
} | ||
|
||
case 5: | ||
case 6: | ||
if (n === 5) { | ||
return "j"; | ||
} else { | ||
return "k"; | ||
} | ||
|
||
{ | ||
"l"; | ||
} | ||
|
||
case 7: | ||
} | ||
}(); |
Oops, something went wrong.