Modulo tests
@@ -33,6 +33,7 @@ pub fn main() -> Int {
suite("call returned function", call_returned_function_tests()),
suite("floats", floats_tests()),
suite("ints", ints_tests()),
+ suite("modulo", modulo_tests()),
suite("mod with numbers", mod_with_numbers_tests()),
suite("record update", record_update_tests()),
suite("record access", record_access_tests()),
@@ -1151,6 +1152,23 @@ fn ints_tests() -> List(Test) {
]
}
+fn modulo_tests() -> List(Test) {
+ [
+ "1 % 1"
+ |> example(fn() { assert_equal(0, 1 % 1) }),
+ "1 % 0"
+ |> example(fn() { assert_equal(0, 1 % 0) }),
+ "3 % 2"
+ |> example(fn() { assert_equal(1, 3 % 2) }),
+ "3 % 0"
+ |> example(fn() { assert_equal(0, 3 % 0) }),
+ "3 % -2"
+ |> example(fn() { assert_equal(1, 3 % -2) }),
+ "3 % -0"
+ |> example(fn() { assert_equal(0, 3 % -0) }),
+ ]
+}
+
fn mod_with_numbers_tests() -> List(Test) {
[
"mod_with_numbers_0123456789.hello()"
