This commit is contained in:
Waylon Walker 2022-03-31 20:20:07 -05:00
commit 38355d2442
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
9083 changed files with 1225834 additions and 0 deletions

View file

@ -0,0 +1,30 @@
# Test cases for floats (compile and run)
[case testStrToFloat]
def str_to_float(x: str) -> float:
return float(x)
[file driver.py]
from native import str_to_float
assert str_to_float("1") == 1.0
assert str_to_float("1.234567") == 1.234567
assert str_to_float("44324") == 44324.0
assert str_to_float("23.4") == 23.4
assert str_to_float("-43.44e-4") == -43.44e-4
[case testFloatArithmetic]
def test_abs() -> None:
assert abs(0.0) == 0.0
assert abs(-1.234567) == 1.234567
assert abs(44324.732) == 44324.732
assert abs(-23.4) == 23.4
assert abs(-43.44e-4) == 43.44e-4
def test_float_min_max() -> None:
x: float = 20.0
y: float = 30.0
assert min(x, y) == 20.0
assert min(y, x) == 20.0
assert max(x, y) == 30.0
assert max(y, x) == 30.0