zig/doc/langref/test_coerce_error_subset_to_superset.zig

22 lines
392 B
Zig

const std = @import("std");
const FileOpenError = error{
AccessDenied,
OutOfMemory,
FileNotFound,
};
const AllocationError = error{
OutOfMemory,
};
test "coerce subset to superset" {
const err = foo(AllocationError.OutOfMemory);
try std.testing.expectEqual(FileOpenError.OutOfMemory, err);
}
fn foo(err: AllocationError) FileOpenError {
return err;
}
// test