diff options
author | Lukas Larsson <[email protected]> | 2011-08-08 18:46:56 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-10-11 17:19:01 +0200 |
commit | 0e88b9724ddd2d5ccd1def55ab2044e7665ca9e4 (patch) | |
tree | 2f3d3836d1b40741af2ef00fc3c3ee3e64ba53a5 /erts/emulator | |
parent | 6c1a36a91a0b214d598f845bed2b649a4de8ae3f (diff) | |
download | otp-0e88b9724ddd2d5ccd1def55ab2044e7665ca9e4.tar.gz otp-0e88b9724ddd2d5ccd1def55ab2044e7665ca9e4.tar.bz2 otp-0e88b9724ddd2d5ccd1def55ab2044e7665ca9e4.zip |
Add tests for comparing large floats and small bignums
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/test/float_SUITE.erl | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/erts/emulator/test/float_SUITE.erl b/erts/emulator/test/float_SUITE.erl index a8cc3b9a3f..bf0fbc70bc 100644 --- a/erts/emulator/test/float_SUITE.erl +++ b/erts/emulator/test/float_SUITE.erl @@ -203,6 +203,7 @@ cmp_bignum(_Config) -> cmp((1 bsl (64*16)) - 1, (1 bsl (64*15)) * 1.0), [cmp((1 bsl (32*I)) - 1, (1 bsl (32*(I-2))) * 1.0) || I <- lists:seq(3,30)], + [cmp((1 bsl (64*15)) * 1.0, (1 bsl (32*(I)))) || I <- lists:seq(1,29)], ok. span_cmp(Axis) -> @@ -222,24 +223,35 @@ span_cmp(Axis, Incr, Length, Diff) -> end || I <- lists:seq((Length div 2)*-1,(Length div 2))]. cmp(Big,Small) when is_float(Big) -> - BigSmall = lists:flatten( + BigGtSmall = lists:flatten( io_lib:format("~f > ~p",[Big,Small])), - SmallBig = lists:flatten( + BigLtSmall = lists:flatten( io_lib:format("~f < ~p",[Big,Small])), - cmp(Big,Small,BigSmall,SmallBig); + SmallGtBig = lists:flatten( + io_lib:format("~p > ~f",[Small,Big])), + SmallLtBig = lists:flatten( + io_lib:format("~p < ~f",[Small,Big])), + cmp(Big,Small,BigGtSmall,BigLtSmall,SmallGtBig,SmallLtBig); cmp(Big,Small) when is_float(Small) -> - BigSmall = lists:flatten( - io_lib:format("~p > ~f",[Big,Small])), - SmallBig = lists:flatten( - io_lib:format("~p < ~f",[Big,Small])), - cmp(Big,Small,BigSmall,SmallBig). - -cmp(Big,Small,BigSmall,SmallBig) -> - {_,_,_,true} = {Big,Small,BigSmall, + BigGtSmall = lists:flatten( + io_lib:format("~p > ~f",[Big,Small])), + BigLtSmall = lists:flatten( + io_lib:format("~p < ~f",[Big,Small])), + SmallGtBig = lists:flatten( + io_lib:format("~f > ~p",[Small,Big])), + SmallLtBig = lists:flatten( + io_lib:format("~f < ~p",[Small,Big])), + cmp(Big,Small,BigGtSmall,BigLtSmall,SmallGtBig,SmallLtBig). + +cmp(Big,Small,BigGtSmall,BigLtSmall,SmallGtBig,SmallLtBig) -> + {_,_,_,true} = {Big,Small,BigGtSmall, Big > Small}, - {_,_,_,false} = {Big,Small,SmallBig, + {_,_,_,false} = {Big,Small,BigLtSmall, Big < Small}, - {BigSmall, SmallBig}. + {_,_,_,false} = {Big,Small,SmallGtBig, + Small > Big}, + {_,_,_,true} = {Big,Small,SmallLtBig, + Small < Big}. id(I) -> I. |