File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 6
6
* .test
7
7
* .out
8
8
* .html
9
+ custom_tests.json
Original file line number Diff line number Diff line change 4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "os"
7
8
"reflect"
8
9
"testing"
9
10
"time"
@@ -2053,6 +2054,35 @@ func TestMemoryBudget(t *testing.T) {
2053
2054
}
2054
2055
}
2055
2056
2057
+ func TestExpr_custom_tests (t * testing.T ) {
2058
+ f , err := os .Open ("custom_tests.json" )
2059
+ if os .IsNotExist (err ) {
2060
+ t .Skip ("no custom tests" )
2061
+ return
2062
+ }
2063
+
2064
+ require .NoError (t , err , "open file error" )
2065
+ defer f .Close ()
2066
+
2067
+ var tests []string
2068
+ err = json .NewDecoder (f ).Decode (& tests )
2069
+ require .NoError (t , err , "decode json error" )
2070
+
2071
+ for id , tt := range tests {
2072
+ t .Run (fmt .Sprintf ("line %v" , id + 2 ), func (t * testing.T ) {
2073
+ program , err := expr .Compile (tt )
2074
+ require .NoError (t , err )
2075
+
2076
+ out , err := expr .Run (program , nil )
2077
+
2078
+ // Make sure out is used.
2079
+ _ = fmt .Sprintf ("%v" , out )
2080
+
2081
+ assert .Error (t , err )
2082
+ })
2083
+ }
2084
+ }
2085
+
2056
2086
func TestIssue432 (t * testing.T ) {
2057
2087
env := map [string ]any {
2058
2088
"func" : func (
You can’t perform that action at this time.
0 commit comments