update usage of std.testing in stage2

This commit is contained in:
Veikka Tuominen 2021-05-05 21:29:16 +03:00
parent 0a38f61d58
commit 42a95197f3
13 changed files with 137 additions and 137 deletions

View File

@ -727,7 +727,7 @@ test "cache file and then recall it" {
_ = try ch.addFile(temp_file, null);
// There should be nothing in the cache
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
digest1 = ch.final();
try ch.writeManifest();
@ -742,13 +742,13 @@ test "cache file and then recall it" {
_ = try ch.addFile(temp_file, null);
// Cache hit! We just "built" the same file
testing.expect(try ch.hit());
try testing.expect(try ch.hit());
digest2 = ch.final();
try ch.writeManifest();
}
testing.expectEqual(digest1, digest2);
try testing.expectEqual(digest1, digest2);
}
try cwd.deleteTree(temp_manifest_dir);
@ -760,11 +760,11 @@ test "give problematic timestamp" {
// to make it problematic, we make it only accurate to the second
fs_clock = @divTrunc(fs_clock, std.time.ns_per_s);
fs_clock *= std.time.ns_per_s;
testing.expect(isProblematicTimestamp(fs_clock));
try testing.expect(isProblematicTimestamp(fs_clock));
}
test "give nonproblematic timestamp" {
testing.expect(!isProblematicTimestamp(std.time.nanoTimestamp() - std.time.ns_per_s));
try testing.expect(!isProblematicTimestamp(std.time.nanoTimestamp() - std.time.ns_per_s));
}
test "check that changing a file makes cache fail" {
@ -807,9 +807,9 @@ test "check that changing a file makes cache fail" {
const temp_file_idx = try ch.addFile(temp_file, 100);
// There should be nothing in the cache
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
testing.expect(mem.eql(u8, original_temp_file_contents, ch.files.items[temp_file_idx].contents.?));
try testing.expect(mem.eql(u8, original_temp_file_contents, ch.files.items[temp_file_idx].contents.?));
digest1 = ch.final();
@ -826,17 +826,17 @@ test "check that changing a file makes cache fail" {
const temp_file_idx = try ch.addFile(temp_file, 100);
// A file that we depend on has been updated, so the cache should not contain an entry for it
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
// The cache system does not keep the contents of re-hashed input files.
testing.expect(ch.files.items[temp_file_idx].contents == null);
try testing.expect(ch.files.items[temp_file_idx].contents == null);
digest2 = ch.final();
try ch.writeManifest();
}
testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));
try testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));
}
try cwd.deleteTree(temp_manifest_dir);
@ -868,7 +868,7 @@ test "no file inputs" {
ch.hash.addBytes("1234");
// There should be nothing in the cache
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
digest1 = ch.final();
@ -880,12 +880,12 @@ test "no file inputs" {
ch.hash.addBytes("1234");
testing.expect(try ch.hit());
try testing.expect(try ch.hit());
digest2 = ch.final();
try ch.writeManifest();
}
testing.expectEqual(digest1, digest2);
try testing.expectEqual(digest1, digest2);
}
test "Manifest with files added after initial hash work" {
@ -926,7 +926,7 @@ test "Manifest with files added after initial hash work" {
_ = try ch.addFile(temp_file1, null);
// There should be nothing in the cache
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
_ = try ch.addFilePost(temp_file2);
@ -940,12 +940,12 @@ test "Manifest with files added after initial hash work" {
ch.hash.addBytes("1234");
_ = try ch.addFile(temp_file1, null);
testing.expect(try ch.hit());
try testing.expect(try ch.hit());
digest2 = ch.final();
try ch.writeManifest();
}
testing.expect(mem.eql(u8, &digest1, &digest2));
try testing.expect(mem.eql(u8, &digest1, &digest2));
// Modify the file added after initial hash
const ts2 = std.time.nanoTimestamp();
@ -963,7 +963,7 @@ test "Manifest with files added after initial hash work" {
_ = try ch.addFile(temp_file1, null);
// A file that we depend on has been updated, so the cache should not contain an entry for it
testing.expectEqual(false, try ch.hit());
try testing.expectEqual(false, try ch.hit());
_ = try ch.addFilePost(temp_file2);
@ -972,7 +972,7 @@ test "Manifest with files added after initial hash work" {
try ch.writeManifest();
}
testing.expect(!mem.eql(u8, &digest1, &digest3));
try testing.expect(!mem.eql(u8, &digest1, &digest3));
}
try cwd.deleteTree(temp_manifest_dir);

View File

@ -2852,14 +2852,14 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
}
test "classifyFileExt" {
std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
try std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
}
fn haveFramePointer(comp: *const Compilation) bool {

View File

@ -918,7 +918,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
}
if (std.mem.eql(u8, expect, buffer.items)) {
testing.expect(true);
try testing.expect(true);
return;
}
@ -930,7 +930,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
try printSection(out, ">>>> got", buffer.items);
try printRuler(out);
testing.expect(false);
try testing.expect(false);
}
fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {

View File

@ -67,27 +67,27 @@ pub const c_abi_int_param_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6,
pub const c_abi_int_return_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6, .x7 };
test "Register.id" {
testing.expectEqual(@as(u5, 0), Register.x0.id());
testing.expectEqual(@as(u5, 0), Register.w0.id());
try testing.expectEqual(@as(u5, 0), Register.x0.id());
try testing.expectEqual(@as(u5, 0), Register.w0.id());
testing.expectEqual(@as(u5, 31), Register.xzr.id());
testing.expectEqual(@as(u5, 31), Register.wzr.id());
try testing.expectEqual(@as(u5, 31), Register.xzr.id());
try testing.expectEqual(@as(u5, 31), Register.wzr.id());
testing.expectEqual(@as(u5, 31), Register.sp.id());
testing.expectEqual(@as(u5, 31), Register.sp.id());
try testing.expectEqual(@as(u5, 31), Register.sp.id());
try testing.expectEqual(@as(u5, 31), Register.sp.id());
}
test "Register.size" {
testing.expectEqual(@as(u7, 64), Register.x19.size());
testing.expectEqual(@as(u7, 32), Register.w3.size());
try testing.expectEqual(@as(u7, 64), Register.x19.size());
try testing.expectEqual(@as(u7, 32), Register.w3.size());
}
test "Register.to64/to32" {
testing.expectEqual(Register.x0, Register.w0.to64());
testing.expectEqual(Register.x0, Register.x0.to64());
try testing.expectEqual(Register.x0, Register.w0.to64());
try testing.expectEqual(Register.x0, Register.x0.to64());
testing.expectEqual(Register.w3, Register.w3.to32());
testing.expectEqual(Register.w3, Register.x3.to32());
try testing.expectEqual(Register.w3, Register.w3.to32());
try testing.expectEqual(Register.w3, Register.x3.to32());
}
// zig fmt: off
@ -169,33 +169,33 @@ pub const FloatingPointRegister = enum(u8) {
// zig fmt: on
test "FloatingPointRegister.id" {
testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());
testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());
testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());
testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());
testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());
testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());
testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());
try testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());
try testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());
}
test "FloatingPointRegister.size" {
testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());
testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());
testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());
testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());
testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());
try testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());
try testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());
try testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());
try testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());
try testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());
}
test "FloatingPointRegister.toX" {
testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());
testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());
testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());
try testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());
try testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());
try testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());
testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());
testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());
testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());
testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());
try testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());
try testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());
try testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());
try testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());
}
/// Represents an instruction in the AArch64 instruction set
@ -1225,6 +1225,6 @@ test "serialize instructions" {
for (testcases) |case| {
const actual = case.inst.toU32();
testing.expectEqual(case.expected, actual);
try testing.expectEqual(case.expected, actual);
}
}

