MCPcopy
hub / github.com/expr-lang/expr / TestDeref_nil_in_pointer_of_interface

Function TestDeref_nil_in_pointer_of_interface

test/deref/deref_test.go:186–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestDeref_nil_in_pointer_of_interface(t *testing.T) {
187 var a *int32 = nil
188 b := any(a)
189 c := any(&b)
190 t.Run("returned as is", func(t *testing.T) {
191 output, err := expr.Eval(`c`, map[string]any{
192 "c": c,
193 })
194 require.NoError(t, err)
195 require.Equal(t, c, output)
196 require.IsType(t, (*interface{})(nil), output)
197 })
198 t.Run("== nil works", func(t *testing.T) {
199 output, err := expr.Eval(`c == nil`, map[string]any{
200 "c": c,
201 })
202 require.NoError(t, err)
203 require.Equal(t, true, output)
204 })
205}
206
207func TestDeref_commutative(t *testing.T) {
208 a := "ok"

Callers

nothing calls this directly

Calls 5

EvalFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92
IsTypeFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…