mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
bf3ac66150
* Implements #3768. This is a sweeping breaking change that requires many (trivial) edits to Zig source code. Array values no longer coerced to slices; however one may use `&` to obtain a reference to an array value, which may then be coerced to a slice. * Adds `IrInstruction::dump`, for debugging purposes. It's useful to call to inspect the instruction when debugging Zig IR. * Fixes bugs with result location semantics. See the new behavior test cases, and compile error test cases. * Fixes bugs with `@typeInfo` not properly resolving const values. * Behavior tests are passing but std lib tests are not yet. There is more work to do before merging this branch.
23 lines
778 B
Zig
23 lines
778 B
Zig
const std = @import("../std.zig");
|
|
const testing = std.testing;
|
|
const mem = std.mem;
|
|
const fmt = std.fmt;
|
|
|
|
// Hash using the specified hasher `H` asserting `expected == H(input)`.
|
|
pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, input: []const u8) void {
|
|
var h: [expected.len / 2]u8 = undefined;
|
|
Hasher.hash(input, h[0..]);
|
|
|
|
assertEqual(expected, &h);
|
|
}
|
|
|
|
// Assert `expected` == `input` where `input` is a bytestring.
|
|
pub fn assertEqual(comptime expected: []const u8, input: []const u8) void {
|
|
var expected_bytes: [expected.len / 2]u8 = undefined;
|
|
for (expected_bytes) |*r, i| {
|
|
r.* = fmt.parseInt(u8, expected[2 * i .. 2 * i + 2], 16) catch unreachable;
|
|
}
|
|
|
|
testing.expectEqualSlices(u8, &expected_bytes, input);
|
|
}
|