summaryrefslogtreecommitdiff
path: root/src/test/values.zig
diff options
context:
space:
mode:
authorTaylan Kammer <taylan.kammer@gmail.com>2025-04-05 17:11:29 +0200
committerTaylan Kammer <taylan.kammer@gmail.com>2025-04-05 17:11:29 +0200
commit70089dacfa6bab5a1e1d0d5aa257e2d671493beb (patch)
tree913b19c94792e2d41fdc800d728ad0bdabf0fada /src/test/values.zig
parentcf934006c650d3d008a4408bedbd95597f906e43 (diff)
uhhhh buncha changes
Diffstat (limited to 'src/test/values.zig')
-rw-r--r--src/test/values.zig49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/test/values.zig b/src/test/values.zig
index 7339f22..4a62afa 100644
--- a/src/test/values.zig
+++ b/src/test/values.zig
@@ -8,9 +8,8 @@ pub const io = @import("../zisp/io.zig");
pub const lib = @import("../zisp/lib.zig");
pub const value = @import("../zisp/value.zig");
-pub const Hval = gc.Hval;
-
-pub const ShortString = value.ShortString;
+pub const Zptr = value.Zptr;
+pub const PtrTag = value.PtrTag;
pub const Value = value.Value;
test "double" {
@@ -46,13 +45,11 @@ test "fixnum" {
test "ptr" {
const ptr = value.ptr;
- const val: *Hval = @ptrFromInt(256);
- const tag = ptr.Tag.pair;
+ const val: Zptr = @ptrFromInt(256);
+ const tag = PtrTag.pair;
const p = ptr.pack(val, tag);
try testing.expect(ptr.check(p));
- try testing.expect(ptr.checkZispTag(p, tag));
- try testing.expect(ptr.checkStrong(p));
const pv, const pt = ptr.unpack(p);
try testing.expectEqual(val, pv);
@@ -60,10 +57,9 @@ test "ptr" {
var w = ptr.makeWeak(p);
try testing.expect(ptr.check(w));
- try testing.expect(ptr.checkZispTag(w, tag));
try testing.expect(ptr.checkWeak(w));
- try testing.expectEqual(true, value.boole.unpack(ptr.predWeak(w)));
- try testing.expectEqual(false, value.boole.unpack(ptr.predWeakNull(w)));
+ try testing.expect(value.t.eq(ptr.predWeak(w)));
+ try testing.expect(value.f.eq(ptr.predWeakNull(w)));
const wv, const wt = ptr.unpack(w);
try testing.expectEqual(val, wv);
@@ -77,24 +73,9 @@ test "ptr" {
try testing.expect(ptr.check(w));
try testing.expect(ptr.checkWeak(w));
try testing.expect(ptr.isWeakNull(w));
- try testing.expectEqual(true, value.boole.unpack(ptr.predWeak(w)));
- try testing.expectEqual(true, value.boole.unpack(ptr.predWeakNull(w)));
- try testing.expectEqual(false, value.boole.unpack(ptr.getWeak(w)));
-}
-
-test "fptr" {
- const ptr = value.ptr;
-
- const int1: u50 = 0;
- const int2: u50 = std.math.maxInt(u50);
-
- const f1 = ptr.packForeign(int1);
- try testing.expect(ptr.checkForeign(f1));
- try testing.expectEqual(int1, ptr.unpackForeign(f1));
-
- const f2 = ptr.packForeign(int2);
- try testing.expect(ptr.checkForeign(f2));
- try testing.expectEqual(int2, ptr.unpackForeign(f2));
+ try testing.expect(value.t.eq(ptr.predWeak(w)));
+ try testing.expect(value.t.eq(ptr.predWeakNull(w)));
+ try testing.expect(value.f.eq(ptr.getWeak(w)));
}
test "rune" {
@@ -107,7 +88,7 @@ test "rune" {
const SstrImpl = struct { SstrPack, SstrUnpack };
const SstrPack = *const fn ([]const u8) Value;
-const SstrUnpack = *const fn (Value) ShortString;
+const SstrUnpack = *const fn (Value) value.ShortString;
test "sstr" {
const impls = [_]SstrImpl{
@@ -205,13 +186,13 @@ test "misc" {
const f = value.boole.pack(false);
try testing.expect(value.f.eq(f));
try testing.expect(value.boole.check(f));
- try testing.expectEqual(false, value.boole.unpack(f));
+ try testing.expect(!value.boole.unpack(f));
try testing.expect(value.boole.unpack(value.boole.pred(f)));
const t = value.boole.pack(true);
try testing.expect(value.t.eq(t));
try testing.expect(value.boole.check(t));
- try testing.expectEqual(true, value.boole.unpack(t));
+ try testing.expect(value.boole.unpack(t));
try testing.expect(value.boole.unpack(value.boole.pred(t)));
const nil = value.nil;
@@ -229,7 +210,7 @@ test "pair" {
const v4 = value.fixnum.pack(4);
const p = value.pair.cons(v1, v2);
- try testing.expect(value.pair.check(p));
+ try testing.expect(value.pair.check(p) != null);
try testing.expect(value.boole.unpack(value.pair.pred(p)));
const car = value.pair.car(p);
@@ -237,8 +218,8 @@ test "pair" {
try testing.expectEqual(1, value.fixnum.unpack(car));
try testing.expectEqual(2, value.fixnum.unpack(cdr));
- value.pair.setcar(p, v3);
- value.pair.setcdr(p, v4);
+ value.pair.setCar(p, v3);
+ value.pair.setCdr(p, v4);
const car2 = value.pair.car(p);
const cdr2 = value.pair.cdr(p);