add the anyframe and anyframe->T types

This commit is contained in:
Andrew Kelley
2019-07-26 19:52:35 -04:00
parent 018a89c7a1
commit ee64a22045
19 changed files with 337 additions and 50 deletions

View File

@@ -177,11 +177,11 @@ fn testUnion() void {
expect(TypeId(typeinfo_info) == TypeId.Union);
expect(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto);
expect(typeinfo_info.Union.tag_type.? == TypeId);
expect(typeinfo_info.Union.fields.len == 25);
expect(typeinfo_info.Union.fields.len == 26);
expect(typeinfo_info.Union.fields[4].enum_field != null);
expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
expect(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int));
expect(typeinfo_info.Union.decls.len == 20);
expect(typeinfo_info.Union.decls.len == 21);
const TestNoTagUnion = union {
Foo: void,
@@ -280,6 +280,25 @@ fn testVector() void {
expect(vec_info.Vector.child == i32);
}
test "type info: anyframe and anyframe->T" {
testAnyFrame();
comptime testAnyFrame();
}
fn testAnyFrame() void {
{
const anyframe_info = @typeInfo(anyframe->i32);
expect(TypeId(anyframe_info) == .AnyFrame);
expect(anyframe_info.AnyFrame.child.? == i32);
}
{
const anyframe_info = @typeInfo(anyframe);
expect(TypeId(anyframe_info) == .AnyFrame);
expect(anyframe_info.AnyFrame.child == null);
}
}
test "type info: optional field unwrapping" {
const Struct = struct {
cdOffset: u32,