============================================================================= REFLECTION OPTIONS TESTS =============================================================================
(t *testing.T)
| 333 | // ============================================================================= |
| 334 | |
| 335 | func TestReflectionWithIgnoredFields(t *testing.T) { |
| 336 | rt := NewRuntime() |
| 337 | defer rt.Close() |
| 338 | ctx := rt.NewContext() |
| 339 | defer ctx.Close() |
| 340 | |
| 341 | // Test WithIgnoredFields option |
| 342 | constructor, _ := ctx.BindClass(&ReflectionTestStruct{}, WithIgnoredFields("IgnoredOne", "IgnoredTwo")) |
| 343 | require.False(t, constructor.IsException()) |
| 344 | |
| 345 | ctx.Globals().Set("ReflectionTestStruct", constructor) |
| 346 | |
| 347 | result := ctx.Eval(` |
| 348 | let obj = new ReflectionTestStruct(); |
| 349 | [ |
| 350 | typeof obj.field1, // Should exist |
| 351 | typeof obj.field2, // Should exist |
| 352 | typeof obj.ignoredOne, // Should be undefined (ignored) |
| 353 | typeof obj.ignoredTwo // Should be undefined (ignored) |
| 354 | ]; |
| 355 | `) |
| 356 | defer result.Free() |
| 357 | |
| 358 | require.False(t, result.IsException()) |
| 359 | |
| 360 | require.Equal(t, "string", result.GetIdx(0).ToString()) // Changed: String() → ToString() |
| 361 | require.Equal(t, "string", result.GetIdx(1).ToString()) // Changed: String() → ToString() |
| 362 | require.Equal(t, "undefined", result.GetIdx(2).ToString()) // Changed: String() → ToString() |
| 363 | require.Equal(t, "undefined", result.GetIdx(3).ToString()) // Changed: String() → ToString() |
| 364 | } |
| 365 | |
| 366 | func TestReflectionWithMethodPrefix(t *testing.T) { |
| 367 | rt := NewRuntime() |
nothing calls this directly
no test coverage detected