internal/lsp/regtest: add a regtest for golang/go#39296

Looks like the issue described in
https://github.com/golang/go/issues/39296#issuecomment-652058883 is
resolved with Go 1.15.

Fixes golang/go#39296

Change-Id: Ibe694281d4d4d40df3dc7bacc5837f593bb1dc5a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/241398
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/internal/lsp/regtest/diagnostics_test.go b/internal/lsp/regtest/diagnostics_test.go
index d70e1a8..451aed1 100644
--- a/internal/lsp/regtest/diagnostics_test.go
+++ b/internal/lsp/regtest/diagnostics_test.go
@@ -954,3 +954,42 @@
 		)
 	}, WithoutWorkspaceFolders())
 }
+
+// Reproduces the case described in
+// https://github.com/golang/go/issues/39296#issuecomment-652058883.
+func TestPkgm(t *testing.T) {
+	const basic = `
+-- go.mod --
+module mod.com
+
+go 1.15
+-- foo/foo.go --
+package foo
+
+import "fmt"
+
+func Foo() {
+	fmt.Println("")
+}
+`
+	runner.Run(t, basic, func(t *testing.T, env *Env) {
+		testenv.NeedsGo1Point(t, 15)
+
+		env.Await(
+			CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromInitialWorkspaceLoad), 1),
+		)
+		env.WriteWorkspaceFile("foo/foo_test.go", `package main
+
+func main() {
+
+}`)
+		env.OpenFile("foo/foo_test.go")
+		env.RegexpReplace("foo/foo_test.go", `package main`, `package foo`)
+		env.Await(
+			OnceMet(
+				CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChange), 1),
+				NoDiagnostics("foo/foo.go"),
+			),
+		)
+	})
+}