@@ -33,12 +33,12 @@ func (g NegativePositiveTestsGenerator) TemplateData() any {
33
33
}
34
34
35
35
invalidAssertions = append (invalidAssertions ,
36
- Assertion {Fn : "Less" , Argsf : "a , " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
37
- Assertion {Fn : "Greater" , Argsf : zero + ", a" , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
38
- Assertion {Fn : "True" , Argsf : v + " < " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
39
- Assertion {Fn : "True" , Argsf : zero + " > " + v , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
40
- Assertion {Fn : "False" , Argsf : v + " >= " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
41
- Assertion {Fn : "False" , Argsf : zero + " <= " + v , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "a" },
36
+ Assertion {Fn : "Less" , Argsf : v + " , " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
37
+ Assertion {Fn : "Greater" , Argsf : zero + ", " + v , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
38
+ Assertion {Fn : "True" , Argsf : v + " < " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
39
+ Assertion {Fn : "True" , Argsf : zero + " > " + v , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
40
+ Assertion {Fn : "False" , Argsf : v + " >= " + zero , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
41
+ Assertion {Fn : "False" , Argsf : zero + " <= " + v , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : v },
42
42
)
43
43
}
44
44
@@ -54,15 +54,22 @@ func (g NegativePositiveTestsGenerator) TemplateData() any {
54
54
}
55
55
56
56
invalidAssertions = append (invalidAssertions ,
57
- Assertion {Fn : "Greater" , Argsf : "a , " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
58
- Assertion {Fn : "Less" , Argsf : zero + ", a" , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
59
- Assertion {Fn : "True" , Argsf : v + " > " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
60
- Assertion {Fn : "True" , Argsf : zero + " < " + v , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
61
- Assertion {Fn : "False" , Argsf : v + " <= " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
62
- Assertion {Fn : "False" , Argsf : zero + " >= " + v , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "a" },
57
+ Assertion {Fn : "Greater" , Argsf : v + " , " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
58
+ Assertion {Fn : "Less" , Argsf : zero + ", " + v , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
59
+ Assertion {Fn : "True" , Argsf : v + " > " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
60
+ Assertion {Fn : "True" , Argsf : zero + " < " + v , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
61
+ Assertion {Fn : "False" , Argsf : v + " <= " + zero , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
62
+ Assertion {Fn : "False" , Argsf : zero + " >= " + v , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : v },
63
63
)
64
64
}
65
65
66
+ invalidAssertions = append (invalidAssertions ,
67
+ Assertion {Fn : "True" , Argsf : "len(x) > 0" , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "len(x)" },
68
+ Assertion {Fn : "Greater" , Argsf : "len(x), 0" , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "len(x)" },
69
+ Assertion {Fn : "Less" , Argsf : "f(a), 0" , ReportMsgf : report , ProposedFn : "Negative" , ProposedArgsf : "f(a)" },
70
+ Assertion {Fn : "False" , Argsf : "0 >= f(a)" , ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "f(a)" },
71
+ )
72
+
66
73
var ignoredAssertions []Assertion
67
74
68
75
for _ , fn := range []string {"Equal" , "NotEqual" , "GreaterOrEqual" , "LessOrEqual" } {
@@ -192,16 +199,27 @@ func (g NegativePositiveTestsGenerator) TemplateData() any {
192
199
Assertion {Fn : "False" , Argsf : "-1 <= -1" },
193
200
Assertion {Fn : "False" , Argsf : "-1 == -1" },
194
201
Assertion {Fn : "False" , Argsf : "-1 != -1" },
202
+ Assertion {Fn : "GreaterOrEqual" , Argsf : "len(x), 0" },
203
+ Assertion {Fn : "LessOrEqual" , Argsf : "0, len(x)" },
195
204
)
196
205
197
206
// These one will be reported by incorrect-assert.
198
207
ignoredAssertions = append (ignoredAssertions ,
199
208
Assertion {Fn : "Negative" , Argsf : "uint(a)" },
200
209
Assertion {Fn : "Less" , Argsf : "uint(a), 0" },
210
+ Assertion {Fn : "Greater" , Argsf : "0, uint(a)" },
201
211
Assertion {Fn : "True" , Argsf : "uint(a) < 0" },
202
212
Assertion {Fn : "True" , Argsf : "0 > uint(a)" },
203
213
Assertion {Fn : "False" , Argsf : "uint(a) >= 0" },
204
214
Assertion {Fn : "False" , Argsf : "0 <= uint(a)" },
215
+
216
+ Assertion {Fn : "Negative" , Argsf : "len(x)" },
217
+ Assertion {Fn : "Less" , Argsf : "len(x), 0" },
218
+ Assertion {Fn : "Greater" , Argsf : "0, len(x)" },
219
+ Assertion {Fn : "True" , Argsf : "len(x) < 0" },
220
+ Assertion {Fn : "True" , Argsf : "0 > len(x)" },
221
+ Assertion {Fn : "False" , Argsf : "len(x) >= 0" },
222
+ Assertion {Fn : "False" , Argsf : "0 <= len(x)" },
205
223
)
206
224
207
225
return struct {
@@ -215,7 +233,10 @@ func (g NegativePositiveTestsGenerator) TemplateData() any {
215
233
InvalidAssertions : invalidAssertions ,
216
234
ValidAssertions : []Assertion {
217
235
{Fn : "Negative" , Argsf : "a" },
236
+ {Fn : "Negative" , Argsf : "f(a)" },
218
237
{Fn : "Positive" , Argsf : "a" },
238
+ {Fn : "Positive" , Argsf : "len(x)" },
239
+ {Fn : "Positive" , Argsf : "f(a)" },
219
240
},
220
241
IgnoredAssertions : ignoredAssertions ,
221
242
RealLifeUintExamples : []Assertion {
@@ -237,7 +258,7 @@ func (g NegativePositiveTestsGenerator) TemplateData() any {
237
258
},
238
259
{
239
260
Fn : "Greater" , Argsf : "uint64(state.LastUpdatedEpoch), uint64(0)" ,
240
- ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "state.LastUpdatedEpoch" ,
261
+ ReportMsgf : report , ProposedFn : "Positive" , ProposedArgsf : "uint64( state.LastUpdatedEpoch) " ,
241
262
},
242
263
{
243
264
Fn : "True" , Argsf : `uint64(0) < prod["last_claim_time"].(uint64)` ,
@@ -272,7 +293,11 @@ import (
272
293
)
273
294
274
295
func {{ .CheckerName.AsTestName }}(t *testing.T) {
275
- var a int
296
+ var (
297
+ a int
298
+ x []int
299
+ f func(d int) int
300
+ )
276
301
277
302
// Invalid.
278
303
{
0 commit comments