- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline - Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch - RTL: 351 Harbour-compatible functions - RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization - Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec) - HB_FUNC API: Full Harbour C API compatible Go bridge - Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT - Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST - Macro Compiler: Runtime AST parsing and evaluation - Debugger: TUI debugger with source display, breakpoints, stepping - FRB: Native + Pcode dual mode runtime binary - Tests: 13 packages ALL PASS Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
99 lines
1.8 KiB
Go
99 lines
1.8 KiB
Go
package hbrtl
|
|
|
|
import (
|
|
"five/hbrt"
|
|
"testing"
|
|
)
|
|
|
|
func TestErrorBlock(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
// Reset errorBlock for test
|
|
errorBlock = hbrt.MakeNil()
|
|
|
|
// Get default (NIL)
|
|
th.PendingParams2(0)
|
|
ErrorBlock(th)
|
|
if !th.GetRetValue().IsNil() {
|
|
t.Error("Default ERRORBLOCK should be NIL")
|
|
}
|
|
|
|
// Set a block
|
|
block := hbrt.MakeBlock(func(t *hbrt.Thread) {
|
|
t.Frame(0, 0)
|
|
defer t.EndProc()
|
|
t.RetNil()
|
|
}, 0)
|
|
|
|
th.PushValue(block)
|
|
th.PendingParams2(1)
|
|
ErrorBlock(th)
|
|
// Returns old (NIL)
|
|
if !th.GetRetValue().IsNil() {
|
|
t.Error("ERRORBLOCK(bNew) should return old NIL")
|
|
}
|
|
|
|
// Query — should return the block now
|
|
th.PendingParams2(0)
|
|
ErrorBlock(th)
|
|
if th.GetRetValue().IsNil() {
|
|
t.Error("ERRORBLOCK() should return the set block")
|
|
}
|
|
}
|
|
|
|
func TestErrorNew(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
th.PendingParams2(0)
|
|
ErrorNew(th)
|
|
errObj := th.GetRetValue()
|
|
if errObj.IsNil() {
|
|
t.Fatal("ERRORNEW returned NIL")
|
|
}
|
|
if !errObj.IsHash() {
|
|
t.Fatal("ERRORNEW should return a hash")
|
|
}
|
|
h := errObj.AsHash()
|
|
if h == nil || len(h.Keys) != 14 {
|
|
t.Errorf("ERRORNEW hash has %d keys, want 14", len(h.Keys))
|
|
}
|
|
}
|
|
|
|
func TestDosError(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
lastDosErr = 0 // reset
|
|
|
|
// Get
|
|
th.PendingParams2(0)
|
|
DosError(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0 {
|
|
t.Errorf("DOSERROR() = %d, want 0", r)
|
|
}
|
|
|
|
// Set
|
|
th.PushInt(5)
|
|
th.PendingParams2(1)
|
|
DosError(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0 {
|
|
t.Errorf("DOSERROR(5) old = %d, want 0", r)
|
|
}
|
|
|
|
// Get again
|
|
th.PendingParams2(0)
|
|
DosError(th)
|
|
if r := th.GetRetValue().AsLong(); r != 5 {
|
|
t.Errorf("DOSERROR() = %d, want 5", r)
|
|
}
|
|
}
|
|
|
|
func TestFError(t *testing.T) {
|
|
_, th := setupVM()
|
|
SetFError(2)
|
|
th.PendingParams2(0)
|
|
FError(th)
|
|
if r := th.GetRetValue().AsLong(); r != 2 {
|
|
t.Errorf("FERROR() = %d, want 2", r)
|
|
}
|
|
}
|