Hey, I was trying to learn zig threads in ziglearn.org
I tried the code that was provided:
const std = @import("std");
pub fn main() !void {}
fn ticker(step: u8) void {
while (true) {
std.time.sleep(1 * std.time.ns_per_s);
tick += @as(isize, step);
}
}
var tick: isize = 0;
test "threading" {
var thread = try std.Thread.spawn(.{}, ticker, .{@as(u8, 1)});
_ = thread;
try expect(tick == 0);
std.time.sleep(3 * std.time.ns_per_s / 2);
try expect(tick == 1);
}
And I got the following result in the terminal:
main.zig:17:9: error: use of undeclared identifier 'expect'
try expect(tick == 0);
Can anyone help me understand why its happening?