(module main)

(fn i32_remainder () -> i32
  (% 17 5))

(fn i32_signed_remainder () -> i32
  (% -17 5))

(fn i64_remainder () -> i64
  (% 42i64 5i64))

(fn i64_signed_remainder () -> i64
  (% -17i64 5i64))

(fn remainder_ok () -> bool
  (if (= (i32_remainder) 2)
    (if (= (i32_signed_remainder) -2)
      (if (= (i64_remainder) 2i64)
        (= (i64_signed_remainder) -2i64)
        false)
      false)
    false))

(fn main () -> i32
  (if (remainder_ok)
    42
    1))

(test "i32 remainder"
  (= (i32_remainder) 2))

(test "i32 signed remainder"
  (= (i32_signed_remainder) -2))

(test "i64 remainder"
  (= (i64_remainder) 2i64))

(test "i64 signed remainder"
  (= (i64_signed_remainder) -2i64))

(test "integer remainder summary"
  (remainder_ok))
