Test for class setter proxy errors - unchanged except method calls
(t *testing.T)
| 1458 | |
| 1459 | // Test for class setter proxy errors - unchanged except method calls |
| 1460 | func TestBridgeClassSetterErrors(t *testing.T) { |
| 1461 | // Test class setter proxy error handling |
| 1462 | t.Run("SetterContextNotFound", func(t *testing.T) { |
| 1463 | rt := NewRuntime() |
| 1464 | defer rt.Close() |
| 1465 | ctx := rt.NewContext() |
| 1466 | defer ctx.Close() |
| 1467 | |
| 1468 | // MODIFIED FOR SCHEME C: Create class with new constructor signature |
| 1469 | constructor, _ := NewClassBuilder("TestClass"). |
| 1470 | Constructor(func(ctx *Context, instance *Value, args []*Value) (interface{}, error) { |
| 1471 | return &Point{X: 1, Y: 2}, nil |
| 1472 | }). |
| 1473 | Accessor("testProp", nil, func(ctx *Context, this *Value, value *Value) *Value { |
| 1474 | return ctx.NewUndefined() // Changed: Undefined() → NewUndefined() |
| 1475 | }). |
| 1476 | Build(ctx) |
| 1477 | require.False(t, constructor.IsException()) |
| 1478 | |
| 1479 | ctx.Globals().Set("TestClass", constructor) |
| 1480 | |
| 1481 | // Verify setter works initially |
| 1482 | result := ctx.Eval(` |
| 1483 | let obj = new TestClass(); |
| 1484 | obj.testProp = "test"; |
| 1485 | "setter works"; |
| 1486 | `) |
| 1487 | require.False(t, result.IsException()) |
| 1488 | require.Equal(t, "setter works", result.ToString()) // Changed: String() → ToString() |
| 1489 | result.Free() |
| 1490 | |
| 1491 | // Unregister context from mapping |
| 1492 | unregisterContext(ctx.ref) |
| 1493 | |
| 1494 | // Call setter - triggers goClassSetterProxy with unmapped context |
| 1495 | result2 := ctx.Eval(` |
| 1496 | try { |
| 1497 | let obj = new TestClass(); |
| 1498 | obj.testProp = "test"; |
| 1499 | } catch(e) { |
| 1500 | e.toString(); |
| 1501 | } |
| 1502 | `) |
| 1503 | |
| 1504 | if result2.IsException() { |
| 1505 | err := ctx.Exception() |
| 1506 | require.Contains(t, err.Error(), "Context not found") |
| 1507 | } else { |
| 1508 | defer result2.Free() |
| 1509 | require.Contains(t, result2.ToString(), "Context not found") // Changed: String() → ToString() |
| 1510 | } |
| 1511 | |
| 1512 | // Re-register context for cleanup |
| 1513 | registerContext(ctx.ref, ctx) |
| 1514 | |
| 1515 | t.Log("Successfully triggered goClassSetterProxy Context not found branch") |
| 1516 | }) |
| 1517 |
nothing calls this directly
no test coverage detected