(t *testing.T)
| 1691 | } |
| 1692 | |
| 1693 | func 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 |
| 1729 | func TestBridgeCreateClassInstanceEdgeCases(t *testing.T) { |
nothing calls this directly
no test coverage detected