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

Function TestContextLoadModuleAwaitSetTimeoutResolution

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

Source from the content-addressed store, hash-verified

735}
736
737func TestContextLoadModuleAwaitSetTimeoutResolution(t *testing.T) {
738 rt := NewRuntime(WithModuleImport(true), WithExecuteTimeout(2))
739 defer rt.Close()
740
741 ctx := rt.NewContext()
742 require.NotNil(t, ctx)
743 defer ctx.Close()
744
745 start := time.Now()
746 result := ctx.LoadModule(`
747 export default 123;
748 await new Promise((resolve) => {
749 setTimeout(() => resolve(true), 20);
750 });
751 `, "issue_471_timer_resolution")
752 defer result.Free()
753
754 elapsed := time.Since(start)
755 require.False(t, result.IsException())
756 require.Less(t, elapsed, 2*time.Second)
757}
758
759func TestContextFunctions(t *testing.T) {
760 useStableOwnerHooksForLegacySubtests(t)

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
LoadModuleMethod · 0.95
NewRuntimeFunction · 0.85
WithModuleImportFunction · 0.85
WithExecuteTimeoutFunction · 0.85
IsExceptionMethod · 0.80
FreeMethod · 0.45

Tested by

no test coverage detected