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

Function TestRuntimeWithModuleImportOptionInstallsDefaultLoader

runtime_test.go:911–929  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

909}
910
911func TestRuntimeWithModuleImportOptionInstallsDefaultLoader(t *testing.T) {
912 rt := NewRuntime(WithModuleImport(true))
913 defer rt.Close()
914
915 ctx := rt.NewContext()
916 require.NotNil(t, ctx)
917 defer ctx.Close()
918
919 result := ctx.Eval(`
920 (async function() {
921 const mod = await import("./test/fib_module.js");
922 return mod.fib(6);
923 })()
924 `, EvalAwait(true))
925 defer result.Free()
926
927 require.False(t, result.IsException())
928 require.EqualValues(t, 8, result.ToInt32())
929}
930
931func TestRuntimeSetModuleImportToggle(t *testing.T) {
932 evalFibImport := func(ctx *Context) *Value {

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
EvalMethod · 0.95
NewRuntimeFunction · 0.85
WithModuleImportFunction · 0.85
EvalAwaitFunction · 0.85
IsExceptionMethod · 0.80
ToInt32Method · 0.80
FreeMethod · 0.45

Tested by

no test coverage detected