lots of miscellaneous things all in one big commit
* add `@compileLog(...)` builtin function - Helps debug code running at compile time - See #240 * fix crash when there is an error on the start value of a slice * add implicit cast from int and float types to int and float literals if the value is known at compile time * make array concatenation work with slices in addition to arrays and c string literals * fix compile error message for something not having field access * fix crash when `@setDebugSafety()` was called from a function being evaluated at compile-time * fix compile-time evaluation of overflow math builtins. * avoid debug safety panic handler in builtin.o and compiler_rt.o since we use no debug safety in these modules anyway * add compiler_rt functions for division on ARM - Closes #254 * move default panic handler to std.debug so users can call it manually * std.io.printf supports a width in the format specifier
This commit is contained in:
17
std/math.zig
17
std/math.zig
@@ -1,3 +1,5 @@
|
||||
const assert = @import("debug.zig").assert;
|
||||
|
||||
pub const Cmp = enum {
|
||||
Equal,
|
||||
Greater,
|
||||
@@ -66,3 +68,18 @@ fn getReturnTypeForAbs(comptime T: type) -> type {
|
||||
}
|
||||
}
|
||||
|
||||
fn testMath() {
|
||||
@setFnTest(this);
|
||||
|
||||
assert(%%mulOverflow(i32, 3, 4) == 12);
|
||||
assert(%%addOverflow(i32, 3, 4) == 7);
|
||||
assert(%%subOverflow(i32, 3, 4) == -1);
|
||||
assert(%%shlOverflow(i32, 0b11, 4) == 0b110000);
|
||||
|
||||
comptime {
|
||||
assert(%%mulOverflow(i32, 3, 4) == 12);
|
||||
assert(%%addOverflow(i32, 3, 4) == 7);
|
||||
assert(%%subOverflow(i32, 3, 4) == -1);
|
||||
assert(%%shlOverflow(i32, 0b11, 4) == 0b110000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user