-
Notifications
You must be signed in to change notification settings - Fork 38
/
types.go
85 lines (67 loc) · 1.77 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Package tests contains tests for minimock tool and demonstrates minimock features
package tests
import (
"context"
"google.golang.org/protobuf/proto"
)
type (
//Formatter interface is used to test code generated by minimock
Formatter interface {
formatter //to check if variadic functions are supported
}
formatter interface {
Format(string, ...interface{}) string //to check if variadic functions are supported
}
// these generic types provide all possible cases of type params declarations
// This produces invalid Go code when used with minimock v3.0.10 and below
genericInout[T any] interface {
Name(T) T
}
genericOut[T any] interface {
Name() T
}
genericIn[T any] interface {
Name(T)
}
// following types reference some specific constraints on generic types
// These are not generated properly with minimock v3.1.1 and below
// Reference a specific type
genericSpecific[T proto.Message] interface {
Name(T)
}
// Reference a single type as a simple union
simpleUnion interface {
int
}
// Reference a composite union of multiple types
complexUnion interface {
int | float64
}
genericSimpleUnion[T simpleUnion] interface {
Name(T)
}
genericComplexUnion[T complexUnion] interface {
Name(T)
}
genericInlineUnion[T int | float64] interface {
Name(T)
}
genericInlineUnionWithManyTypes[T int | float64 | string] interface {
Name(T)
}
genericMultipleTypes[T proto.Message, K any] interface {
Name(T, K)
}
structArg struct {
a int
b string
}
contextAccepter interface {
AcceptContext(context.Context)
AcceptContextWithOtherArgs(context.Context, int) (int, error)
AcceptContextWithStructArgs(context.Context, structArg) (int, error)
}
actor interface {
Action(firstParam string, secondParam int) (int, error)
}
)