40 lines
809 B
Plaintext
40 lines
809 B
Plaintext
(module main)
|
|
|
|
(fn base () -> u32
|
|
1073741824u32)
|
|
|
|
(fn adjust ((value u32) (delta u32)) -> u32
|
|
(+ value delta))
|
|
|
|
(fn doubled ((value u32)) -> u32
|
|
(* value 2u32))
|
|
|
|
(fn local_total () -> u32
|
|
(let offset u32 15u32)
|
|
(adjust (doubled (base)) offset))
|
|
|
|
(fn high_enough ((value u32)) -> bool
|
|
(if (> value 2147483660u32)
|
|
(< value 2147483670u32)
|
|
false))
|
|
|
|
(fn exact_u32 () -> bool
|
|
(= (local_total) 2147483663u32))
|
|
|
|
(fn main () -> i32
|
|
(std.io.print_u32 (local_total))
|
|
(if (high_enough (local_total))
|
|
0
|
|
1))
|
|
|
|
(test "u32 arithmetic returns exact fixture value"
|
|
(exact_u32))
|
|
|
|
(test "u32 comparison works in predicates"
|
|
(high_enough (local_total)))
|
|
|
|
(test "u32 division and ordering"
|
|
(if (>= (/ (local_total) 3u32) 715827887u32)
|
|
(<= (/ (local_total) 3u32) 715827887u32)
|
|
false))
|