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

Function TestCallInterruptHandler_DirectCall

runtime_test.go:408–422  ·  view source on GitHub ↗

TestCallInterruptHandler_DirectCall directly tests callInterruptHandler method for 100% coverage

(t *testing.T)

Source from the content-addressed store, hash-verified

406
407// TestCallInterruptHandler_DirectCall directly tests callInterruptHandler method for 100% coverage
408func TestCallInterruptHandler_DirectCall(t *testing.T) {
409 rt := NewRuntime()
410 defer rt.Close()
411
412 // Test return 0 branch when no handler is set
413 rt.ClearInterruptHandler()
414 require.Equal(t, 0, rt.callInterruptHandler())
415
416 // Test handler invocation with different return values
417 testCases := []int{0, 1, 42, -1}
418 for _, expected := range testCases {
419 rt.SetInterruptHandler(func() int { return expected })
420 require.Equal(t, expected, rt.callInterruptHandler())
421 }
422}
423
424// TestRuntimeTimeoutVsInterruptHandler tests precedence between timeout and interrupt handler
425func TestRuntimeTimeoutVsInterruptHandler(t *testing.T) {

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
ClearInterruptHandlerMethod · 0.95
callInterruptHandlerMethod · 0.95
SetInterruptHandlerMethod · 0.95
NewRuntimeFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected