- 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>
100 lines
2.0 KiB
Go
100 lines
2.0 KiB
Go
package hbrtl
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestHbBitAnd(t *testing.T) {
|
|
_, th := setupVM()
|
|
th.PushLong(0xFF)
|
|
th.PushLong(0x0F)
|
|
th.PendingParams2(2)
|
|
HbBitAnd(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0x0F {
|
|
t.Errorf("HB_BITAND(0xFF, 0x0F) = 0x%X, want 0x0F", r)
|
|
}
|
|
}
|
|
|
|
func TestHbBitOr(t *testing.T) {
|
|
_, th := setupVM()
|
|
th.PushLong(0xF0)
|
|
th.PushLong(0x0F)
|
|
th.PendingParams2(2)
|
|
HbBitOr(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0xFF {
|
|
t.Errorf("HB_BITOR(0xF0, 0x0F) = 0x%X, want 0xFF", r)
|
|
}
|
|
}
|
|
|
|
func TestHbBitXor(t *testing.T) {
|
|
_, th := setupVM()
|
|
th.PushLong(0xFF)
|
|
th.PushLong(0x0F)
|
|
th.PendingParams2(2)
|
|
HbBitXor(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0xF0 {
|
|
t.Errorf("HB_BITXOR(0xFF, 0x0F) = 0x%X, want 0xF0", r)
|
|
}
|
|
}
|
|
|
|
func TestHbBitNot(t *testing.T) {
|
|
_, th := setupVM()
|
|
th.PushLong(0)
|
|
th.PendingParams2(1)
|
|
HbBitNot(th)
|
|
if r := th.GetRetValue().AsLong(); r != -1 {
|
|
t.Errorf("HB_BITNOT(0) = %d, want -1", r)
|
|
}
|
|
}
|
|
|
|
func TestHbBitShift(t *testing.T) {
|
|
_, th := setupVM()
|
|
// Left shift
|
|
th.PushLong(1)
|
|
th.PushLong(4)
|
|
th.PendingParams2(2)
|
|
HbBitShift(th)
|
|
if r := th.GetRetValue().AsLong(); r != 16 {
|
|
t.Errorf("HB_BITSHIFT(1, 4) = %d, want 16", r)
|
|
}
|
|
|
|
// Right shift
|
|
th.PushLong(16)
|
|
th.PushLong(-2)
|
|
th.PendingParams2(2)
|
|
HbBitShift(th)
|
|
if r := th.GetRetValue().AsLong(); r != 4 {
|
|
t.Errorf("HB_BITSHIFT(16, -2) = %d, want 4", r)
|
|
}
|
|
}
|
|
|
|
func TestHbBitTestSetReset(t *testing.T) {
|
|
_, th := setupVM()
|
|
// BITTEST(8, 3) → true (bit 3 of 8=0b1000)
|
|
th.PushLong(8)
|
|
th.PushLong(3)
|
|
th.PendingParams2(2)
|
|
HbBitTest(th)
|
|
if r := th.GetRetValue().AsBool(); !r {
|
|
t.Error("HB_BITTEST(8, 3) = false, want true")
|
|
}
|
|
|
|
// BITSET(0, 5) → 32
|
|
th.PushLong(0)
|
|
th.PushLong(5)
|
|
th.PendingParams2(2)
|
|
HbBitSet(th)
|
|
if r := th.GetRetValue().AsLong(); r != 32 {
|
|
t.Errorf("HB_BITSET(0, 5) = %d, want 32", r)
|
|
}
|
|
|
|
// BITRESET(0xFF, 0) → 0xFE
|
|
th.PushLong(0xFF)
|
|
th.PushLong(0)
|
|
th.PendingParams2(2)
|
|
HbBitReset(th)
|
|
if r := th.GetRetValue().AsLong(); r != 0xFE {
|
|
t.Errorf("HB_BITRESET(0xFF, 0) = 0x%X, want 0xFE", r)
|
|
}
|
|
}
|