Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 612f4ab

Browse files
committed
Add while read test and update test name
1 parent 9a1b79c commit 612f4ab

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

‎server/src/__tests__/server.test.ts‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,42 +1739,47 @@ describe('server', () => {
17391739
// These may fail in the future when tree-sitter-bash's parsing gets better
17401740
// or when the rename symbol implementation is improved.
17411741
describe('Edge or not covered cases', () => {
1742-
it('does not include variables inside let and arithmetic expressions', async () => {
1742+
it('only includes variables typed as variable_name', async () => {
17431743
const iRanges = await getFirstChangeRanges(getRenameRequestResult(106, 4))
1744-
// This should be 6 if all instances are included.
1744+
// This should be 6 if all instances within let and arithmetic
1745+
// expressions are included.
17451746
expect(iRanges.length).toBe(2)
1747+
1748+
const lineRanges = await getFirstChangeRanges(getRenameRequestResult(118, 10))
1749+
// This should be 2 if the declaration of `line` is included.
1750+
expect(lineRanges.length).toBe(1)
17461751
})
17471752

17481753
it('includes incorrect number of symbols for complex scopes and nesting', async () => {
1749-
const varRanges = await getFirstChangeRanges(getRenameRequestResult(118, 8))
1754+
const varRanges = await getFirstChangeRanges(getRenameRequestResult(124, 8))
17501755
// This should only be 2 if `$var` from `3` is not included.
17511756
expect(varRanges.length).toBe(3)
17521757

1753-
const localFuncRanges = await getFirstChangeRanges(getRenameRequestResult(138, 5))
1758+
const localFuncRanges = await getFirstChangeRanges(getRenameRequestResult(144, 5))
17541759
// This should be 2 if the instance of `localFunc` in `callerFunc` is
17551760
// also included.
17561761
expect(localFuncRanges.length).toBe(1)
17571762
})
17581763

17591764
it('only takes into account subshells created with ( and )', async () => {
17601765
const pipelinevarRanges = await getFirstChangeRanges(
1761-
getRenameRequestResult(144, 7),
1766+
getRenameRequestResult(150, 7),
17621767
)
17631768
// This should only be 1 if pipeline subshell scoping is recognized.
17641769
expect(pipelinevarRanges.length).toBe(2)
17651770
})
17661771

17671772
it('does not take into account sourcing location and scope', async () => {
1768-
const FOOUris = await getChangeUris(getRenameRequestResult(148, 8))
1773+
const FOOUris = await getChangeUris(getRenameRequestResult(154, 8))
17691774
// This should only be 1 if sourcing after a symbol does not affect it.
17701775
expect(FOOUris.length).toBe(2)
17711776

1772-
const hello_worldUris = await getChangeUris(getRenameRequestResult(154, 6))
1777+
const hello_worldUris = await getChangeUris(getRenameRequestResult(160, 6))
17731778
// This should only be 1 if sourcing inside an uncalled function does
17741779
// not affect symbols outside of it.
17751780
expect(hello_worldUris.length).toBe(2)
17761781

1777-
const PATH_INPUTUris = await getChangeUris(getRenameRequestResult(157, 9))
1782+
const PATH_INPUTUris = await getChangeUris(getRenameRequestResult(163, 9))
17781783
// This should only be 1 if sourcing inside a subshell does not affect
17791784
// symbols outside of it.
17801785
expect(PATH_INPUTUris.length).toBe(2)

‎testing/fixtures/renaming.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ for (( ; i < 10; i++)); do
113113
echo "$((2 * i))"
114114
done
115115

116+
# tree-sitter-bash's parsing limitations with while read loops
117+
118+
while read -r line; do
119+
echo "$line"
120+
done < somefile.txt
121+
116122
# Complex nesting affects self-assignment handling
117123

118124
1() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /