aboutsummaryrefslogtreecommitdiff
path: root/test/cases/eval.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-20 23:06:32 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-20 23:06:32 -0400
commit29b488245daa9210ed9b5e1ffb7290024677f0db (patch)
tree7bcee7504f7caa5f72c8d83bbf066aa494306a70 /test/cases/eval.zig
parent051ee8e626111445c27d6c868cb0cdec6df7409e (diff)
downloadzig-29b488245daa9210ed9b5e1ffb7290024677f0db.tar.gz
zig-29b488245daa9210ed9b5e1ffb7290024677f0db.zip
add setFloatMode builtin and std.math.floor
* skip installing std/rand_test.zig as it's not needed beyond running the std lib tests * add std.math.floor function * add setFloatMode builtin function to choose between builtin.FloatMode.Optimized (default) and builtin.FloatMode.Strict (Optimized is equivalent to -ffast-math in gcc)
Diffstat (limited to 'test/cases/eval.zig')
-rw-r--r--test/cases/eval.zig12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/cases/eval.zig b/test/cases/eval.zig
index 35fc27a3e0..160acbb2c9 100644
--- a/test/cases/eval.zig
+++ b/test/cases/eval.zig
@@ -1,4 +1,5 @@
const assert = @import("std").debug.assert;
+const builtin = @import("builtin");
test "compileTimeRecursion" {
assert(some_data.len == 21);
@@ -222,7 +223,7 @@ test "comptimeIterateOverFnPtrList" {
assert(performFn('w', 99) == 99);
}
-test "evalSetDebugSafetyAtCompileTime" {
+test "eval @setDebugSafety at compile-time" {
const result = comptime fnWithSetDebugSafety();
assert(result == 1234);
}
@@ -232,6 +233,15 @@ fn fnWithSetDebugSafety() -> i32{
return 1234;
}
+test "eval @setFloatMode at compile-time" {
+ const result = comptime fnWithFloatMode();
+ assert(result == 1234.0);
+}
+
+fn fnWithFloatMode() -> f32 {
+ @setFloatMode(this, builtin.FloatMode.Strict);
+ return 1234.0;
+}
const SimpleStruct = struct {