-
Notifications
You must be signed in to change notification settings - Fork 0
/
workspace_declaration_import_test.go
67 lines (56 loc) · 1.6 KB
/
workspace_declaration_import_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package langd
import (
"go/token"
"path/filepath"
"testing"
)
func Test_Workspace_Declaration_Import_Const(t *testing.T) {
src1 := `package foo
const (
Fooval = 1
)`
src2 := `package bar
import (
"../foo"
)
func fooer() int {
return foo.Fooval
}`
rootPath, overlayFs := createOverlay(map[string]string{
filepath.Join("foo", "foo.go"): src1,
filepath.Join("bar", "bar.go"): src2,
})
barPath := filepath.Join(rootPath, "bar")
barGoPath := filepath.Join(rootPath, "bar", "bar.go")
fooGoPath := filepath.Join(rootPath, "foo", "foo.go")
w, closer := workspaceSetup(t, barPath, overlayFs, false)
defer closer()
usagePosition := &token.Position{Filename: barGoPath, Line: 6, Column: 14}
declPosition := &token.Position{Filename: fooGoPath, Line: 3, Column: 3}
testDeclaration(t, w, usagePosition, declPosition)
}
func Test_Workspace_Declaration_Import_Func(t *testing.T) {
src1 := `package foo
func FooFunc() int {
return 1
}`
src2 := `package bar
import (
"../foo"
)
func fooer() int {
return foo.FooFunc()
}`
rootPath, overlayFs := createOverlay(map[string]string{
filepath.Join("foo", "foo.go"): src1,
filepath.Join("bar", "bar.go"): src2,
})
barPath := filepath.Join(rootPath, "bar")
barGoPath := filepath.Join(rootPath, "bar", "bar.go")
fooGoPath := filepath.Join(rootPath, "foo", "foo.go")
w, closer := workspaceSetup(t, barPath, overlayFs, false)
defer closer()
usagePosition := &token.Position{Filename: barGoPath, Line: 6, Column: 14}
declPosition := &token.Position{Filename: fooGoPath, Line: 2, Column: 7}
testDeclaration(t, w, usagePosition, declPosition)
}