4 ms·
Re 9, would it be possible to change the signature of expectEqual from pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) !void to pub
by rstarast 4y ago
Re 9, would it be possible to change the signature of expectEqual from
pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) !void
to
pub fn expectEqual(expected: @TypeOf(actual), actual: anytype) !void
What would the downsides be?
- ptato 4y agoIt isn't possible, compiler will complain about "actual" being an undeclared identifier. The function arguments are declared in order.
- hiccuphippo 4y agoThe compiler already allows using functions defined later in the same file. This is a solvable problem.
- latch 4y agoNo, it won't work. It'll say "actual" is undeclared. https://github.com/ziglang/zig/issues/4437 https://github.com/ziglang/zig/issues/4437 is tracking the issue. I think std.testing is going to see some major changes, so it's possible this gets fixed. But going from the responses in that issue, I think that fix might be more of a side effect, since there doesn't seem to be too much sympathy for the issue as-is.
- nyanpasu64 4y agoWhy not place actual as the first argument and expected as the second? This matches the way I hand-write asserts like `assert(x == 5)`.