From cd25a1acae128b660f60a0132ffb981e08442cd4 Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Thu, 4 Jun 2026 19:47:54 +0200 Subject: Fix tests. --- src/test/parse.zig | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/test/parse.zig') diff --git a/src/test/parse.zig b/src/test/parse.zig index 78915cd..53de21d 100644 --- a/src/test/parse.zig +++ b/src/test/parse.zig @@ -42,23 +42,21 @@ test "parse short bare string" { try expect(parse("+0.1").eq(str("+0.1"))); try expect(parse("-0.1").eq(str("-0.1"))); try expect(parse("10.1").eq(str("10.1"))); - try expect(parse("|x()|").eq(str("x()"))); - try expect(parse("|{\\|}|").eq(str("{|}"))); try expect(parse("foobar").eq(str("foobar"))); try expect(parse("!$%*+-").eq(str("!$%*+-"))); - try expect(parse("/<=>?@").eq(str("/<=>?@"))); - try expect(parse("^_~000").eq(str("^_~000"))); + try expect(parse("/<=>?^").eq(str("/<=>?^"))); + try expect(parse("_~0000").eq(str("_~0000"))); } test "parse long bare string" { const str = value.istr.intern; try expect(parse("foobarbaz").eq(str("foobarbaz"))); try expect(parse(".foo.bar.baz").eq(str(".foo.bar.baz"))); + try expect(parse(":foo:bar:baz").eq(str(":foo:bar:baz"))); try expect(parse("+foo.bar.baz").eq(str("+foo.bar.baz"))); try expect(parse("-foo.bar.baz").eq(str("-foo.bar.baz"))); try expect(parse("0foo.bar.baz").eq(str("0foo.bar.baz"))); - try expect(parse("!$%*+-/<=>?@^_~").eq(str("!$%*+-/<=>?@^_~"))); - try expect(parse("|foo\\x20;bar\\x0a;baz|").eq(str("foo bar\nbaz"))); + try expect(parse("!$%*+-/<=>?^_~").eq(str("!$%*+-/<=>?^_~"))); } test "parse" { @@ -66,8 +64,8 @@ test "parse" { try testing.expect(value.sstr.check(val)); - const s = value.sstr.unpack(val); - try testing.expectEqualStrings("foo", s.slice()); + const s = value.sstr.unpack(&val); + try testing.expectEqualStrings("foo", s); } test "parse2" { @@ -77,14 +75,14 @@ test "parse2" { \\ ;; end ); - const r = value.rune.unpack(value.pair.car(val)); - try testing.expectEqualStrings("HASH", r.slice()); + const r = value.rune.unpack(&value.pair.car(val)); + try testing.expectEqualStrings("HASH", r); const s = value.pair.cdr(value.pair.cdr(val)); try testing.expect(value.sstr.check(s)); - const f = value.sstr.unpack(s); - try testing.expectEqualStrings("foo", f.slice()); + const f = value.sstr.unpack(&s); + try testing.expectEqualStrings("foo", f); } test "parse3" { @@ -109,11 +107,11 @@ test "parse3" { test "parse4" { const val = parse("(foo & ;~x bar ;~y)"); - const s = value.sstr.unpack(value.pair.car(val)); - try testing.expectEqualStrings("foo", s.slice()); + const s = value.sstr.unpack(&value.pair.car(val)); + try testing.expectEqualStrings("foo", s); - const f = value.sstr.unpack(value.pair.cdr(val)); - try testing.expectEqualStrings("bar", f.slice()); + const f = value.sstr.unpack(&value.pair.cdr(val)); + try testing.expectEqualStrings("bar", f); } test "print" { @@ -167,7 +165,8 @@ test "print7" { } fn parseBench(path: []const u8, iters: usize) !void { - var timer = try std.time.Timer.start(); + const clock = std.Io.Clock.cpu_thread; + const start = clock.now(io); for (0..iters) |i| { _ = i; const file = try std.Io.Dir.cwd().openFile(io, path, .{}); @@ -180,7 +179,8 @@ fn parseBench(path: []const u8, iters: usize) !void { if (value.eof.eq(v)) break; } } - const ns: f64 = @floatFromInt(timer.lap()); + const stop = clock.now(io); + const ns: f64 = @floatFromInt(start.durationTo(stop).nanoseconds); const secs = ns / 1_000_000_000; std.debug.print( "parse {s} x {}: {d:.3}s\n", -- cgit v1.2.3