From b5dc38e9e61c14c0837874207c2133d7e1f52fba Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 15 May 2016 18:25:13 +0200 Subject: [PATCH] Add more NaN-related tests, make NaN checking stricter reallyequal: Compare the sign of NaN when checking if the args are NaN. Tests added: - llAsin, llAcos with out-of-range argument produces NaN. - llAtan2 with (0, 0) produces 0. - Sign of NaN is not distinguished in lists, even if NaN compares equal to NaN. --- testfuncs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testfuncs.py b/testfuncs.py index 8eb17fe..96e000b 100644 --- a/testfuncs.py +++ b/testfuncs.py @@ -51,7 +51,9 @@ def reallyequal(actual, expected, tol): if actual == 0.0: return repr(actual) == repr(expected) elif math.isnan(actual): - return math.isnan(expected) + # This compares the sign of NaN as well + from struct import pack + return pack('>f', actual) == pack('>f', expected) return abs(actual - expected) <= tol # Deal with tuples and lists (item-by-item, recursively) @@ -830,6 +832,9 @@ def do_tests(): test('llTan(F32(math.pi))', F('0x1.777A5Cp-24')) test('llTan(F32(math.pi*.5))', -22877330.) test('llTan(F("0x1.921FB4p0"))', 13245400.) + test('llAsin(2.0)', NaN) + test('llAcos(2.0)', NaN) + test('llAtan2(0.0, 0.0)', 0.0) # nan and -nan in llList2CSV test('llList2CSV([llSin(F32(4e38))])', u'-nan') @@ -1023,7 +1028,7 @@ def do_tests(): test('llModPow(41, 1, 17)', 7) test('llListFindList([], [])', 0) - test('llListFindList([NaN], [NaN])', 0) # I swear + test('llListFindList([NaN, -NaN], [-NaN, NaN])', 0) # I swear test('llListFindList([-0.], [0.])', 0) # Really. test('llListFindList([0.], [-0.])', 0) # Yes. test('llListFindList([1, NaN, 1., NaN], [1., NaN])', 2)