(t *testing.T)
| 1877 | } |
| 1878 | |
| 1879 | func TestValueHasInstanceDataFailClosedOnMissingOwnerContext(t *testing.T) { |
| 1880 | rt := NewRuntime() |
| 1881 | defer rt.Close() |
| 1882 | ctx := rt.NewContext() |
| 1883 | defer ctx.Close() |
| 1884 | |
| 1885 | constructor, _ := NewClassBuilder("MissingOwnerCtxClass"). |
| 1886 | Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) { |
| 1887 | return map[string]int{"value": 1}, nil |
| 1888 | }). |
| 1889 | Build(ctx) |
| 1890 | require.False(t, constructor.IsException()) |
| 1891 | ctx.Globals().Set("MissingOwnerCtxClass", constructor) |
| 1892 | |
| 1893 | instance := ctx.Eval(`new MissingOwnerCtxClass()`) |
| 1894 | defer instance.Free() |
| 1895 | require.False(t, instance.IsException()) |
| 1896 | require.True(t, instance.HasInstanceData()) |
| 1897 | |
| 1898 | rt.contextsByID.Delete(ctx.contextID) |
| 1899 | require.False(t, instance.HasInstanceData()) |
| 1900 | _, err := instance.GetGoObject() |
| 1901 | require.Error(t, err) |
| 1902 | require.Contains(t, err.Error(), "instance data not found in handle store") |
| 1903 | |
| 1904 | rt.contextsByID.Store(ctx.contextID, ctx) |
| 1905 | } |
| 1906 | |
| 1907 | // TestValueCallConstructorEdgeCases tests edge cases and error conditions in CallConstructor |
| 1908 | // MODIFIED FOR SCHEME C: Removed all NewInstance tests, enhanced CallConstructor coverage |
nothing calls this directly
no test coverage detected