(t *testing.T)
| 436 | } |
| 437 | |
| 438 | func 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 | |
| 466 | func TestBridgeClassConstructorRuntimeUnavailable(t *testing.T) { |
| 467 | rt := NewRuntime() |
nothing calls this directly
no test coverage detected