-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9c6635
commit 61451bd
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package typecheck_test | ||
|
||
// TODO: Figure out how to test this analyzer. | ||
// The golang.org/x/tools/go/analysis/analysistest testing tools set up a | ||
// "GOPATH-style project" [1], which seems to require vendoring dependencies. | ||
// This is ok for testing the Go standard library but isn't practical for | ||
// code with several transitive dependencies, as bigslice has. | ||
// [1] https://pkg.go.dev/golang.org/x/[email protected]/go/analysis/analysistest?tab=doc | ||
// | ||
// Until then, run and see no errors for urls but a type error for wrongarg: | ||
// $ go run github.com/grailbio/bigslice/cmd/slicetypecheck \ | ||
// github.com/grailbio/bigslice/cmd/urls \ | ||
// github.com/grailbio/bigslice/analysis/typecheck/typechecktest/wrongarg | ||
// <snip>/wrongarg.go:22:34: bigslice type error: func "testFunc" argument "argInt" requires int, but got string | ||
// exit status 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Tests the static slice typechecker. | ||
// | ||
// This is a correctly-typed Go program (even though it's incomplete and thus | ||
// not runnable, for simplicity). However, its bigslice Func invocation is | ||
// incorrectly typed, and the static typechecker find that, in this case. | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/grailbio/bigslice" | ||
"github.com/grailbio/bigslice/exec" | ||
) | ||
|
||
var testFunc = bigslice.Func(func(argInt int, argString string) bigslice.Slice { | ||
return nil | ||
}) | ||
|
||
func main() { | ||
ctx := context.Background() | ||
var session *exec.Session | ||
_ = session.Must(ctx, testFunc, "i should be an int", "i'm ok") | ||
} |