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

Function TestBridgeClassFinalizerOwnerContextUnavailable

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

Source from the content-addressed store, hash-verified

1691}
1692
1693func TestBridgeClassFinalizerOwnerContextUnavailable(t *testing.T) {
1694 rt := NewRuntime()
1695 defer rt.Close()
1696 ctx := rt.NewContext()
1697 defer ctx.Close()
1698
1699 var finalized atomic.Bool
1700 constructor, _ := NewClassBuilder("FinalizerOwnerMissingClass").
1701 Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) {
1702 return &bridgeFinalizerProbe{mark: &finalized}, nil
1703 }).
1704 Build(ctx)
1705 require.False(t, constructor.IsException())
1706 ctx.Globals().Set("FinalizerOwnerMissingClass", constructor)
1707
1708 instance1 := ctx.Eval(`new FinalizerOwnerMissingClass()`)
1709 defer instance1.Free()
1710 require.False(t, instance1.IsException())
1711
1712 instance2 := ctx.Eval(`new FinalizerOwnerMissingClass()`)
1713 defer instance2.Free()
1714 require.False(t, instance2.IsException())
1715
1716 rt.contextsByID.Delete(ctx.contextID)
1717 goClassFinalizerProxy(rt.ref, instance1.ref)
1718 require.False(t, finalized.Load())
1719 rt.contextsByID.Store(ctx.contextID, ctx)
1720
1721 backupStore := ctx.handleStore
1722 ctx.handleStore = nil
1723 goClassFinalizerProxy(rt.ref, instance2.ref)
1724 ctx.handleStore = backupStore
1725 require.False(t, finalized.Load())
1726}
1727
1728// NEW TEST FOR SCHEME C: Test CreateClassInstance C function behavior
1729func TestBridgeCreateClassInstanceEdgeCases(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
GlobalsMethod · 0.95
EvalMethod · 0.95
NewRuntimeFunction · 0.85
NewClassBuilderFunction · 0.85
goClassFinalizerProxyFunction · 0.85
ConstructorMethod · 0.80
IsExceptionMethod · 0.80
SetMethod · 0.80
LoadMethod · 0.80

Tested by

no test coverage detected