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

Function TestBridgeMappingCloseContractStress

bridge_test.go:227–261  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestBridgeMappingCloseContractStress(t *testing.T) {
228 for i := 0; i < 64; i++ {
229 rt := NewRuntime()
230 ctx := rt.NewContext()
231 require.NotNil(t, ctx)
232
233 ctxRef := ctx.ref
234 rtRef := rt.ref
235
236 require.NotNil(t, getContextFromJS(ctxRef))
237 require.NotNil(t, getRuntimeFromJS(rtRef))
238
239 for j := 0; j < 32; j++ {
240 unregisterContext(ctxRef)
241 require.Nil(t, getContextFromJS(ctxRef))
242 registerContext(ctxRef, ctx)
243 require.NotNil(t, getContextFromJS(ctxRef))
244 }
245
246 ctx.Close()
247 rt.Close()
248
249 contextMapping.Store(ctxRef, ctx)
250 runtimeMapping.Store(rtRef, rt)
251
252 require.Nil(t, getContextFromJS(ctxRef))
253 require.Nil(t, getRuntimeFromJS(rtRef))
254 require.NotPanics(t, func() {
255 _ = goInterruptHandler(rtRef)
256 })
257
258 contextMapping.Delete(ctxRef)
259 runtimeMapping.Delete(rtRef)
260 }
261}
262
263func TestBridgeNilCallbackResultsNormalizeToUndefined(t *testing.T) {
264 rt := NewRuntime()

Callers

nothing calls this directly

Calls 11

NewContextMethod · 0.95
CloseMethod · 0.95
CloseMethod · 0.95
NewRuntimeFunction · 0.85
getContextFromJSFunction · 0.85
getRuntimeFromJSFunction · 0.85
unregisterContextFunction · 0.85
registerContextFunction · 0.85
goInterruptHandlerFunction · 0.85
StoreMethod · 0.80
DeleteMethod · 0.45

Tested by

no test coverage detected