Open suzmue opened 2 years ago
For some inputs, gotests fails to generate tests:
typeparams.go
package typeparams
type Set[T comparable] struct {
m map[T]struct{}
}
func (o *Set[T]) Add(v T) {
o.m[v] = struct{}{}
}
func (o *Set[T]) Has(v T) bool {
_, ok := o.m[v]
return ok
}
gotests
output:
output.Process: imports.Process: /var/folders/fw/grysx2h56354vh4_30px6_r80000gp/T/gotests_112301585:9:14: all type parameters must be named (and 1 more errors)
Filing this issue to track/ discuss generic function support for gotests.
Currently, gotests produces a table driven test for a function with type parameters, but the test needs to actually be modified to include concrete types (the test file will have build errors).
Example:
typeparams.go:
typeparams_test.go:
Can better table driven tests be generated for functions with type params / should the generated tests make sure there are no build errors?
Related go issue: golang/go#50558