View File

@ -88,19 +88,19 @@ pub const Condition = enum(u4) {
};
test "condition from CompareOperator" {
testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));
testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));
try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));
try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));
testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));
testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));
try testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));
try testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));
testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));
testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));
try testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));
try testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));
}
test "negate condition" {
testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());
testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());
try testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());
try testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());
}
/// Represents a register in the ARM instruction set architecture
@ -175,8 +175,8 @@ pub const Register = enum(u5) {
};
test "Register.id" {
testing.expectEqual(@as(u4, 15), Register.r15.id());
testing.expectEqual(@as(u4, 15), Register.pc.id());
try testing.expectEqual(@as(u4, 15), Register.r15.id());
try testing.expectEqual(@as(u4, 15), Register.pc.id());
}
/// Program status registers containing flags, mode bits and other
@ -1225,7 +1225,7 @@ test "serialize instructions" {
for (testcases) |case| {
const actual = case.inst.toU32();
testing.expectEqual(case.expected, actual);
try testing.expectEqual(case.expected, actual);
}
}
@ -1265,6 +1265,6 @@ test "aliases" {
};
for (testcases) |case| {
testing.expectEqual(case.expected.toU32(), case.actual.toU32());
try testing.expectEqual(case.expected.toU32(), case.actual.toU32());
}
}

