MCPcopy Index your code
hub / github.com/yuin/gopher-lua / TestRegistryFixedOverflow

Function TestRegistryFixedOverflow

state_test.go:497–523  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

495}
496
497func TestRegistryFixedOverflow(t *testing.T) {
498 state := NewState()
499 defer state.Close()
500 reg := state.reg
501 expectedPanic := false
502 // should be non auto grow by default
503 errorIfFalse(t, reg.maxSize == 0, "state should default to non-auto growing implementation")
504 // fill the stack and check we get a panic
505 test := LString("test")
506 for i := 0; i < len(reg.array); i++ {
507 reg.Push(test)
508 }
509 defer func() {
510 rcv := recover()
511 if rcv != nil {
512 if expectedPanic {
513 errorIfFalse(t, rcv.(error).Error() != "registry overflow", "expected registry overflow exception, got "+rcv.(error).Error())
514 } else {
515 t.Errorf("did not expect registry overflow")
516 }
517 } else if expectedPanic {
518 t.Errorf("expected registry overflow exception, but didn't get panic")
519 }
520 }()
521 expectedPanic = true
522 reg.Push(test)
523}
524
525func TestRegistryAutoGrow(t *testing.T) {
526 state := NewState(Options{RegistryMaxSize: 300, RegistrySize: 200, RegistryGrowStep: 25})

Callers

nothing calls this directly

Calls 6

errorIfFalseFunction · 0.85
LStringTypeAlias · 0.85
NewStateFunction · 0.70
PushMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…