cbe: implement optional slice representation change
This commit is contained in:
@@ -3,6 +3,7 @@ const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const expect = testing.expect;
|
||||
const expectEqual = testing.expectEqual;
|
||||
const expectEqualStrings = std.testing.expectEqualStrings;
|
||||
|
||||
test "passing an optional integer as a parameter" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
@@ -425,3 +426,18 @@ test "alignment of wrapping an optional payload" {
|
||||
};
|
||||
try expect(S.foo().?.x == 1234);
|
||||
}
|
||||
|
||||
test "Optional slice size is optimized" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
try expect(@sizeOf(?[]u8) == @sizeOf([]u8));
|
||||
var a: ?[]const u8 = null;
|
||||
try expect(a == null);
|
||||
a = "hello";
|
||||
try expectEqualStrings(a.?, "hello");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user