@@ -115,7 +115,7 @@ func Test_newComparisonEvaluator(t *testing.T) {
115
115
116
116
JanFirst2023 := time .Date (2023 , 1 , 1 , 0 , 0 , 0 , 0 , time .Local )
117
117
118
- var tests = []struct {
118
+ tests : = []struct {
119
119
name string
120
120
l any
121
121
r any
@@ -159,16 +159,16 @@ func Test_newComparisonEvaluator(t *testing.T) {
159
159
{name : "compare not greater than equal to durations" , l : "dur1" , r : "dur2" , op : ">=" , want : false , item : map [string ]time.Duration {"dur1" : oneMillisecond , "dur2" : threeSeconds }},
160
160
{name : "compare equal times" , l : "time1" , r : "time2" , op : "==" , want : true , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : JanFirst2023 }},
161
161
{name : "compare unequal times" , l : "time1" , r : "time2" , op : "==" , want : false , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : time .Date (2023 , 1 , 2 , 0 , 0 , 0 , 0 , time .Local )}},
162
- {name : "compare for not equal times" , l : "time1" , r : "time2" , op : "!=" , want : true , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : time .Date (2002 , 11 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
163
- {name : "compare for equal times using not equal" , l : "time1" , r : "time2" , op : "!=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 11 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2002 , 11 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
164
- {name : "compare less than times" , l : "time1" , r : "time2" , op : "<" , want : true , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : time .Date (2023 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
165
- {name : "compare not less than times" , l : "time1" , r : "time2" , op : "<" , want : false , item : map [string ]time.Time {"time1" : time .Date (2023 , 6 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2023 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
166
- {name : "compare less than equal to times" , l : "time1" , r : "time2" , op : "<=" , want : true , item : map [string ]time.Time {"time1" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
167
- {name : "compare not less than equal to times" , l : "time1" , r : "time2" , op : "<=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (1999 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
168
- {name : "compare not greater than equal to w/ times" , l : "time1" , r : "time2" , op : ">=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
169
- {name : "compare greater than equal to w/ times" , l : "time1" , r : "time2" , op : ">=" , want : true , item : map [string ]time.Time {"time1" : time .Date (2022 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
170
- {name : "compare greater than w/ times" , l : "time1" , r : "time2" , op : ">" , want : true , item : map [string ]time.Time {"time1" : time .Date (2022 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
171
- {name : "compare not greater than w/ times" , l : "time1" , r : "time2" , op : ">" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 3 , 2 , 01 , 01 , 01 , 01 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 01 , 01 , 01 , 01 , time .Local )}},
162
+ {name : "compare for not equal times" , l : "time1" , r : "time2" , op : "!=" , want : true , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : time .Date (2002 , 11 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
163
+ {name : "compare for equal times using not equal" , l : "time1" , r : "time2" , op : "!=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 11 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2002 , 11 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
164
+ {name : "compare less than times" , l : "time1" , r : "time2" , op : "<" , want : true , item : map [string ]time.Time {"time1" : JanFirst2023 , "time2" : time .Date (2023 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
165
+ {name : "compare not less than times" , l : "time1" , r : "time2" , op : "<" , want : false , item : map [string ]time.Time {"time1" : time .Date (2023 , 6 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2023 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
166
+ {name : "compare less than equal to times" , l : "time1" , r : "time2" , op : "<=" , want : true , item : map [string ]time.Time {"time1" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
167
+ {name : "compare not less than equal to times" , l : "time1" , r : "time2" , op : "<=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (1999 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
168
+ {name : "compare not greater than equal to w/ times" , l : "time1" , r : "time2" , op : ">=" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
169
+ {name : "compare greater than equal to w/ times" , l : "time1" , r : "time2" , op : ">=" , want : true , item : map [string ]time.Time {"time1" : time .Date (2022 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
170
+ {name : "compare greater than w/ times" , l : "time1" , r : "time2" , op : ">" , want : true , item : map [string ]time.Time {"time1" : time .Date (2022 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
171
+ {name : "compare not greater than w/ times" , l : "time1" , r : "time2" , op : ">" , want : false , item : map [string ]time.Time {"time1" : time .Date (2002 , 3 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local ), "time2" : time .Date (2003 , 5 , 2 , 0o1 , 0o1 , 0o1 , 0o1 , time .Local )}},
172
172
}
173
173
for _ , tt := range tests {
174
174
t .Run (tt .name , func (t * testing.T ) {
@@ -220,6 +220,7 @@ func True() (ExprFunc[any], error) {
220
220
return true , nil
221
221
}, nil
222
222
}
223
+
223
224
func False () (ExprFunc [any ], error ) {
224
225
return func (_ context.Context , _ any ) (any , error ) {
225
226
return false , nil
@@ -243,7 +244,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
243
244
want bool
244
245
expr * booleanExpression
245
246
}{
246
- {"a" , false ,
247
+ {
248
+ "a" , false ,
247
249
& booleanExpression {
248
250
Left : & term {
249
251
Left : & booleanValue {
@@ -264,7 +266,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
264
266
},
265
267
},
266
268
},
267
- {"b" , true ,
269
+ {
270
+ "b" , true ,
268
271
& booleanExpression {
269
272
Left : & term {
270
273
Left : & booleanValue {
@@ -285,7 +288,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
285
288
},
286
289
},
287
290
},
288
- {"c" , false ,
291
+ {
292
+ "c" , false ,
289
293
& booleanExpression {
290
294
Left : & term {
291
295
Left : & booleanValue {
@@ -314,7 +318,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
314
318
},
315
319
},
316
320
},
317
- {"d" , true ,
321
+ {
322
+ "d" , true ,
318
323
& booleanExpression {
319
324
Left : & term {
320
325
Left : & booleanValue {
@@ -337,7 +342,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
337
342
},
338
343
},
339
344
},
340
- {"e" , true ,
345
+ {
346
+ "e" , true ,
341
347
& booleanExpression {
342
348
Left : & term {
343
349
Left : & booleanValue {
@@ -360,7 +366,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
360
366
},
361
367
},
362
368
},
363
- {"f" , false ,
369
+ {
370
+ "f" , false ,
364
371
& booleanExpression {
365
372
Left : & term {
366
373
Left : & booleanValue {
@@ -383,7 +390,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
383
390
},
384
391
},
385
392
},
386
- {"g" , true ,
393
+ {
394
+ "g" , true ,
387
395
& booleanExpression {
388
396
Left : & term {
389
397
Left : & booleanValue {
@@ -416,7 +424,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
416
424
},
417
425
},
418
426
},
419
- {"h" , true ,
427
+ {
428
+ "h" , true ,
420
429
& booleanExpression {
421
430
Left : & term {
422
431
Left : & booleanValue {
@@ -455,7 +464,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
455
464
},
456
465
},
457
466
},
458
- {"i" , true ,
467
+ {
468
+ "i" , true ,
459
469
& booleanExpression {
460
470
Left : & term {
461
471
Left : & booleanValue {
@@ -467,7 +477,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
467
477
},
468
478
},
469
479
},
470
- {"j" , false ,
480
+ {
481
+ "j" , false ,
471
482
& booleanExpression {
472
483
Left : & term {
473
484
Left : & booleanValue {
@@ -479,7 +490,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
479
490
},
480
491
},
481
492
},
482
- {"k" , true ,
493
+ {
494
+ "k" , true ,
483
495
& booleanExpression {
484
496
Left : & term {
485
497
Left : & booleanValue {
@@ -497,7 +509,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
497
509
},
498
510
},
499
511
},
500
- {"l" , false ,
512
+ {
513
+ "l" , false ,
501
514
& booleanExpression {
502
515
Left : & term {
503
516
Left : & booleanValue {
@@ -537,7 +550,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
537
550
},
538
551
},
539
552
},
540
- {"m" , false ,
553
+ {
554
+ "m" , false ,
541
555
& booleanExpression {
542
556
Left : & term {
543
557
Left : & booleanValue {
@@ -573,7 +587,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
573
587
},
574
588
},
575
589
},
576
- {"n" , true ,
590
+ {
591
+ "n" , true ,
577
592
& booleanExpression {
578
593
Left : & term {
579
594
Left : & booleanValue {
@@ -586,7 +601,8 @@ func Test_newBooleanExpressionEvaluator(t *testing.T) {
586
601
},
587
602
},
588
603
},
589
- {"o" , false ,
604
+ {
605
+ "o" , false ,
590
606
& booleanExpression {
591
607
Left : & term {
592
608
Left : & booleanValue {
0 commit comments