MCPcopy Create free account
hub / github.com/buke/quickjs-go / TestReflectionWithIgnoredMethods

Function TestReflectionWithIgnoredMethods

class_reflect_test.go:400–432  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

398}
399
400func TestReflectionWithIgnoredMethods(t *testing.T) {
401 rt := NewRuntime()
402 defer rt.Close()
403 ctx := rt.NewContext()
404 defer ctx.Close()
405
406 // Test ignored methods
407 builder, err := ctx.BindClassBuilder(&FilteredMethods{}, WithIgnoredMethods("GetInfo", "ProcessData"))
408 require.NoError(t, err)
409
410 constructor, _ := builder.Build(ctx)
411 require.False(t, constructor.IsException())
412
413 ctx.Globals().Set("Filtered", constructor)
414
415 result := ctx.Eval(`
416 let obj = new Filtered();
417 [
418 typeof obj.GetData, // Should exist
419 typeof obj.GetInfo, // Should be undefined (ignored)
420 typeof obj.SetData, // Should exist
421 typeof obj.ProcessData // Should be undefined (ignored)
422 ];
423 `)
424 defer result.Free()
425
426 require.False(t, result.IsException())
427
428 require.Equal(t, "function", result.GetIdx(0).ToString()) // Changed: String() → ToString()
429 require.Equal(t, "undefined", result.GetIdx(1).ToString()) // Changed: String() → ToString()
430 require.Equal(t, "function", result.GetIdx(2).ToString()) // Changed: String() → ToString()
431 require.Equal(t, "undefined", result.GetIdx(3).ToString()) // Changed: String() → ToString()
432}
433
434// =============================================================================
435// ERROR HANDLING TESTS

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
NewContextMethod · 0.95
CloseMethod · 0.95
BindClassBuilderMethod · 0.95
GlobalsMethod · 0.95
EvalMethod · 0.95
NewRuntimeFunction · 0.85
WithIgnoredMethodsFunction · 0.85
IsExceptionMethod · 0.80
SetMethod · 0.80
EqualMethod · 0.80
GetIdxMethod · 0.80

Tested by

no test coverage detected