(enable bool)
| 1536 | } |
| 1537 | |
| 1538 | func forceRuntimeEvalFailureForTest(enable bool) func() { |
| 1539 | oldHook := runtimeEvalFunctionHook |
| 1540 | if enable { |
| 1541 | runtimeEvalFunctionHook = func(ctx *C.JSContext, compiled C.JSValue) C.JSValue { |
| 1542 | C.JS_FreeValue(ctx, compiled) |
| 1543 | msg := C.CString("forced eval failure") |
| 1544 | defer C.free(unsafe.Pointer(msg)) |
| 1545 | return C.ThrowInternalError(ctx, msg) |
| 1546 | } |
| 1547 | } else { |
| 1548 | runtimeEvalFunctionHook = nil |
| 1549 | } |
| 1550 | return func() { |
| 1551 | runtimeEvalFunctionHook = oldHook |
| 1552 | } |
| 1553 | } |