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

Function forceRuntimeInitFailureForTest

runtime.go:1467–1481  ·  view source on GitHub ↗
(enable bool)

Source from the content-addressed store, hash-verified

1465}
1466
1467func forceRuntimeInitFailureForTest(enable bool) func() {
1468 oldHook := runtimeInitContextHook
1469 if enable {
1470 runtimeInitContextHook = func(ctx *C.JSContext) C.JSValue {
1471 msg := C.CString("forced init failure")
1472 defer C.free(unsafe.Pointer(msg))
1473 return C.ThrowInternalError(ctx, msg)
1474 }
1475 } else {
1476 runtimeInitContextHook = nil
1477 }
1478 return func() {
1479 runtimeInitContextHook = oldHook
1480 }
1481}
1482
1483func forceRuntimeInitSuccessForTest(enable bool) func() {
1484 oldHook := runtimeInitContextHook

Calls 1

ThrowInternalErrorMethod · 0.80