(t *testing.T)
| 1663 | } |
| 1664 | |
| 1665 | func TestBridgeClassFinalizerNoGlobalContextScan(t *testing.T) { |
| 1666 | rt := NewRuntime() |
| 1667 | defer rt.Close() |
| 1668 | ctx := rt.NewContext() |
| 1669 | defer ctx.Close() |
| 1670 | |
| 1671 | var finalized atomic.Bool |
| 1672 | constructor, _ := NewClassBuilder("NoScanClass"). |
| 1673 | Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) { |
| 1674 | return &bridgeFinalizerProbe{mark: &finalized}, nil |
| 1675 | }). |
| 1676 | Build(ctx) |
| 1677 | require.False(t, constructor.IsException()) |
| 1678 | ctx.Globals().Set("NoScanClass", constructor) |
| 1679 | |
| 1680 | instance := ctx.Eval(`new NoScanClass()`) |
| 1681 | defer instance.Free() |
| 1682 | require.False(t, instance.IsException()) |
| 1683 | |
| 1684 | ctxRef := ctx.ref |
| 1685 | unregisterContext(ctxRef) |
| 1686 | contextMapping.Store(ctxRef, "corrupted") |
| 1687 | defer registerContext(ctxRef, ctx) |
| 1688 | |
| 1689 | goClassFinalizerProxy(rt.ref, instance.ref) |
| 1690 | require.True(t, finalized.Load()) |
| 1691 | } |
| 1692 | |
| 1693 | func TestBridgeClassFinalizerOwnerContextUnavailable(t *testing.T) { |
| 1694 | rt := NewRuntime() |
nothing calls this directly
no test coverage detected