(t *testing.T)
| 464 | } |
| 465 | |
| 466 | func TestBridgeClassConstructorRuntimeUnavailable(t *testing.T) { |
| 467 | rt := NewRuntime() |
| 468 | defer rt.Close() |
| 469 | ctx := rt.NewContext() |
| 470 | defer ctx.Close() |
| 471 | |
| 472 | backupRuntime := ctx.runtime |
| 473 | |
| 474 | constructor, _ := NewClassBuilder("RuntimeUnavailableClass"). |
| 475 | Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) { |
| 476 | ctx.runtime = nil |
| 477 | return map[string]int{"x": 1}, nil |
| 478 | }). |
| 479 | Build(ctx) |
| 480 | require.False(t, constructor.IsException()) |
| 481 | |
| 482 | ctx.Globals().Set("RuntimeUnavailableClass", constructor) |
| 483 | |
| 484 | result := ctx.Eval(`new RuntimeUnavailableClass()`) |
| 485 | ctx.runtime = backupRuntime |
| 486 | |
| 487 | defer result.Free() |
| 488 | require.True(t, result.IsException()) |
| 489 | err := ctx.Exception() |
| 490 | require.Error(t, err) |
| 491 | require.Contains(t, err.Error(), "Context runtime not available") |
| 492 | } |
| 493 | |
| 494 | func TestBridgeClassConstructorIdentityRegistrationFailure(t *testing.T) { |
| 495 | rt := NewRuntime() |
nothing calls this directly
no test coverage detected