(module main)

(fn i32_zero_text () -> string
  (std.num.i32_to_string 0))

(fn i32_negative_text () -> string
  (std.num.i32_to_string -7))

(fn i32_high_text () -> string
  (std.num.i32_to_string 2147483647))

(fn i64_low_text () -> string
  (std.num.i64_to_string -9223372036854775808i64))

(fn i64_high_text () -> string
  (std.num.i64_to_string 9223372036854775807i64))

(fn i64_beyond_i32_text () -> string
  (std.num.i64_to_string 2147483648i64))

(test "i32 zero to string"
  (= (i32_zero_text) "0"))

(test "i32 negative to string"
  (= (i32_negative_text) "-7"))

(test "i32 high to string"
  (= (i32_high_text) "2147483647"))

(test "i32 negative string length"
  (= (std.string.len (i32_negative_text)) 2))

(test "i64 low to string"
  (= (i64_low_text) "-9223372036854775808"))

(test "i64 high to string"
  (= (i64_high_text) "9223372036854775807"))

(test "i64 beyond i32 to string"
  (= (i64_beyond_i32_text) "2147483648"))

(test "i64 low string length"
  (= (std.string.len (i64_low_text)) 20))

(fn main () -> i32
  (std.io.print_string (i32_zero_text))
  (std.io.print_string (i32_negative_text))
  (std.io.print_string (i32_high_text))
  (std.io.print_string (i64_low_text))
  (std.io.print_string (i64_high_text))
  (std.io.print_string (i64_beyond_i32_text))
  (if (= (std.string.len (i64_high_text)) 19)
    0
    1))
