File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -808,6 +808,24 @@ func TestExpr(t *testing.T) {
808
808
}
809
809
}
810
810
811
+ func TestExpr_eval_with_env (t * testing.T ) {
812
+ _ , err := expr .Eval ("true" , expr .Env (map [string ]interface {}{}))
813
+ assert .Error (t , err )
814
+ assert .Contains (t , err .Error (), "misused" )
815
+ }
816
+
817
+ func TestExpr_fetch_from_func (t * testing.T ) {
818
+ _ , err := expr .Eval ("foo.Value" , map [string ]interface {}{
819
+ "foo" : func () {},
820
+ })
821
+ assert .Error (t , err )
822
+ assert .Contains (t , err .Error (), "cannot fetch Value from func()" )
823
+ }
824
+
825
+ //
826
+ // Mock types
827
+ //
828
+
811
829
type mockEnv struct {
812
830
Any interface {}
813
831
Int , One , Two , Three int
@@ -903,9 +921,3 @@ type segment struct {
903
921
Destination string
904
922
Date time.Time
905
923
}
906
-
907
- func TestExpr_eval_with_env (t * testing.T ) {
908
- _ , err := expr .Eval ("true" , expr .Env (map [string ]interface {}{}))
909
- assert .Error (t , err )
910
- assert .Contains (t , err .Error (), "misused" )
911
- }
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ func fetch(from interface{}, i interface{}) interface{} {
46
46
if value .IsValid () && value .CanInterface () {
47
47
return value .Interface ()
48
48
}
49
+
50
+ case reflect .Func :
51
+ panic (fmt .Sprintf ("cannot fetch %v from %T" , i , from ))
49
52
}
50
53
return nil
51
54
}
You can’t perform that action at this time.
0 commit comments