golang.org/x/tools/gopls@v0.15.3/internal/test/integration/misc/multiple_adhoc_test.go (about)

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package misc
     6  
     7  import (
     8  	"testing"
     9  
    10  	. "golang.org/x/tools/gopls/internal/test/integration"
    11  )
    12  
    13  func TestMultipleAdHocPackages(t *testing.T) {
    14  	Run(t, `
    15  -- a/a.go --
    16  package main
    17  
    18  import "fmt"
    19  
    20  func main() {
    21  	fmt.Println("")
    22  }
    23  -- a/b.go --
    24  package main
    25  
    26  import "fmt"
    27  
    28  func main() () {
    29  	fmt.Println("")
    30  }
    31  `, func(t *testing.T, env *Env) {
    32  		env.OpenFile("a/a.go")
    33  		if list := env.Completion(env.RegexpSearch("a/a.go", "Println")); list == nil || len(list.Items) == 0 {
    34  			t.Fatal("expected completions, got none")
    35  		}
    36  		env.OpenFile("a/b.go")
    37  		if list := env.Completion(env.RegexpSearch("a/b.go", "Println")); list == nil || len(list.Items) == 0 {
    38  			t.Fatal("expected completions, got none")
    39  		}
    40  		if list := env.Completion(env.RegexpSearch("a/a.go", "Println")); list == nil || len(list.Items) == 0 {
    41  			t.Fatal("expected completions, got none")
    42  		}
    43  	})
    44  }