1const expectEqual = @import("std").testing.expectEqual;
2
3test "optional type" {
4 // Declare an optional and coerce from null:
5 var foo: ?i32 = null;
6
7 // Coerce from child type of an optional
8 foo = 1234;
9
10 // Use compile-time reflection to access the child type of the optional:
11 try comptime expectEqual(i32, @typeInfo(@TypeOf(foo)).optional.child);
12}
13
14// test