aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/regtest/misc/multiple_adhoc_test.go
blob: 5f803e4e385201e16b716b876343ed4c5f7eaf0c (plain)
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
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package misc

import (
	"testing"

	. "golang.org/x/tools/internal/lsp/regtest"
)

func TestMultipleAdHocPackages(t *testing.T) {
	Run(t, `
-- a/a.go --
package main

import "fmt"

func main() {
	fmt.Println("")
}
-- a/b.go --
package main

import "fmt"

func main() () {
	fmt.Println("")
}
`, func(t *testing.T, env *Env) {
		env.OpenFile("a/a.go")
		if list := env.Completion("a/a.go", env.RegexpSearch("a/a.go", "Println")); list == nil || len(list.Items) == 0 {
			t.Fatal("expected completions, got none")
		}
		env.OpenFile("a/b.go")
		if list := env.Completion("a/b.go", env.RegexpSearch("a/b.go", "Println")); list == nil || len(list.Items) == 0 {
			t.Fatal("expected completions, got none")
		}
		if list := env.Completion("a/a.go", env.RegexpSearch("a/a.go", "Println")); list == nil || len(list.Items) == 0 {
			t.Fatal("expected completions, got none")
		}
	})
}