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

Function TestBridgeClassConstructorHandleStoreUnavailable

bridge_test.go:438–464  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

436}
437
438func TestBridgeClassConstructorHandleStoreUnavailable(t *testing.T) {
439 rt := NewRuntime()
440 defer rt.Close()
441 ctx := rt.NewContext()
442 defer ctx.Close()
443
444 backupStore := ctx.handleStore
445
446 constructor, _ := NewClassBuilder("HandleStoreUnavailableClass").
447 Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) {
448 ctx.handleStore = nil
449 return map[string]int{"x": 1}, nil
450 }).
451 Build(ctx)
452 require.False(t, constructor.IsException())
453
454 ctx.Globals().Set("HandleStoreUnavailableClass", constructor)
455
456 result := ctx.Eval(`new HandleStoreUnavailableClass()`)
457 ctx.handleStore = backupStore
458
459 defer result.Free()
460 require.True(t, result.IsException())
461 err := ctx.Exception()
462 require.Error(t, err)
463 require.Contains(t, err.Error(), "Handle store not available")
464}
465
466func TestBridgeClassConstructorRuntimeUnavailable(t *testing.T) {
467 rt := NewRuntime()

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
GlobalsMethod · 0.95
EvalMethod · 0.95
ExceptionMethod · 0.95
NewRuntimeFunction · 0.85
NewClassBuilderFunction · 0.85
ConstructorMethod · 0.80
IsExceptionMethod · 0.80
SetMethod · 0.80
BuildMethod · 0.45

Tested by

no test coverage detected