From 404defd99b76ebf2cfe46ea26248a8813e40136f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 7 May 2016 20:53:16 -0700 Subject: add div_exact builtin fn closes #149 --- test/run_tests.cpp | 10 ++++++++++ test/self_hosted.zig | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'test') diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 44b2c93e83..74926d5a38 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1456,6 +1456,16 @@ fn div0(a: i32, b: i32) -> i32 { } )SOURCE"); + add_debug_safety_case("exact division failure", R"SOURCE( +pub fn main(args: [][]u8) -> %void { + div_exact(10, 3); +} +#static_eval_enable(false) +fn div_exact(a: i32, b: i32) -> i32 { + @div_exact(a, b) +} + )SOURCE"); + } ////////////////////////////////////////////////////////////////////////////// diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 34577e570e..6d8ccc9882 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -1603,3 +1603,12 @@ fn float_division() { fn fdiv32(a: f32, b: f32) -> f32 { a / b } + +#attribute("test") +fn exact_division() { + assert(div_exact(55, 11) == 5); +} +#static_eval_enable(false) +fn div_exact(a: u32, b: u32) -> u32 { + @div_exact(a, b) +} -- cgit v1.2.3