///- --package .
quantity (test)
test quantity: prelude
///- --test static --symbol
:< testing
:! hitpoints = ()
:! milliseconds = ()
:! tiles = ()
:! gold_coins = ()
:= hp (value : i32) : units::amount hitpoints = units::amount value
:= ms (value : i32) : units::amount milliseconds = units::amount value
:= tile_count (value : i32) : units::amount tiles = units::amount value
:= gp (value : i32) : units::amount gold_coins = units::amount value
:= healed_to_cap (health : i32) : i32 = units::value_of (units::capped (hp 150) (units::plus (hp health) (hp 60)))
same_unit_arithmetic (test)
test same_unit_arithmetic: passed
///- --test --symbol
///> c
:= ~health = 150i32
:= left = units::value_of (units::minus (hp health) (hp 40))
(left, healed_to_cap health, units::at_least (ms 2000) (ms (health * 10))) |> _assert_eq (110i32, 150i32, !+)
__assert_eq { expected = (110, 150, true) }
hitpoints_and_milliseconds_do_not_mix (test)
test hitpoints_and_milliseconds_do_not_mix: passed
///- --test --symbol --fails "Unification failure"
///> c
units::plus (hp 10) (ms 20)
failed to compile as expected ("Unification failure"): FatalError: File main has a type error somewhere in its path. /home/runner/work/tibia/tibia/src/quantity.spi:28:26 (main.spi:19:26): ETY-TermError: Unification failure. Got: amount milliseconds Expected: amount hitpoints In the definition: spiral_cells_test.
gold_is_not_hitpoints (test)
test gold_is_not_hitpoints: passed
///- --test --symbol --fails "Unification failure"
///> c
:= heal (amount : units::amount hitpoints) = amount
heal (gp 5)
failed to compile as expected ("Unification failure"): FatalError: File main has a type error somewhere in its path. /home/runner/work/tibia/tibia/src/quantity.spi:33:11 (main.spi:20:11): ETY-TermError: Unification failure. Got: amount gold_coins Expected: amount hitpoints In the definition: spiral_cells_test.
units_on_gpu (test)
test units_on_gpu: passed
///- --test --symbol
///> wgsl
:= ~health = 150i32
? healed_to_cap health = 150i32 && units::value_of (units::minus (ms 2000) (ms 500)) = 1500i32 ?> 0i32 |: 1i32