Skip to content

Commit

Permalink
expand typeparams testscript
Browse files Browse the repository at this point in the history
It now includes more syntax, such as type sets.
Plus, we also check that we error on Go 1.17 and older.
  • Loading branch information
mvdan committed Nov 2, 2021
1 parent 6553de5 commit 44f79f5
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions testdata/scripts/typeparams.txt
@@ -1,25 +1,53 @@
[!go1.18] skip 'type parameters require Go 1.18 or later'
[go1.18] gofumpt foo.go
[!go1.18] ! gofumpt foo.go

gofumpt foo.go
cmp stdout foo.go.golden
[go1.18] cmp stdout foo.go.golden
[!go1.18] stderr 'foo.go:.*expected'

-- go.mod --
module test

go 1.18
-- foo.go --
package main
package p

func Foo[ A, B any](x A, y B) {}
func Foo[A, B any](x A, y B) {}

type Vector[T any] []T

var v Vector[int ]

type PredeclaredSignedInteger interface {
int | int8 | int16 | int32 | int64
}

type StringableSignedInteger interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
String() string

}

func main() {
func Caller() {
Foo[int,int](1,2)
}
-- foo.go.golden --
package main
package p

func Foo[A, B any](x A, y B) {}

func main() {
type Vector[T any] []T

var v Vector[int]

type PredeclaredSignedInteger interface {
int | int8 | int16 | int32 | int64
}

type StringableSignedInteger interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
String() string
}

func Caller() {
Foo[int, int](1, 2)
}

0 comments on commit 44f79f5

Please sign in to comment.