blob: 60b01aa0e9288272f5810ec176bcee3e0519d7b5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const expect = @import("std").testing.expect;
const FileOpenError = error { AccessDenied, OutOfMemory, FileNotFound };
const AllocationError = error { OutOfMemory };
fn foo(err: AllocationError) FileOpenError {
return err;
}
test "coerce subset to superset" {
const err = foo(AllocationError.OutOfMemory);
expect(err == FileOpenError.OutOfMemory);
expect(err == AllocationError.OutOfMemory);
expect(err == error.OutOfMemory);
}
fn bar(err: FileOpenError) AllocationError {
return err;
}
test "coerce superset to subset" {
bar(FileOpenError.OutOfMemory) catch {};
}
|