mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01:00
22 lines
392 B
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
|