Skip to content

Commit f367650

Browse files
author
Kapil Borle
committed
Add tests for finding variable definitions in other files
1 parent 7419af8 commit f367650

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,36 @@ await this.SendRequest(
455455
Assert.Equal(7, locations[0].Range.End.Character);
456456
}
457457

458+
[Fact]
459+
public async Task FindsDefinitionOfVariableInOtherFile()
460+
{
461+
await this.SendOpenFileEvent("TestFiles\\FindReferences.ps1");
462+
463+
Location[] locations =
464+
await this.SendRequest(
465+
DefinitionRequest.Type,
466+
new TextDocumentPositionParams
467+
{
468+
TextDocument = new TextDocumentIdentifier
469+
{
470+
Uri = "TestFiles\\FindReferences.ps1"
471+
},
472+
Position = new Position
473+
{
474+
Line = 15,
475+
Character = 20,
476+
}
477+
});
478+
479+
Assert.NotNull(locations);
480+
Assert.Equal(1, locations.Length);
481+
Assert.EndsWith("VariableDefinition.ps1", locations[0].Uri);
482+
Assert.Equal(0, locations[0].Range.Start.Line);
483+
Assert.Equal(0, locations[0].Range.Start.Character);
484+
Assert.Equal(0, locations[0].Range.End.Line);
485+
Assert.Equal(20, locations[0].Range.End.Character);
486+
}
487+
458488
[Fact]
459489
public async Task FindsOccurencesOnFunctionDefinition()
460490
{

test/PowerShellEditorServices.Test.Host/TestFiles/FindReferences.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ My-Function $things
1010

1111
Write-Output "Hi";
1212

13-
Write-Output ""
13+
Write-Output ""
14+
15+
. .\VariableDefinition.ps1
16+
Write-Output $variableInOtherFile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$variableInOtherFile = "some value"

0 commit comments

Comments
 (0)