| ... | @@ -1946,3 +1946,47 @@ test "comptime float vector multiplication of zero by nan is nan" { | ... | @@ -1946,3 +1946,47 @@ test "comptime float vector multiplication of zero by nan is nan" { |
| 1946 | comptime assert(math.isNan((ct_zero * ct_nan)[0])); | 1946 | comptime assert(math.isNan((ct_zero * ct_nan)[0])); |
| 1947 | comptime assert(math.isNan((ct_nan * ct_zero)[0])); | 1947 | comptime assert(math.isNan((ct_nan * ct_zero)[0])); |
| 1948 | } | 1948 | } |
| | 1949 | |
| | 1950 | test "i96 operations" { |
| | 1951 | // This is coverage for some stuff used by std.Io timestamps, to catch |
| | 1952 | // issues earlier than bootstrapping. |
| | 1953 | const Op_i96 = union(enum) { |
| | 1954 | a, |
| | 1955 | b: B, |
| | 1956 | c: C, |
| | 1957 | |
| | 1958 | const B = struct { |
| | 1959 | inner: struct { x: i96 }, |
| | 1960 | flag: bool, |
| | 1961 | }; |
| | 1962 | |
| | 1963 | const C = struct { |
| | 1964 | inner: struct { x: i96 }, |
| | 1965 | flag: bool, |
| | 1966 | }; |
| | 1967 | |
| | 1968 | fn do(op: @This()) i64 { |
| | 1969 | switch (op) { |
| | 1970 | .a => { |
| | 1971 | return std.math.minInt(i64); |
| | 1972 | }, |
| | 1973 | .b => |b| { |
| | 1974 | const x = b.inner.x; |
| | 1975 | return @intCast(@divTrunc(x, 100)); |
| | 1976 | }, |
| | 1977 | .c => |c| { |
| | 1978 | const a = get() catch unreachable; |
| | 1979 | const b = a.x + c.inner.x; |
| | 1980 | return @intCast(@divTrunc(b, 100)); |
| | 1981 | }, |
| | 1982 | } |
| | 1983 | } |
| | 1984 | |
| | 1985 | fn get() anyerror!struct { x: i96 } { |
| | 1986 | return .{ .x = 999999999 }; |
| | 1987 | } |
| | 1988 | }; |
| | 1989 | try expect(-9223372036854775808 == Op_i96.do(.{ .a = {} })); |
| | 1990 | try expect(12345678910111213 == Op_i96.do(.{ .b = .{ .inner = .{ .x = 1234567891011121314 }, .flag = true } })); |
| | 1991 | try expect(1234567891021121314 == Op_i96.do(.{ .c = .{ .inner = .{ .x = 123456789101112131415 }, .flag = true } })); |
| | 1992 | } |