- 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>
112 lines
2.0 KiB
Go
112 lines
2.0 KiB
Go
package hbrtl
|
|
|
|
import (
|
|
"five/hbrt"
|
|
"testing"
|
|
)
|
|
|
|
func TestLastKey(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
SetLastKey(27) // ESC
|
|
th.PendingParams2(0)
|
|
LastKey(th)
|
|
if r := th.GetRetValue().AsLong(); r != 27 {
|
|
t.Errorf("LASTKEY() = %d, want 27", r)
|
|
}
|
|
}
|
|
|
|
func TestKeyboardBuffer(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
// Stuff keys via KEYBOARD
|
|
th.PushString("ABC")
|
|
th.PendingParams2(1)
|
|
Keyboard(th)
|
|
|
|
// NEXTKEY should return 'A' without consuming
|
|
th.PendingParams2(0)
|
|
NextKey(th)
|
|
if r := th.GetRetValue().AsLong(); r != 65 {
|
|
t.Errorf("NEXTKEY() = %d, want 65 ('A')", r)
|
|
}
|
|
|
|
// PopKeyBuffer should consume
|
|
k := PopKeyBuffer()
|
|
if k != 65 {
|
|
t.Errorf("PopKeyBuffer() = %d, want 65", k)
|
|
}
|
|
k = PopKeyBuffer()
|
|
if k != 66 {
|
|
t.Errorf("PopKeyBuffer() = %d, want 66 ('B')", k)
|
|
}
|
|
k = PopKeyBuffer()
|
|
if k != 67 {
|
|
t.Errorf("PopKeyBuffer() = %d, want 67 ('C')", k)
|
|
}
|
|
k = PopKeyBuffer()
|
|
if k != -1 {
|
|
t.Errorf("PopKeyBuffer() = %d, want -1 (empty)", k)
|
|
}
|
|
}
|
|
|
|
func TestHbKeyPut(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
// Clear buffer first
|
|
th.PushString("")
|
|
th.PendingParams2(1)
|
|
Keyboard(th)
|
|
|
|
// Put single key
|
|
th.PushInt(13) // Enter
|
|
th.PendingParams2(1)
|
|
HbKeyPut(th)
|
|
|
|
k := PopKeyBuffer()
|
|
if k != 13 {
|
|
t.Errorf("HB_KEYPUT(13) → PopKeyBuffer = %d, want 13", k)
|
|
}
|
|
}
|
|
|
|
func TestSetKey(t *testing.T) {
|
|
_, th := setupVM()
|
|
|
|
// Set a key action
|
|
block := hbrt.MakeBlock(func(t *hbrt.Thread) {
|
|
t.Frame(0, 0)
|
|
defer t.EndProc()
|
|
t.RetNil()
|
|
}, 0)
|
|
|
|
th.PushInt(28) // F1
|
|
th.PushValue(block)
|
|
th.PendingParams2(2)
|
|
SetKeyFunc(th)
|
|
// Old action should be NIL (first time)
|
|
if !th.GetRetValue().IsNil() {
|
|
t.Error("SETKEY first call should return NIL")
|
|
}
|
|
|
|
// Query key action
|
|
th.PushInt(28)
|
|
th.PendingParams2(1)
|
|
SetKeyFunc(th)
|
|
if th.GetRetValue().IsNil() {
|
|
t.Error("SETKEY should return previous block")
|
|
}
|
|
|
|
// Clear key action
|
|
th.PushInt(28)
|
|
th.PushNil()
|
|
th.PendingParams2(2)
|
|
SetKeyFunc(th)
|
|
|
|
th.PushInt(28)
|
|
th.PendingParams2(1)
|
|
SetKeyFunc(th)
|
|
if !th.GetRetValue().IsNil() {
|
|
t.Error("SETKEY after clear should return NIL")
|
|
}
|
|
}
|