(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func TestRun_Cast(t *testing.T) { |
| 64 | tests := []struct { |
| 65 | input string |
| 66 | expect reflect.Kind |
| 67 | want any |
| 68 | }{ |
| 69 | { |
| 70 | input: `1`, |
| 71 | expect: reflect.Float64, |
| 72 | want: float64(1), |
| 73 | }, |
| 74 | { |
| 75 | input: `1`, |
| 76 | expect: reflect.Int, |
| 77 | want: int(1), |
| 78 | }, |
| 79 | { |
| 80 | input: `1`, |
| 81 | expect: reflect.Int64, |
| 82 | want: int64(1), |
| 83 | }, |
| 84 | { |
| 85 | input: `true`, |
| 86 | expect: reflect.Bool, |
| 87 | want: true, |
| 88 | }, |
| 89 | { |
| 90 | input: `false`, |
| 91 | expect: reflect.Bool, |
| 92 | want: false, |
| 93 | }, |
| 94 | { |
| 95 | input: `nil`, |
| 96 | expect: reflect.Bool, |
| 97 | want: false, |
| 98 | }, |
| 99 | } |
| 100 | |
| 101 | for _, tt := range tests { |
| 102 | t.Run(fmt.Sprintf("%v %v", tt.expect, tt.input), func(t *testing.T) { |
| 103 | tree, err := parser.Parse(tt.input) |
| 104 | require.NoError(t, err) |
| 105 | |
| 106 | program, err := compiler.Compile(tree, &conf.Config{Expect: tt.expect}) |
| 107 | require.NoError(t, err) |
| 108 | |
| 109 | out, err := vm.Run(program, nil) |
| 110 | require.NoError(t, err) |
| 111 | |
| 112 | require.Equal(t, tt.want, out) |
| 113 | }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | func TestRun_Helpers(t *testing.T) { |
| 118 | values := []any{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…