MCPcopy Create free account
hub / github.com/buke/quickjs-go / TestContextExceptionPrimitiveFallback

Function TestContextExceptionPrimitiveFallback

context_test.go:157–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestContextExceptionPrimitiveFallback(t *testing.T) {
158 useStableOwnerHooksForLegacySubtests(t)
159
160 rt := NewRuntime()
161 defer rt.Close()
162 ctx := rt.NewContext()
163 defer ctx.Close()
164
165 result := ctx.Eval(`throw 42`)
166 defer result.Free()
167 require.True(t, result.IsException())
168 require.True(t, ctx.HasException())
169 require.EqualError(t, ctx.Exception(), "javascript exception")
170 require.False(t, ctx.HasException())
171 require.Nil(t, ctx.Exception())
172}
173
174func TestContextInternalStateHelpers(t *testing.T) {
175 var nilCtx *Context

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
EvalMethod · 0.95
HasExceptionMethod · 0.95
ExceptionMethod · 0.95
NewRuntimeFunction · 0.85
IsExceptionMethod · 0.80
FreeMethod · 0.45

Tested by

no test coverage detected