Skip to content

Commit b8c00d1

Browse files
committed
test union constraint type
1 parent 7daa360 commit b8c00d1

File tree

3 files changed

+271
-24
lines changed

3 files changed

+271
-24
lines changed

fixtures/genericinterface/genericinterface.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ package genericinterface
44

55
type CustomTypeT any
66
type CustomTypeU any
7-
type CustomTypeConstraint interface {
7+
type CustomTypeConstraintT interface {
88
~string
99
}
1010

11+
type CustomTypeConstraintU interface {
12+
int64 | float64
13+
}
14+
1115
// incorrect setup. this would fail
1216
// //counterfeiter:generate . GenericInterfaceBad[T CustomType]
1317
// type GenericInterfaceBad[T CustomTypeT] interface {
@@ -25,8 +29,16 @@ type GenericInterface[T CustomTypeT] interface {
2529
DoSomething()
2630
}
2731

28-
//counterfeiter:generate . GenericInterfaceCustomTypeConstraint
29-
type GenericInterfaceCustomTypeConstraint[T CustomTypeConstraint] interface {
32+
//counterfeiter:generate . GenericInterfaceCustomTypeConstraintT
33+
type GenericInterfaceCustomTypeConstraintT[T CustomTypeConstraintT] interface {
34+
ReturnT() T
35+
TakeT(T)
36+
TakeAndReturnT(T) T
37+
DoSomething()
38+
}
39+
40+
//counterfeiter:generate . GenericInterfaceCustomTypeConstraintU
41+
type GenericInterfaceCustomTypeConstraintU[T CustomTypeConstraintU] interface {
3042
ReturnT() T
3143
TakeT(T)
3244
TakeAndReturnT(T) T

fixtures/genericinterface/genericinterfacefakes/fake_generic_interface_custom_type_constraint.go renamed to fixtures/genericinterface/genericinterfacefakes/fake_generic_interface_custom_type_constraint_t.go

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)