MCPcopy Index your code
hub / github.com/expr-lang/expr / TestCompile_exposed_error

Function TestCompile_exposed_error

expr_test.go:1756–1772  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1754}
1755
1756func TestCompile_exposed_error(t *testing.T) {
1757 _, err := expr.Compile(`1 == true`)
1758 require.Error(t, err)
1759
1760 fileError, ok := err.(*file.Error)
1761 require.True(t, ok, "error should be of type *file.Error")
1762 require.Equal(t, "invalid operation: == (mismatched types int and bool) (1:3)\n | 1 == true\n | ..^", fileError.Error())
1763 require.Equal(t, 2, fileError.Column)
1764 require.Equal(t, 1, fileError.Line)
1765
1766 b, err := json.Marshal(err)
1767 require.NoError(t, err)
1768 require.Equal(t,
1769 `{"from":2,"to":4,"line":1,"column":2,"message":"invalid operation: == (mismatched types int and bool)","snippet":"\n | 1 == true\n | ..^","prev":null}`,
1770 string(b),
1771 )
1772}
1773
1774func TestAsBool_exposed_error(t *testing.T) {
1775 _, err := expr.Compile(`42`, expr.AsBool())

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
ErrorFunction · 0.92
TrueFunction · 0.92
EqualFunction · 0.92
NoErrorFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…