View File

@ -465,6 +465,6 @@ test "serialize instructions" {
for (testcases) |case| {
const actual = case.inst.toU32();
testing.expectEqual(case.expected, actual);
try testing.expectEqual(case.expected, actual);
}
}

View File

@ -463,11 +463,11 @@ test "Wasm - buildOpcode" {
const i64_extend32_s = buildOpcode(.{ .op = .extend, .valtype1 = .i64, .width = 32, .signedness = .signed });
const f64_reinterpret_i64 = buildOpcode(.{ .op = .reinterpret, .valtype1 = .f64, .valtype2 = .i64 });
testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);
testing.expectEqual(@as(wasm.Opcode, .end), end);
testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);
testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);
testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);
try testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);
try testing.expectEqual(@as(wasm.Opcode, .end), end);
try testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);
try testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);
try testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);
}
pub const Result = union(enum) {

View File

@ -182,7 +182,7 @@ test "CodeSignature header" {
try code_sig.writeHeader(stream.writer());
const expected = &[_]u8{ 0xfa, 0xde, 0x0c, 0xc0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0 };
testing.expect(mem.eql(u8, expected, &buffer));
try testing.expect(mem.eql(u8, expected, &buffer));
}
pub fn calcCodeSignaturePaddingSize(id: []const u8, file_size: u64, page_size: u16) u32 {

View File

@ -404,15 +404,15 @@ test "Trie node count" {
var trie = Trie.init(gpa);
defer trie.deinit();
testing.expectEqual(trie.node_count, 0);
testing.expect(trie.root == null);
try testing.expectEqual(trie.node_count, 0);
try testing.expect(trie.root == null);
try trie.put(.{
.name = "_main",
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expectEqual(trie.node_count, 2);
try testing.expectEqual(trie.node_count, 2);
// Inserting the same node shouldn't update the trie.
try trie.put(.{
@ -420,14 +420,14 @@ test "Trie node count" {
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expectEqual(trie.node_count, 2);
try testing.expectEqual(trie.node_count, 2);
try trie.put(.{
.name = "__mh_execute_header",
.vmaddr_offset = 0x1000,
.export_flags = 0,
});
testing.expectEqual(trie.node_count, 4);
try testing.expectEqual(trie.node_count, 4);
// Inserting the same node shouldn't update the trie.
try trie.put(.{
@ -435,13 +435,13 @@ test "Trie node count" {
.vmaddr_offset = 0x1000,
.export_flags = 0,
});
testing.expectEqual(trie.node_count, 4);
try testing.expectEqual(trie.node_count, 4);
try trie.put(.{
.name = "_main",
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expectEqual(trie.node_count, 4);
try testing.expectEqual(trie.node_count, 4);
}
test "Trie basic" {
@ -455,8 +455,8 @@ test "Trie basic" {
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expect(trie.root.?.edges.items.len == 1);
testing.expect(mem.eql(u8, trie.root.?.edges.items[0].label, "_st"));
try testing.expect(trie.root.?.edges.items.len == 1);
try testing.expect(mem.eql(u8, trie.root.?.edges.items[0].label, "_st"));
{
// root --- _st ---> node --- art ---> node
@ -465,12 +465,12 @@ test "Trie basic" {
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expect(trie.root.?.edges.items.len == 1);
try testing.expect(trie.root.?.edges.items.len == 1);
const nextEdge = &trie.root.?.edges.items[0];
testing.expect(mem.eql(u8, nextEdge.label, "_st"));
testing.expect(nextEdge.to.edges.items.len == 1);
testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "art"));
try testing.expect(mem.eql(u8, nextEdge.label, "_st"));
try testing.expect(nextEdge.to.edges.items.len == 1);
try testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "art"));
}
{
// root --- _ ---> node --- st ---> node --- art ---> node
@ -481,16 +481,16 @@ test "Trie basic" {
.vmaddr_offset = 0,
.export_flags = 0,
});
testing.expect(trie.root.?.edges.items.len == 1);
try testing.expect(trie.root.?.edges.items.len == 1);
const nextEdge = &trie.root.?.edges.items[0];
testing.expect(mem.eql(u8, nextEdge.label, "_"));
testing.expect(nextEdge.to.edges.items.len == 2);
testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "st"));
testing.expect(mem.eql(u8, nextEdge.to.edges.items[1].label, "main"));
try testing.expect(mem.eql(u8, nextEdge.label, "_"));
try testing.expect(nextEdge.to.edges.items.len == 2);
try testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "st"));
try testing.expect(mem.eql(u8, nextEdge.to.edges.items[1].label, "main"));
const nextNextEdge = &nextEdge.to.edges.items[0];
testing.expect(mem.eql(u8, nextNextEdge.to.edges.items[0].label, "art"));
try testing.expect(mem.eql(u8, nextNextEdge.to.edges.items[0].label, "art"));
}
}
@ -529,15 +529,15 @@ test "write Trie to a byte stream" {
var stream = std.io.fixedBufferStream(buffer);
{
const nwritten = try trie.write(stream.writer());
testing.expect(nwritten == trie.size);
testing.expect(mem.eql(u8, buffer, &exp_buffer));
try testing.expect(nwritten == trie.size);
try testing.expect(mem.eql(u8, buffer, &exp_buffer));
}
{
// Writing finalized trie again should yield the same result.
try stream.seekTo(0);
const nwritten = try trie.write(stream.writer());
testing.expect(nwritten == trie.size);
testing.expect(mem.eql(u8, buffer, &exp_buffer));
try testing.expect(nwritten == trie.size);
try testing.expect(mem.eql(u8, buffer, &exp_buffer));
}
}
@ -560,7 +560,7 @@ test "parse Trie from byte stream" {
defer trie.deinit();
const nread = try trie.read(in_stream.reader());
testing.expect(nread == in_buffer.len);
try testing.expect(nread == in_buffer.len);
try trie.finalize();
@ -569,6 +569,6 @@ test "parse Trie from byte stream" {
var out_stream = std.io.fixedBufferStream(out_buffer);
const nwritten = try trie.write(out_stream.writer());
testing.expect(nwritten == trie.size);
testing.expect(mem.eql(u8, &in_buffer, out_buffer));
try testing.expect(nwritten == trie.size);
try testing.expect(mem.eql(u8, &in_buffer, out_buffer));
}

View File

@ -286,13 +286,13 @@ fn testRead(allocator: *Allocator, buffer: []const u8, expected: anytype) !void
var stream = io.fixedBufferStream(buffer);
var given = try LoadCommand.read(allocator, stream.reader());
defer given.deinit(allocator);
testing.expect(expected.eql(given));
try testing.expect(expected.eql(given));
}
fn testWrite(buffer: []u8, cmd: LoadCommand, expected: []const u8) !void {
var stream = io.fixedBufferStream(buffer);
try cmd.write(stream.writer());
testing.expect(mem.eql(u8, expected, buffer[0..expected.len]));
try testing.expect(mem.eql(u8, expected, buffer[0..expected.len]));
}
test "read-write segment command" {

View File

@ -267,21 +267,21 @@ test "tryAllocReg: no spilling" {
.src = .unneeded,
};
std.testing.expect(!function.register_manager.isRegAllocated(.r2));
std.testing.expect(!function.register_manager.isRegAllocated(.r3));
try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
std.testing.expectEqual(@as(?MockRegister, .r2), function.register_manager.tryAllocReg(&mock_instruction));
std.testing.expectEqual(@as(?MockRegister, .r3), function.register_manager.tryAllocReg(&mock_instruction));
std.testing.expectEqual(@as(?MockRegister, null), function.register_manager.tryAllocReg(&mock_instruction));
try std.testing.expectEqual(@as(?MockRegister, .r2), function.register_manager.tryAllocReg(&mock_instruction));
try std.testing.expectEqual(@as(?MockRegister, .r3), function.register_manager.tryAllocReg(&mock_instruction));
try std.testing.expectEqual(@as(?MockRegister, null), function.register_manager.tryAllocReg(&mock_instruction));
std.testing.expect(function.register_manager.isRegAllocated(.r2));
std.testing.expect(function.register_manager.isRegAllocated(.r3));
try std.testing.expect(function.register_manager.isRegAllocated(.r2));
try std.testing.expect(function.register_manager.isRegAllocated(.r3));
function.register_manager.freeReg(.r2);
function.register_manager.freeReg(.r3);
std.testing.expect(function.register_manager.isRegAllocated(.r2));
std.testing.expect(function.register_manager.isRegAllocated(.r3));
try std.testing.expect(function.register_manager.isRegAllocated(.r2));
try std.testing.expect(function.register_manager.isRegAllocated(.r3));
}
test "allocReg: spilling" {
@ -298,20 +298,20 @@ test "allocReg: spilling" {
.src = .unneeded,
};
std.testing.expect(!function.register_manager.isRegAllocated(.r2));
std.testing.expect(!function.register_manager.isRegAllocated(.r3));
try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
try std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
try std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
// Spill a register
std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
try std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
// No spilling necessary
function.register_manager.freeReg(.r3);
std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
try std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
}
test "getReg" {
@ -328,18 +328,18 @@ test "getReg" {
.src = .unneeded,
};
std.testing.expect(!function.register_manager.isRegAllocated(.r2));
std.testing.expect(!function.register_manager.isRegAllocated(.r3));
try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
try function.register_manager.getReg(.r3, &mock_instruction);
std.testing.expect(!function.register_manager.isRegAllocated(.r2));
std.testing.expect(function.register_manager.isRegAllocated(.r3));
try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
try std.testing.expect(function.register_manager.isRegAllocated(.r3));
// Spill r3
try function.register_manager.getReg(.r3, &mock_instruction);
std.testing.expect(!function.register_manager.isRegAllocated(.r2));
std.testing.expect(function.register_manager.isRegAllocated(.r3));
std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r3}, function.spilled.items);
try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
try std.testing.expect(function.register_manager.isRegAllocated(.r3));
try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r3}, function.spilled.items);
}

