aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-10-11 17:18:41 +0200
committerLukas Larsson <[email protected]>2011-10-11 17:18:41 +0200
commit0ab6d70a34f5e2fbfdeb6235024a1d5e83cab64f (patch)
tree8d1c318facc782fe8af08ae03067944abe7c0cd3 /erts
parent5afcc1900d858984143c673aca5c1639d12f9e84 (diff)
downloadotp-0ab6d70a34f5e2fbfdeb6235024a1d5e83cab64f.tar.gz
otp-0ab6d70a34f5e2fbfdeb6235024a1d5e83cab64f.tar.bz2
otp-0ab6d70a34f5e2fbfdeb6235024a1d5e83cab64f.zip
Expand tests for float and number comparison
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/test/float_SUITE.erl36
1 files changed, 26 insertions, 10 deletions
diff --git a/erts/emulator/test/float_SUITE.erl b/erts/emulator/test/float_SUITE.erl
index e2e9b9120c..a8cc3b9a3f 100644
--- a/erts/emulator/test/float_SUITE.erl
+++ b/erts/emulator/test/float_SUITE.erl
@@ -193,7 +193,7 @@ cmp_zero(_Config) ->
cmp_integer(_Config) ->
Axis = (1 bsl 53)-2.0, %% The point where floating points become unprecise
span_cmp(Axis,2,200),
- cmp(Axis*Axis, round(Axis)).
+ cmp(Axis*Axis,round(Axis)).
cmp_bignum(_Config) ->
span_cmp((1 bsl 58) - 1.0),%% Smallest bignum float
@@ -202,23 +202,39 @@ cmp_bignum(_Config) ->
[span_cmp((1 bsl (32*I)) - 1.0) || I <- lists:seq(2,30)],
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)],
ok.
span_cmp(Axis) ->
- span_cmp(Axis, 50).
+ span_cmp(Axis, 25).
span_cmp(Axis, Length) ->
span_cmp(Axis, round(Axis) bsr 52, Length).
span_cmp(Axis, Incr, Length) ->
- [cmp(round(Axis*-1.0)+1+I*Incr,Axis*-1.0+I*Incr)
- || I <- lists:seq((Length div 2)*-1,(Length div 2))],
- [cmp(round(Axis)+1+I*Incr,Axis+I*Incr) ||
- I <- lists:seq((Length div 2)*-1,(Length div 2))].
-
-cmp(Big,Small) ->
+ [span_cmp(Axis, Incr, Length, 1 bsl (1 bsl I)) || I <- lists:seq(0,6)].
+span_cmp(Axis, Incr, Length, Diff) ->
+ [begin
+ cmp(round(Axis*-1.0)+Diff+I*Incr,Axis*-1.0+I*Incr),
+ cmp(Axis*-1.0+I*Incr,round(Axis*-1.0)-Diff+I*Incr)
+ end || I <- lists:seq((Length div 2)*-1,(Length div 2))],
+ [begin
+ cmp(round(Axis)+Diff+I*Incr,Axis+I*Incr),
+ cmp(Axis+I*Incr,round(Axis)-Diff+I*Incr)
+ end || I <- lists:seq((Length div 2)*-1,(Length div 2))].
+
+cmp(Big,Small) when is_float(Big) ->
+ BigSmall = lists:flatten(
+ io_lib:format("~f > ~p",[Big,Small])),
+ SmallBig = lists:flatten(
+ io_lib:format("~f < ~p",[Big,Small])),
+ cmp(Big,Small,BigSmall,SmallBig);
+cmp(Big,Small) when is_float(Small) ->
BigSmall = lists:flatten(
- io_lib:format("~p > ~p",[Big,Small])),
+ io_lib:format("~p > ~f",[Big,Small])),
SmallBig = lists:flatten(
- io_lib:format("~p < ~p",[Big,Small])),
+ io_lib:format("~p < ~f",[Big,Small])),
+ cmp(Big,Small,BigSmall,SmallBig).
+
+cmp(Big,Small,BigSmall,SmallBig) ->
{_,_,_,true} = {Big,Small,BigSmall,
Big > Small},
{_,_,_,false} = {Big,Small,SmallBig,