Fix Zig builtins for 32-bit targets

This commit is contained in:
Brian Carroll 2022-03-10 23:26:58 +00:00
parent 20f6330f72
commit 4878c701ae
3 changed files with 17 additions and 17 deletions

View file

@ -901,11 +901,11 @@ test "toStr: -0.00045" {
try expectEqualSlices(u8, res_slice, res_roc_str.?.asSlice());
}
test "toStr: -111.123456789" {
var dec: RocDec = .{ .num = -111123456789000000000 };
test "toStr: -111.123456" {
var dec: RocDec = .{ .num = -111123456000000000000 };
var res_roc_str = dec.toStr();
const res_slice: []const u8 = "-111.123456789"[0..];
const res_slice: []const u8 = "-111.123456"[0..];
try expectEqualSlices(u8, res_slice, res_roc_str.?.asSlice());
}

View file

@ -1840,13 +1840,13 @@ test "strTrim: large to large" {
}
test "strTrim: large to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(!original.isSmallStr());
const expected_bytes = "hello world";
const expected_bytes = "hello";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();
@ -1859,13 +1859,13 @@ test "strTrim: large to small" {
}
test "strTrim: small to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(original.isSmallStr());
const expected_bytes = "hello world";
const expected_bytes = "hello";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();
@ -1911,13 +1911,13 @@ test "strTrimLeft: large to large" {
}
test "strTrimLeft: large to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(!original.isSmallStr());
const expected_bytes = "hello world ";
const expected_bytes = "hello ";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();
@ -1930,13 +1930,13 @@ test "strTrimLeft: large to small" {
}
test "strTrimLeft: small to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(original.isSmallStr());
const expected_bytes = "hello world ";
const expected_bytes = "hello ";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();
@ -1982,13 +1982,13 @@ test "strTrimRight: large to large" {
}
test "strTrimRight: large to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(!original.isSmallStr());
const expected_bytes = " hello world";
const expected_bytes = " hello";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();
@ -2001,13 +2001,13 @@ test "strTrimRight: large to small" {
}
test "strTrimRight: small to small" {
const original_bytes = " hello world ";
const original_bytes = " hello ";
const original = RocStr.init(original_bytes, original_bytes.len);
defer original.deinit();
try expect(original.isSmallStr());
const expected_bytes = " hello world";
const expected_bytes = " hello";
const expected = RocStr.init(expected_bytes, expected_bytes.len);
defer expected.deinit();

View file

@ -38,14 +38,14 @@ fn testing_roc_alloc(size: usize, _: u32) callconv(.C) ?*c_void {
}
fn testing_roc_realloc(c_ptr: *c_void, new_size: usize, old_size: usize, _: u32) callconv(.C) ?*c_void {
const ptr = @ptrCast([*]u8, @alignCast(16, c_ptr));
const ptr = @ptrCast([*]u8, @alignCast(2 * @alignOf(usize), c_ptr));
const slice = ptr[0..old_size];
return @ptrCast(?*c_void, std.testing.allocator.realloc(slice, new_size) catch unreachable);
}
fn testing_roc_dealloc(c_ptr: *c_void, _: u32) callconv(.C) void {
const ptr = @ptrCast([*]u8, @alignCast(16, c_ptr));
const ptr = @ptrCast([*]u8, @alignCast(2 * @alignOf(usize), c_ptr));
std.testing.allocator.destroy(ptr);
}