From 97a4f9788f7c36182d0dff85a9ebaa9eef099d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Baru=C4=8Di=C4=87?= Date: Thu, 14 Nov 2024 09:15:42 +0100 Subject: [PATCH] Dectests: Fix `scripts/dectest.jl` A wrong condition in the script resulted in valid test cases to be omitted. --- scripts/dectest.jl | 3 +- test/dectests/test_abs.jl | 1 + test/dectests/test_add.jl | 32 ++++++++++++++ test/dectests/test_divide.jl | 77 +++++++++++++++++++++++++++++++++ test/dectests/test_max.jl | 1 + test/dectests/test_min.jl | 1 + test/dectests/test_minus.jl | 2 + test/dectests/test_multiply.jl | 26 +++++++++++ test/dectests/test_normalize.jl | 2 + test/dectests/test_plus.jl | 2 + test/dectests/test_subtract.jl | 12 +++++ 11 files changed, 157 insertions(+), 2 deletions(-) diff --git a/scripts/dectest.jl b/scripts/dectest.jl index 801b563..b9cf5c7 100644 --- a/scripts/dectest.jl +++ b/scripts/dectest.jl @@ -47,7 +47,6 @@ function translate(io, dectest_path) test = parse_test(line) any(isspecial, test.operands) && continue - isspecial(test.result) && continue dectest = decimal_test(test, directives) println(io, dectest) @@ -57,7 +56,7 @@ end function isspecial(value) value = lowercase(value) - return occursin(r"(inf|nan|#|\?)", value) + return occursin(r"(inf|nan|#)", value) end function parse_precision(line) diff --git a/test/dectests/test_abs.jl b/test/dectests/test_abs.jl index 50cc048..dcc60bd 100644 --- a/test/dectests/test_abs.jl +++ b/test/dectests/test_abs.jl @@ -48,6 +48,7 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"-56267e-2") == dec"562.67") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"-56267e-1") == dec"5626.7") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"-56267e-0") == dec"56267") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, abs(dec"9.999e+999999999")) @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"1.00e-999") == dec"1.00e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"0.1e-999") == dec"1e-1000") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(abs(dec"0.10e-999") == dec"1.0e-1000") diff --git a/test/dectests/test_add.jl b/test/dectests/test_add.jl index 5b4bef4..f49aec0 100644 --- a/test/dectests/test_add.jl +++ b/test/dectests/test_add.jl @@ -568,16 +568,24 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.0" + dec"-0.0" == dec"-1.0") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.0" + dec"0.0" == dec"1.0") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.0" + dec"-0.0" == dec"1.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+999999999" + dec"9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" + dec"1e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.1e-999999999" + dec"1e-999999999" == dec"-1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-999999999" + dec"-1.1e-999999999" == dec"-1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.0001e-999999999" + dec"1e-999999999" == dec"-1e-1000000003") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-999999999" + dec"-1.0001e-999999999" == dec"-1e-1000000003") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+999999999" + dec"-9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9e+999999999" + dec"-1e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"+1.1e-999999999" + dec"-1e-999999999" == dec"1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-999999999" + dec"+1.1e-999999999" == dec"1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"+1.0001e-999999999" + dec"-1e-999999999" == dec"1e-1000000003") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-999999999" + dec"+1.0001e-999999999" == dec"1e-1000000003") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e+999999999" + dec"+9e+999999999" == dec"8e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9e+999999999" + dec"+1e+999999999" == dec"-8e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"0" + dec"-9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9.999e+999999999" + dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"0" + dec"9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9.999e+999999999" + dec"0") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.00e-999" + dec"0" == dec"1.00e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.1e-999" + dec"0" == dec"1e-1000") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.10e-999" + dec"0" == dec"1.0e-1000") @@ -638,6 +646,12 @@ using Decimals: @with_context @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9.999999e+96" == dec"9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9.999999e+96" + dec"1" == dec"9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9999999e+90" + dec"1" == dec"9.999999e+96") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"1e+90") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"9e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"8e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"7e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"6e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9999999e+90" + dec"5e+89") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9999999e+90" + dec"4e+89" == dec"9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9999999e+90" + dec"3e+89" == dec"9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9999999e+90" + dec"2e+89" == dec"9.999999e+96") @@ -645,6 +659,12 @@ using Decimals: @with_context @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9.999999e+96" == dec"-9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9.999999e+96" + dec"-1" == dec"-9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9999999e+90" + dec"-1" == dec"-9.999999e+96") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-1e+90") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-9e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-8e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-7e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-6e+89") +@with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9999999e+90" + dec"-5e+89") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9999999e+90" + dec"-4e+89" == dec"-9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9999999e+90" + dec"-3e+89" == dec"-9.999999e+96") @with_context (Emax = 96, Emin = -95, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-9999999e+90" + dec"-2e+89" == dec"-9.999999e+96") @@ -1486,6 +1506,12 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9.999999999999999e+384" == dec"9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9.999999999999999e+384" + dec"1" == dec"9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9999999999999999e+369" + dec"1" == dec"9.999999999999999e+384") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"1e+369") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"9e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"8e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"7e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"6e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9999999999999999e+369" + dec"5e+368") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9999999999999999e+369" + dec"4e+368" == dec"9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9999999999999999e+369" + dec"3e+368" == dec"9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"9999999999999999e+369" + dec"2e+368" == dec"9.999999999999999e+384") @@ -1493,6 +1519,12 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9.999999999999999e+384" == dec"-9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9.999999999999999e+384" + dec"-1" == dec"-9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9999999999999999e+369" + dec"-1" == dec"-9.999999999999999e+384") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-1e+369") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-9e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-8e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-7e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-6e+368") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9999999999999999e+369" + dec"-5e+368") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9999999999999999e+369" + dec"-4e+368" == dec"-9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9999999999999999e+369" + dec"-3e+368" == dec"-9.999999999999999e+384") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:Nearest}()) @test(dec"-9999999999999999e+369" + dec"-2e+368" == dec"-9.999999999999999e+384") diff --git a/test/dectests/test_divide.jl b/test/dectests/test_divide.jl index c7401d2..7d2f681 100644 --- a/test/dectests/test_divide.jl +++ b/test/dectests/test_divide.jl @@ -399,27 +399,85 @@ using Decimals: @with_context @with_context (Emax = 999, Emin = -999, precision = 2, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-3374988581607586061255542201048" / dec"82293895124.90045271504836568681" == dec"-4.1e+19") @with_context (Emax = 999, Emin = -999, precision = 1, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-3374988581607586061255542201048" / dec"82293895124.90045271504836568681" == dec"-4e+19") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"5.00" / dec"1e-3" == dec"5.00e+3") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"00.00" / dec"0.000") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"00.00" / dec"0e-3") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"0" / dec"-0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"-0" / dec"0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"-0" / dec"-0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0" / dec"-1" == dec"-0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0" / dec"-1" == dec"0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0" / dec"1" == dec"0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0" / dec"1" == dec"-0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"-0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"-0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.0" / dec"-1" == dec"-0.0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.0" / dec"-1" == dec"0.0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.0" / dec"1" == dec"0.0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.0" / dec"1" == dec"-0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1.0" / dec"0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1.0" / dec"-0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1.0" / dec"0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1.0" / dec"-0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0" / dec"-1.0" == dec"-0e+1") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0" / dec"-1.0" == dec"0e+1") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0" / dec"1.0" == dec"0e+1") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0" / dec"1.0" == dec"-0e+1") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"-0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"-0.0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.0" / dec"-1.0" == dec"-0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.0" / dec"-1.0" == dec"0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.0" / dec"1.0" == dec"0") @with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.0" / dec"1.0" == dec"-0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1.0" / dec"0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1.0" / dec"-0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1.0" / dec"0.0") +@with_context (Emax = 384, Emin = -383, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1.0" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"0" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"0.0e5" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(UndefinedDivisionError, dec"0.000" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.0001" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.01" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.1" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"10" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1e+100" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1e+1000" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.0001" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.01" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.1" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-10" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1e+100" / dec"0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1e+1000" / dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.0001" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.01" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"0.1" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"10" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1e+100" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"1e+1000" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.0001" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.01" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-0.1" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-10" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1e+100" / dec"-0.0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 16, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(DivisionByZeroError, dec"-1e+1000" / dec"-0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" / dec"+0.23456789012345e-0") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"+0.100" / dec"9e+999999999" == dec"1.111111e-1000000001") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999999" / dec"+9.100" == dec"9.8901099e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.23456789" / dec"9e+999999999" == dec"-1.3717421e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.23456789012345e-0" / dec"9e+999999999" == dec"-1.3717421e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.23456789012345e-0" / dec"7e+999999999" == dec"-1.7636684e-1000000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" / dec"-0.83456789012345e-0") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.100" / dec"9e+999999999" == dec"-1.111111e-1000000001") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999999" / dec"-9.100" == dec"-9.8901099e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"1e+400000001" == dec"1e-1000000001") @@ -432,13 +490,32 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"1e+400000008" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"1e+400000009" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"1e+400000010" == dec"0e-1000000007") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000001") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000002") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000003") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000004") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000005") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000006") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000007") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000008") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000010") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"1e+400000009" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" / dec"-1e+400000009" == dec"-0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-600000000" / dec"1e+400000009" == dec"-0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-600000000" / dec"-1e+400000009" == dec"0e-1000000007") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"1e-400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" / dec"-1e-400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+600000000" / dec"1e-400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+600000000" / dec"-1e-400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1000" / dec"9.999e-999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1000" / dec"-9.999e-999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9.999e+999999999" / dec"0.01") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9.999e+999999999" / dec"0.01") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.52444e-80" / dec"1" == dec"1.524e-80") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.52445e-80" / dec"1" == dec"1.524e-80") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.52446e-80" / dec"1" == dec"1.524e-80") +@with_context (Emax = 6144, Emin = -6143, precision = 34, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"343e6000" / dec"234e-1000") @with_context (Emax = 6144, Emin = -6143, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e0" / dec"1e0" == dec"1") @with_context (Emax = 6144, Emin = -6143, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e0" / dec"2e0" == dec"0.5") @with_context (Emax = 6144, Emin = -6143, precision = 7, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e0" / dec"3e0" == dec"0.3333333") diff --git a/test/dectests/test_max.jl b/test/dectests/test_max.jl index a1c9d45..95ef0af 100644 --- a/test/dectests/test_max.jl +++ b/test/dectests/test_max.jl @@ -198,6 +198,7 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec".5", dec"6666") == dec"6.67e+3") @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec".5", dec"66666") == dec"6.67e+4") @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec".5", dec"33333") == dec"3.33e+4") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, max(dec"9.999e+999999999", dec"0")) @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec"-9.999e+999999999", dec"0") == dec"0") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec"1.00e-999", dec"0") == dec"1.00e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(max(dec"0.1e-999", dec"0") == dec"1e-1000") diff --git a/test/dectests/test_min.jl b/test/dectests/test_min.jl index 794e571..1568a2e 100644 --- a/test/dectests/test_min.jl +++ b/test/dectests/test_min.jl @@ -189,6 +189,7 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"75410", dec"66666") == dec"6.67e+4") @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"75411", dec"33333") == dec"3.33e+4") @with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"9.999e+999999999", dec"0") == dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, min(dec"-9.999e+999999999", dec"0")) @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"1.00e-999", dec"0") == dec"0") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"0.1e-999", dec"0") == dec"0") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(min(dec"0.10e-999", dec"0") == dec"0") diff --git a/test/dectests/test_minus.jl b/test/dectests/test_minus.jl index ae8e3fc..c163907 100644 --- a/test/dectests/test_minus.jl +++ b/test/dectests/test_minus.jl @@ -69,6 +69,8 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"-56267e+4") == dec"5.6267e+8") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"-56267e+5") == dec"5.6267e+9") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"-56267e+6") == dec"5.6267e+10") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, -(dec"9.999e+999999999")) +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, -(dec"-9.999e+999999999")) @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"1.00e-999") == dec"-1.00e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"0.1e-999") == dec"-1e-1000") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(-(dec"0.10e-999") == dec"-1.0e-1000") diff --git a/test/dectests/test_multiply.jl b/test/dectests/test_multiply.jl index 957814f..29c1f16 100644 --- a/test/dectests/test_multiply.jl +++ b/test/dectests/test_multiply.jl @@ -249,8 +249,12 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.0" * dec"-0.0" == dec"0.00") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.0" * dec"0.0" == dec"0.00") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1.0" * dec"-0.0" == dec"-0.00") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"+1.23456789012345e-0" * dec"9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" * dec"+1.23456789012345e-0") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"+0.100" * dec"9e-999999999" == dec"9.00e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999999" * dec"+0.100" == dec"9.00e-1000000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1.23456789012345e-0" * dec"9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" * dec"-1.23456789012345e-0") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-0.100" * dec"9e-999999999" == dec"-9.00e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999999" * dec"-0.100" == dec"-9.00e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-599999999" * dec"1e-400000001" == dec"1e-1000000000") @@ -259,8 +263,16 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999998" * dec"0.01" == dec"9e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e-999999998" * dec"0.1" == dec"9e-999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0.01" * dec"9e-999999998" == dec"9e-1000000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e599999999" * dec"1e400000001") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e599999999" * dec"1e400000000" == dec"1e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e600000000" * dec"1e400000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e999999998" * dec"100") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"9e999999998" * dec"10" == dec"9.0e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"100" * dec"9e999999998") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+777777777" * dec"1e+411111111") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+777777777" * dec"-1e+411111111") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+777777777" * dec"1e+411111111") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+777777777" * dec"-1e+411111111") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-777777777" * dec"1e-411111111" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-777777777" * dec"-1e-411111111" == dec"-0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-777777777" * dec"1e-411111111" == dec"-0e-1000000007") @@ -275,6 +287,16 @@ using Decimals: @with_context @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000008" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000009" == dec"0e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000010" == dec"0e-1000000007") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000001") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000002") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000003") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000004") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000005") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000006") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000007") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000008") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000009") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+600000000" * dec"1e+400000010") @with_context (Emax = 999999999, Emin = -999999999, precision = 99, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000007" == dec"1e-1000000007") @with_context (Emax = 999999999, Emin = -999999999, precision = 99, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000008" == dec"1e-1000000008") @with_context (Emax = 999999999, Emin = -999999999, precision = 99, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-600000000" * dec"1e-400000097" == dec"1e-1000000097") @@ -347,6 +369,10 @@ using Decimals: @with_context @with_context (Emax = 999, Emin = -999, precision = 5, rounding = RoundingMode{:Nearest}()) @test(dec"25e-668" * dec"5e-334" == dec"1.25e-1000") @with_context (Emax = 999, Emin = -999, precision = 5, rounding = RoundingMode{:Nearest}()) @test(dec"10e-668" * dec"100e-334" == dec"1.000e-999") @with_context (Emax = 999, Emin = -999, precision = 19, rounding = RoundingMode{:Nearest}()) @test(dec"6636851557994578716e-520" * dec"6636851557994578716e-520" == dec"4.40477986028551e-1003") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"1" * dec"9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"1" * dec"-9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"9.999e+999999999" * dec"1") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:Nearest}()) @test_throws(OverflowError, dec"-9.999e+999999999" * dec"1") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:Nearest}()) @test(dec"1.2347e-40" * dec"1.2347e-40" == dec"1.524e-80") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:Nearest}()) @test(dec"1.234e-40" * dec"1.234e-40" == dec"1.523e-80") @with_context (Emax = 79, Emin = -79, precision = 5, rounding = RoundingMode{:Nearest}()) @test(dec"1.23e-40" * dec"1.23e-40" == dec"1.513e-80") diff --git a/test/dectests/test_normalize.jl b/test/dectests/test_normalize.jl index 8cbfd73..8c0a403 100644 --- a/test/dectests/test_normalize.jl +++ b/test/dectests/test_normalize.jl @@ -110,6 +110,8 @@ using Decimals: @with_context @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"-120") == dec"-1.2e+2") @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"120.00") == dec"1.2e+2") @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"0.00") == dec"0") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, normalize(dec"9.999e+999999999")) +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, normalize(dec"-9.999e+999999999")) @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"1.00e-999") == dec"1e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"0.1e-999") == dec"1e-1000") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(normalize(dec"0.10e-999") == dec"1e-1000") diff --git a/test/dectests/test_plus.jl b/test/dectests/test_plus.jl index c8a4946..d0ee10c 100644 --- a/test/dectests/test_plus.jl +++ b/test/dectests/test_plus.jl @@ -69,6 +69,8 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"+5e8") == dec"5e+8") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"+5e13") == dec"5e+13") @with_context (Emax = 384, Emin = -383, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"+5e18") == dec"5e+18") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, +(dec"9.999e+999999999")) +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, +(dec"-9.999e+999999999")) @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"1.00e-999") == dec"1.00e-999") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"0.1e-999") == dec"1e-1000") @with_context (Emax = 999, Emin = -999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(+(dec"0.10e-999") == dec"1.0e-1000") diff --git a/test/dectests/test_subtract.jl b/test/dectests/test_subtract.jl index 35dff4c..b38d478 100644 --- a/test/dectests/test_subtract.jl +++ b/test/dectests/test_subtract.jl @@ -499,10 +499,22 @@ using Decimals: @with_context @with_context (Emax = 384, Emin = -383, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"3444" - dec"-12e+3" == dec"1.54e+4") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:ToZero}()) @test_throws(OverflowError, dec"1e+999999999" - dec"-9e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:ToZero}()) @test_throws(OverflowError, dec"9e+999999999" - dec"-1e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1e+999999999" - dec"-9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9e+999999999" - dec"-1e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1.1e-999999999" - dec"-1e-999999999" == dec"-1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1e-999999999" - dec"+1.1e-999999999" == dec"-1e-1000000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-1e+999999999" - dec"+9e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9e+999999999" - dec"+1e+999999999") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"+1.1e-999999999" - dec"+1e-999999999" == dec"1e-1000000000") @with_context (Emax = 999999999, Emin = -999999999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"-1e-999999999" - dec"-1.1e-999999999" == dec"1e-1000000000") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1" - dec"9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1" - dec"-9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9.999e+999999999" - dec"1") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9.999e+999999999" - dec"1") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1" - dec"9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"1" - dec"-9.999e+999999999") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"9.999e+999999999" - dec"1") +@with_context (Emax = 999999999, Emin = -999999999, precision = 3, rounding = RoundingMode{:NearestTiesAway}()) @test_throws(OverflowError, dec"-9.999e+999999999" - dec"1") @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"12345678000" - dec"0" == dec"1.23456780e+10") @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"0" - dec"12345678000" == dec"-1.23456780e+10") @with_context (Emax = 999, Emin = -999, precision = 9, rounding = RoundingMode{:NearestTiesAway}()) @test(dec"1234567800" - dec"0" == dec"1.23456780e+9")