| ... | @@ -13,7 +13,7 @@ test "type info: tag type, void info" { | ... | @@ -13,7 +13,7 @@ test "type info: tag type, void info" { |
| 13 | fn testBasic() void { | 13 | fn testBasic() void { |
| 14 | expect(@TagType(TypeInfo) == TypeId); | 14 | expect(@TagType(TypeInfo) == TypeId); |
| 15 | const void_info = @typeInfo(void); | 15 | const void_info = @typeInfo(void); |
| 16 | expect(@as(TypeId, void_info) == TypeId.Void); | 16 | expect(void_info == TypeId.Void); |
| 17 | expect(void_info.Void == {}); | 17 | expect(void_info.Void == {}); |
| 18 | } | 18 | } |
| 19 | | 19 | |
| ... | @@ -24,12 +24,12 @@ test "type info: integer, floating point type info" { | ... | @@ -24,12 +24,12 @@ test "type info: integer, floating point type info" { |
| 24 | | 24 | |
| 25 | fn testIntFloat() void { | 25 | fn testIntFloat() void { |
| 26 | const u8_info = @typeInfo(u8); | 26 | const u8_info = @typeInfo(u8); |
| 27 | expect(@as(TypeId, u8_info) == TypeId.Int); | 27 | expect(u8_info == .Int); |
| 28 | expect(!u8_info.Int.is_signed); | 28 | expect(!u8_info.Int.is_signed); |
| 29 | expect(u8_info.Int.bits == 8); | 29 | expect(u8_info.Int.bits == 8); |
| 30 | | 30 | |
| 31 | const f64_info = @typeInfo(f64); | 31 | const f64_info = @typeInfo(f64); |
| 32 | expect(@as(TypeId, f64_info) == TypeId.Float); | 32 | expect(f64_info == .Float); |
| 33 | expect(f64_info.Float.bits == 64); | 33 | expect(f64_info.Float.bits == 64); |
| 34 | } | 34 | } |
| 35 | | 35 | |
| ... | @@ -40,7 +40,7 @@ test "type info: pointer type info" { | ... | @@ -40,7 +40,7 @@ test "type info: pointer type info" { |
| 40 | | 40 | |
| 41 | fn testPointer() void { | 41 | fn testPointer() void { |
| 42 | const u32_ptr_info = @typeInfo(*u32); | 42 | const u32_ptr_info = @typeInfo(*u32); |
| 43 | expect(@as(TypeId, u32_ptr_info) == TypeId.Pointer); | 43 | expect(u32_ptr_info == .Pointer); |
| 44 | expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.One); | 44 | expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.One); |
| 45 | expect(u32_ptr_info.Pointer.is_const == false); | 45 | expect(u32_ptr_info.Pointer.is_const == false); |
| 46 | expect(u32_ptr_info.Pointer.is_volatile == false); | 46 | expect(u32_ptr_info.Pointer.is_volatile == false); |
| ... | @@ -56,7 +56,7 @@ test "type info: unknown length pointer type info" { | ... | @@ -56,7 +56,7 @@ test "type info: unknown length pointer type info" { |
| 56 | | 56 | |
| 57 | fn testUnknownLenPtr() void { | 57 | fn testUnknownLenPtr() void { |
| 58 | const u32_ptr_info = @typeInfo([*]const volatile f64); | 58 | const u32_ptr_info = @typeInfo([*]const volatile f64); |
| 59 | expect(@as(TypeId, u32_ptr_info) == TypeId.Pointer); | 59 | expect(u32_ptr_info == .Pointer); |
| 60 | expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many); | 60 | expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many); |
| 61 | expect(u32_ptr_info.Pointer.is_const == true); | 61 | expect(u32_ptr_info.Pointer.is_const == true); |
| 62 | expect(u32_ptr_info.Pointer.is_volatile == true); | 62 | expect(u32_ptr_info.Pointer.is_volatile == true); |
| ... | @@ -72,7 +72,7 @@ test "type info: null terminated pointer type info" { | ... | @@ -72,7 +72,7 @@ test "type info: null terminated pointer type info" { |
| 72 | | 72 | |
| 73 | fn testNullTerminatedPtr() void { | 73 | fn testNullTerminatedPtr() void { |
| 74 | const ptr_info = @typeInfo([*:0]u8); | 74 | const ptr_info = @typeInfo([*:0]u8); |
| 75 | expect(@as(TypeId, ptr_info) == TypeId.Pointer); | 75 | expect(ptr_info == .Pointer); |
| 76 | expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many); | 76 | expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many); |
| 77 | expect(ptr_info.Pointer.is_const == false); | 77 | expect(ptr_info.Pointer.is_const == false); |
| 78 | expect(ptr_info.Pointer.is_volatile == false); | 78 | expect(ptr_info.Pointer.is_volatile == false); |
| ... | @@ -91,8 +91,8 @@ test "type info: C pointer type info" { | ... | @@ -91,8 +91,8 @@ test "type info: C pointer type info" { |
| 91 | | 91 | |
| 92 | fn testCPtr() void { | 92 | fn testCPtr() void { |
| 93 | const ptr_info = @typeInfo([*c]align(4) const i8); | 93 | const ptr_info = @typeInfo([*c]align(4) const i8); |
| 94 | expect(@as(TypeId, ptr_info) == TypeId.Pointer); | 94 | expect(ptr_info == .Pointer); |
| 95 | expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.C); | 95 | expect(ptr_info.Pointer.size == .C); |
| 96 | expect(ptr_info.Pointer.is_const); | 96 | expect(ptr_info.Pointer.is_const); |
| 97 | expect(!ptr_info.Pointer.is_volatile); | 97 | expect(!ptr_info.Pointer.is_volatile); |
| 98 | expect(ptr_info.Pointer.alignment == 4); | 98 | expect(ptr_info.Pointer.alignment == 4); |
| ... | @@ -106,8 +106,8 @@ test "type info: slice type info" { | ... | @@ -106,8 +106,8 @@ test "type info: slice type info" { |
| 106 | | 106 | |
| 107 | fn testSlice() void { | 107 | fn testSlice() void { |
| 108 | const u32_slice_info = @typeInfo([]u32); | 108 | const u32_slice_info = @typeInfo([]u32); |
| 109 | expect(@as(TypeId, u32_slice_info) == TypeId.Pointer); | 109 | expect(u32_slice_info == .Pointer); |
| 110 | expect(u32_slice_info.Pointer.size == TypeInfo.Pointer.Size.Slice); | 110 | expect(u32_slice_info.Pointer.size == .Slice); |
| 111 | expect(u32_slice_info.Pointer.is_const == false); | 111 | expect(u32_slice_info.Pointer.is_const == false); |
| 112 | expect(u32_slice_info.Pointer.is_volatile == false); | 112 | expect(u32_slice_info.Pointer.is_volatile == false); |
| 113 | expect(u32_slice_info.Pointer.alignment == 4); | 113 | expect(u32_slice_info.Pointer.alignment == 4); |
| ... | @@ -121,7 +121,7 @@ test "type info: array type info" { | ... | @@ -121,7 +121,7 @@ test "type info: array type info" { |
| 121 | | 121 | |
| 122 | fn testArray() void { | 122 | fn testArray() void { |
| 123 | const arr_info = @typeInfo([42]bool); | 123 | const arr_info = @typeInfo([42]bool); |
| 124 | expect(@as(TypeId, arr_info) == TypeId.Array); | 124 | expect(arr_info == .Array); |
| 125 | expect(arr_info.Array.len == 42); | 125 | expect(arr_info.Array.len == 42); |
| 126 | expect(arr_info.Array.child == bool); | 126 | expect(arr_info.Array.child == bool); |
| 127 | } | 127 | } |
| ... | @@ -133,7 +133,7 @@ test "type info: optional type info" { | ... | @@ -133,7 +133,7 @@ test "type info: optional type info" { |
| 133 | | 133 | |
| 134 | fn testOptional() void { | 134 | fn testOptional() void { |
| 135 | const null_info = @typeInfo(?void); | 135 | const null_info = @typeInfo(?void); |
| 136 | expect(@as(TypeId, null_info) == TypeId.Optional); | 136 | expect(null_info == .Optional); |
| 137 | expect(null_info.Optional.child == void); | 137 | expect(null_info.Optional.child == void); |
| 138 | } | 138 | } |
| 139 | | 139 | |
| ... | @@ -150,18 +150,18 @@ fn testErrorSet() void { | ... | @@ -150,18 +150,18 @@ fn testErrorSet() void { |
| 150 | }; | 150 | }; |
| 151 | | 151 | |
| 152 | const error_set_info = @typeInfo(TestErrorSet); | 152 | const error_set_info = @typeInfo(TestErrorSet); |
| 153 | expect(@as(TypeId, error_set_info) == TypeId.ErrorSet); | 153 | expect(error_set_info == .ErrorSet); |
| 154 | expect(error_set_info.ErrorSet.?.len == 3); | 154 | expect(error_set_info.ErrorSet.?.len == 3); |
| 155 | expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "First")); | 155 | expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "First")); |
| 156 | expect(error_set_info.ErrorSet.?[2].value == @errorToInt(TestErrorSet.Third)); | 156 | expect(error_set_info.ErrorSet.?[2].value == @errorToInt(TestErrorSet.Third)); |
| 157 | | 157 | |
| 158 | const error_union_info = @typeInfo(TestErrorSet!usize); | 158 | const error_union_info = @typeInfo(TestErrorSet!usize); |
| 159 | expect(@as(TypeId, error_union_info) == TypeId.ErrorUnion); | 159 | expect(error_union_info == .ErrorUnion); |
| 160 | expect(error_union_info.ErrorUnion.error_set == TestErrorSet); | 160 | expect(error_union_info.ErrorUnion.error_set == TestErrorSet); |
| 161 | expect(error_union_info.ErrorUnion.payload == usize); | 161 | expect(error_union_info.ErrorUnion.payload == usize); |
| 162 | | 162 | |
| 163 | const global_info = @typeInfo(anyerror); | 163 | const global_info = @typeInfo(anyerror); |
| 164 | expect(@as(TypeId, global_info) == TypeId.ErrorSet); | 164 | expect(global_info == .ErrorSet); |
| 165 | expect(global_info.ErrorSet == null); | 165 | expect(global_info.ErrorSet == null); |
| 166 | } | 166 | } |
| 167 | | 167 | |
| ... | @@ -179,8 +179,8 @@ fn testEnum() void { | ... | @@ -179,8 +179,8 @@ fn testEnum() void { |
| 179 | }; | 179 | }; |
| 180 | | 180 | |
| 181 | const os_info = @typeInfo(Os); | 181 | const os_info = @typeInfo(Os); |
| 182 | expect(@as(TypeId, os_info) == TypeId.Enum); | 182 | expect(os_info == .Enum); |
| 183 | expect(os_info.Enum.layout == TypeInfo.ContainerLayout.Auto); | 183 | expect(os_info.Enum.layout == .Auto); |
| 184 | expect(os_info.Enum.fields.len == 4); | 184 | expect(os_info.Enum.fields.len == 4); |
| 185 | expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); | 185 | expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); |
| 186 | expect(os_info.Enum.fields[3].value == 3); | 186 | expect(os_info.Enum.fields[3].value == 3); |
| ... | @@ -195,8 +195,8 @@ test "type info: union info" { | ... | @@ -195,8 +195,8 @@ test "type info: union info" { |
| 195 | | 195 | |
| 196 | fn testUnion() void { | 196 | fn testUnion() void { |
| 197 | const typeinfo_info = @typeInfo(TypeInfo); | 197 | const typeinfo_info = @typeInfo(TypeInfo); |
| 198 | expect(@as(TypeId, typeinfo_info) == TypeId.Union); | 198 | expect(typeinfo_info == .Union); |
| 199 | expect(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto); | 199 | expect(typeinfo_info.Union.layout == .Auto); |
| 200 | expect(typeinfo_info.Union.tag_type.? == TypeId); | 200 | expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 201 | expect(typeinfo_info.Union.fields.len == 25); | 201 | expect(typeinfo_info.Union.fields.len == 25); |
| 202 | expect(typeinfo_info.Union.fields[4].enum_field != null); | 202 | expect(typeinfo_info.Union.fields[4].enum_field != null); |
| ... | @@ -210,9 +210,9 @@ fn testUnion() void { | ... | @@ -210,9 +210,9 @@ fn testUnion() void { |
| 210 | }; | 210 | }; |
| 211 | | 211 | |
| 212 | const notag_union_info = @typeInfo(TestNoTagUnion); | 212 | const notag_union_info = @typeInfo(TestNoTagUnion); |
| 213 | expect(@as(TypeId, notag_union_info) == TypeId.Union); | 213 | expect(notag_union_info == .Union); |
| 214 | expect(notag_union_info.Union.tag_type == null); | 214 | expect(notag_union_info.Union.tag_type == null); |
| 215 | expect(notag_union_info.Union.layout == TypeInfo.ContainerLayout.Auto); | 215 | expect(notag_union_info.Union.layout == .Auto); |
| 216 | expect(notag_union_info.Union.fields.len == 2); | 216 | expect(notag_union_info.Union.fields.len == 2); |
| 217 | expect(notag_union_info.Union.fields[0].enum_field == null); | 217 | expect(notag_union_info.Union.fields[0].enum_field == null); |
| 218 | expect(notag_union_info.Union.fields[1].field_type == u32); | 218 | expect(notag_union_info.Union.fields[1].field_type == u32); |
| ... | @@ -222,7 +222,7 @@ fn testUnion() void { | ... | @@ -222,7 +222,7 @@ fn testUnion() void { |
| 222 | }; | 222 | }; |
| 223 | | 223 | |
| 224 | const extern_union_info = @typeInfo(TestExternUnion); | 224 | const extern_union_info = @typeInfo(TestExternUnion); |
| 225 | expect(extern_union_info.Union.layout == TypeInfo.ContainerLayout.Extern); | 225 | expect(extern_union_info.Union.layout == .Extern); |
| 226 | expect(extern_union_info.Union.tag_type == null); | 226 | expect(extern_union_info.Union.tag_type == null); |
| 227 | expect(extern_union_info.Union.fields[0].enum_field == null); | 227 | expect(extern_union_info.Union.fields[0].enum_field == null); |
| 228 | expect(extern_union_info.Union.fields[0].field_type == *c_void); | 228 | expect(extern_union_info.Union.fields[0].field_type == *c_void); |
| ... | @@ -235,8 +235,8 @@ test "type info: struct info" { | ... | @@ -235,8 +235,8 @@ test "type info: struct info" { |
| 235 | | 235 | |
| 236 | fn testStruct() void { | 236 | fn testStruct() void { |
| 237 | const struct_info = @typeInfo(TestStruct); | 237 | const struct_info = @typeInfo(TestStruct); |
| 238 | expect(@as(TypeId, struct_info) == TypeId.Struct); | 238 | expect(struct_info == .Struct); |
| 239 | expect(struct_info.Struct.layout == TypeInfo.ContainerLayout.Packed); | 239 | expect(struct_info.Struct.layout == .Packed); |
| 240 | expect(struct_info.Struct.fields.len == 4); | 240 | expect(struct_info.Struct.fields.len == 4); |
| 241 | expect(struct_info.Struct.fields[1].offset == null); | 241 | expect(struct_info.Struct.fields[1].offset == null); |
| 242 | expect(struct_info.Struct.fields[2].field_type == *TestStruct); | 242 | expect(struct_info.Struct.fields[2].field_type == *TestStruct); |
| ... | @@ -268,22 +268,20 @@ test "type info: function type info" { | ... | @@ -268,22 +268,20 @@ test "type info: function type info" { |
| 268 | | 268 | |
| 269 | fn testFunction() void { | 269 | fn testFunction() void { |
| 270 | const fn_info = @typeInfo(@TypeOf(foo)); | 270 | const fn_info = @typeInfo(@TypeOf(foo)); |
| 271 | expect(@as(TypeId, fn_info) == TypeId.Fn); | 271 | expect(fn_info == .Fn); |
| 272 | expect(fn_info.Fn.calling_convention == .Unspecified); | 272 | expect(fn_info.Fn.calling_convention == .C); |
| 273 | expect(fn_info.Fn.is_generic); | 273 | expect(!fn_info.Fn.is_generic); |
| 274 | expect(fn_info.Fn.args.len == 2); | 274 | expect(fn_info.Fn.args.len == 2); |
| 275 | expect(fn_info.Fn.is_var_args); | 275 | expect(fn_info.Fn.is_var_args); |
| 276 | expect(fn_info.Fn.return_type == null); | 276 | expect(fn_info.Fn.return_type.? == usize); |
| 277 | | 277 | |
| 278 | const test_instance: TestStruct = undefined; | 278 | const test_instance: TestStruct = undefined; |
| 279 | const bound_fn_info = @typeInfo(@TypeOf(test_instance.foo)); | 279 | const bound_fn_info = @typeInfo(@TypeOf(test_instance.foo)); |
| 280 | expect(@as(TypeId, bound_fn_info) == TypeId.BoundFn); | 280 | expect(bound_fn_info == .BoundFn); |
| 281 | expect(bound_fn_info.BoundFn.args[0].arg_type.? == *const TestStruct); | 281 | expect(bound_fn_info.BoundFn.args[0].arg_type.? == *const TestStruct); |
| 282 | } | 282 | } |
| 283 | | 283 | |
| 284 | fn foo(comptime a: usize, b: bool, args: ...) usize { | 284 | extern fn foo(a: usize, b: bool, args: ...) usize; |
| 285 | return 0; | | |
| 286 | } | | |
| 287 | | 285 | |
| 288 | test "typeInfo with comptime parameter in struct fn def" { | 286 | test "typeInfo with comptime parameter in struct fn def" { |
| 289 | const S = struct { | 287 | const S = struct { |
| ... | @@ -299,7 +297,7 @@ test "type info: vectors" { | ... | @@ -299,7 +297,7 @@ test "type info: vectors" { |
| 299 | | 297 | |
| 300 | fn testVector() void { | 298 | fn testVector() void { |
| 301 | const vec_info = @typeInfo(@Vector(4, i32)); | 299 | const vec_info = @typeInfo(@Vector(4, i32)); |
| 302 | expect(@as(TypeId, vec_info) == TypeId.Vector); | 300 | expect(vec_info == .Vector); |
| 303 | expect(vec_info.Vector.len == 4); | 301 | expect(vec_info.Vector.len == 4); |
| 304 | expect(vec_info.Vector.child == i32); | 302 | expect(vec_info.Vector.child == i32); |
| 305 | } | 303 | } |
| ... | @@ -312,13 +310,13 @@ test "type info: anyframe and anyframe->T" { | ... | @@ -312,13 +310,13 @@ test "type info: anyframe and anyframe->T" { |
| 312 | fn testAnyFrame() void { | 310 | fn testAnyFrame() void { |
| 313 | { | 311 | { |
| 314 | const anyframe_info = @typeInfo(anyframe->i32); | 312 | const anyframe_info = @typeInfo(anyframe->i32); |
| 315 | expect(@as(TypeId, anyframe_info) == .AnyFrame); | 313 | expect(anyframe_info == .AnyFrame); |
| 316 | expect(anyframe_info.AnyFrame.child.? == i32); | 314 | expect(anyframe_info.AnyFrame.child.? == i32); |
| 317 | } | 315 | } |
| 318 | | 316 | |
| 319 | { | 317 | { |
| 320 | const anyframe_info = @typeInfo(anyframe); | 318 | const anyframe_info = @typeInfo(anyframe); |
| 321 | expect(@as(TypeId, anyframe_info) == .AnyFrame); | 319 | expect(anyframe_info == .AnyFrame); |
| 322 | expect(anyframe_info.AnyFrame.child == null); | 320 | expect(anyframe_info.AnyFrame.child == null); |
| 323 | } | 321 | } |
| 324 | } | 322 | } |