package hbrtl import ( "five/hbrt" "testing" ) func TestHbIsArray(t *testing.T) { _, th := setupVM() th.PushValue(hbrt.MakeArray(3)) th.PendingParams2(1) HbIsArray(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISARRAY({}) = false, want true") } th.PushString("not array") th.PendingParams2(1) HbIsArray(th) if th.GetRetValue().AsBool() { t.Error("HB_ISARRAY('str') = true, want false") } } func TestHbIsString(t *testing.T) { _, th := setupVM() th.PushString("hello") th.PendingParams2(1) HbIsChar(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISCHAR('hello') = false") } th.PushInt(42) th.PendingParams2(1) HbIsChar(th) if th.GetRetValue().AsBool() { t.Error("HB_ISCHAR(42) = true") } } func TestHbIsNumeric(t *testing.T) { _, th := setupVM() th.PushInt(42) th.PendingParams2(1) HbIsNumeric(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISNUMERIC(42) = false") } th.PushDouble(3.14, 5, 2) th.PendingParams2(1) HbIsNumeric(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISNUMERIC(3.14) = false") } th.PushString("nope") th.PendingParams2(1) HbIsNumeric(th) if th.GetRetValue().AsBool() { t.Error("HB_ISNUMERIC('nope') = true") } } func TestHbIsLogical(t *testing.T) { _, th := setupVM() th.PushBool(true) th.PendingParams2(1) HbIsLogical(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISLOGICAL(.T.) = false") } } func TestHbIsNil(t *testing.T) { _, th := setupVM() th.PushNil() th.PendingParams2(1) HbIsNil(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISNIL(NIL) = false") } th.PushInt(0) th.PendingParams2(1) HbIsNil(th) if th.GetRetValue().AsBool() { t.Error("HB_ISNIL(0) = true") } } func TestHbIsHash(t *testing.T) { _, th := setupVM() th.PushValue(hbrt.MakeHash()) th.PendingParams2(1) HbIsHash(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISHASH({=>}) = false") } } func TestHbIsBlock(t *testing.T) { _, th := setupVM() blk := hbrt.MakeBlock(func(t *hbrt.Thread) {}, 0) th.PushValue(blk) th.PendingParams2(1) HbIsBlock(th) if !th.GetRetValue().AsBool() { t.Error("HB_ISBLOCK(block) = false") } }