View File

@ -705,14 +705,14 @@ pub const TestContext = struct {
defer file.close();
const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);
std.testing.expectEqualStrings(expected_output, out);
try std.testing.expectEqualStrings(expected_output, out);
},
.CompareObjectFile => |expected_output| {
var file = try tmp.dir.openFile(bin_name, .{ .read = true });
defer file.close();
const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);
std.testing.expectEqualStrings(expected_output, out);
try std.testing.expectEqualStrings(expected_output, out);
},
.Error => |case_error_list| {
var test_node = update_node.start("assert", 0);
@ -939,7 +939,7 @@ pub const TestContext = struct {
return error.ZigTestFailed;
},
}
std.testing.expectEqualStrings(expected_stdout, exec_result.stdout);
try std.testing.expectEqualStrings(expected_stdout, exec_result.stdout);
// We allow stderr to have garbage in it because wasmtime prints a
// warning about --invoke even though we don't pass it.
//std.testing.expectEqualStrings("", exec_result.stderr);

View File

@ -1456,19 +1456,19 @@ test "hash same value different representation" {
.data = 0,
};
const zero_2 = Value.initPayload(&payload_1.base);
std.testing.expectEqual(zero_1.hash(), zero_2.hash());
try std.testing.expectEqual(zero_1.hash(), zero_2.hash());
var payload_2 = Value.Payload.I64{
.base = .{ .tag = .int_i64 },
.data = 0,
};
const zero_3 = Value.initPayload(&payload_2.base);
std.testing.expectEqual(zero_2.hash(), zero_3.hash());
try std.testing.expectEqual(zero_2.hash(), zero_3.hash());
var payload_3 = Value.Payload.BigInt{
.base = .{ .tag = .int_big_negative },
.data = &[_]std.math.big.Limb{0},
};
const zero_4 = Value.initPayload(&payload_3.base);
std.testing.expectEqual(zero_3.hash(), zero_4.hash());
try std.testing.expectEqual(zero_3.hash(), zero_4.hash());
}