Skip to content

Test floating point numbers the right way #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions integration_tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
ldexp, fabs, gcd, lcm)
from ltypes import i32, f64

eps: f64
eps = 1e-12

def test_factorial_1():
i: i32
Expand Down Expand Up @@ -30,31 +32,31 @@ def test_isqrt():
def test_degrees():
i: f64
i = degrees(32.2)
assert i == 1844.924100321251
assert abs(i - 1844.924100321251) < eps


def test_radians():
i: f64
i = radians(100.1)
assert i == 1.7470745812463238
assert abs(i - 1.7470745812463238) < eps


def test_exp():
i: f64
i = exp(2.34)
assert i == 10.381236562731843
assert abs(i - 10.381236562731843) < eps


def test_pow():
i: f64
i = pow(2.4, 4.3)
assert i == 43.14280115650323
assert abs(i - 43.14280115650323) < eps


def test_ldexp():
i: f64
i = ldexp(23.3, 2)
assert i == 93.2
assert abs(i - 93.2) < eps


def test_fabs():
Expand Down Expand Up @@ -84,15 +86,18 @@ def test_lcm():
assert i == 84


test_factorial_1()
test_comb()
test_isqrt()
test_perm()
test_degrees()
test_radians()
test_exp()
test_pow()
test_fabs()
test_ldexp()
test_gcd()
test_lcm()
def check():
test_factorial_1()
test_comb()
test_isqrt()
test_perm()
test_degrees()
test_radians()
test_exp()
test_pow()
test_fabs()
test_ldexp()
test_gcd()
test_lcm()

check()