Skip to content
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

Bugs when DECDIG == uint16_t #202

Open
mrkn opened this issue Nov 18, 2021 · 0 comments
Open

Bugs when DECDIG == uint16_t #202

mrkn opened this issue Nov 18, 2021 · 0 comments

Comments

@mrkn
Copy link
Member

mrkn commented Nov 18, 2021

Some tests fail when DECDIG is uint16_t.

Failure: test_BigDecimal(TestBigDecimal):
  Expected 0.1e1111111111111111112 to be positive infinite.
  <nil> is not true.
/home/mrkn/src/github.com/ruby/bigdecimal/test/lib/core_assertions.rb:504:in `assert'
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:47:in `assert_positive_infinite'
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:86:in `block in test_BigDecimal'
     83:       BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
     84:       BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
     85:       assert_positive_infinite(BigDecimal("Infinity"))
  => 86:       assert_positive_infinite(BigDecimal("1E1111111111111111111"))
     87:       assert_positive_infinite(BigDecimal(" \t\n\r \rInfinity \t\n\r \r"))
     88:       assert_negative_infinite(BigDecimal("-Infinity"))
     89:       assert_negative_infinite(BigDecimal(" \t\n\r \r-Infinity \t\n\r \r"))
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:82:in `save_exception_mode'
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:82:in `test_BigDecimal'
Failure: test_div(TestBigDecimal)
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:956:in `test_div'
     953:     assert_equal(2, BigDecimal("2") / 1)
     954:     assert_equal(-2, BigDecimal("2") / -1)
     955:
  => 956:     assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]')
     957:
     958:     assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]')
     959:
[ruby-core:59365] [#9316]
<0.1486868686869e4> expected but was
<0.14868687e4>

diff:
? 0.1486868686869e4
?          7
?          ??????
Failure: test_power_of_three(TestBigDecimal)
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:1457:in `test_power_of_three'
     1454:   def test_power_of_three
     1455:     x = BigDecimal(3)
     1456:     assert_equal(81, x ** 4)
  => 1457:     assert_equal(1.quo(81), x ** -4)
     1458:     assert_in_delta(1.0/81, x ** -4)
     1459:   end
     1460:
<1/81> expected but was
<0.12345679012345679012345679e-1>

diff:
?   1/8      1
? 0. 23456790 2345679012345679e-1
? ++ ?? +++++++++++++++++++
Failure: test_power_without_prec(TestBigDecimal)
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:1554:in `test_power_without_prec'
     1551:     pi  = BigDecimal("3.14159265358979323846264338327950288419716939937511")
     1552:     e   = BigDecimal("2.71828182845904523536028747135266249775724709369996")
     1553:     pow = BigDecimal("0.2245915771836104547342715220454373502758931513399678438732330680117143493477164265678321738086407229773690574073268002736527e2")
  => 1554:     assert_equal(pow, pi.power(e))
     1555:
     1556:     n = BigDecimal("2222")
     1557:     assert_equal(BigDecimal("0.5171353084572525892492416e12"), (n ** 3.5))
<0.2245915771836104547342715220454373502758931513399678438732330680117143493477164265678321738086407229773690574073268002736527e2> expected but was
<0.2245915771836104547342715220454373502758931513399678438732330680117143493477164265678321738086407229773690574073e2>

diff:
? 0.2245915771836104547342715220454373502758931513399678438732330680117143493477164265678321738086407229773690574073268002736527e2
Error: test_to_f(TestBigDecimal):
  Test::Unit::CoreAssertions::MiniTest::Assertion: 1e-322.
  Exception raised:
  <#<FloatDomainError: BigDecimal to Float conversion>>
  Backtrace:
    /home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:788:in `to_f'
    /home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:788:in `block in test_to_f'
    /home/mrkn/src/github.com/ruby/bigdecimal/test/lib/core_assertions.rb:185:in `assert_nothing_raised'
    /home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:787:in `test_to_f'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testcase.rb:866:in `run_test'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testcase.rb:561:in `block (2 levels) in run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/fixture.rb:276:in `block in create_fixtures_runner'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/fixture.rb:276:in `block in create_fixtures_runner'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/fixture.rb:257:in `run_fixture'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/fixture.rb:292:in `run_setup'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testcase.rb:559:in `block in run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testcase.rb:558:in `catch'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testcase.rb:558:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testsuite.rb:124:in `run_test'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testsuite.rb:53:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testsuite.rb:124:in `run_test'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/testsuite.rb:53:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:67:in `run_suite'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:45:in `block (2 levels) in run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:102:in `with_listener'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:41:in `block in run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:39:in `catch'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnermediator.rb:39:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunner.rb:40:in `start_mediator'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunner.rb:25:in `start'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/ui/testrunnerutilities.rb:24:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/autorunner.rb:458:in `block in run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/autorunner.rb:514:in `change_work_directory'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/autorunner.rb:457:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit/autorunner.rb:66:in `run'
    /home/mrkn/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.5.1/lib/test/unit.rb:518:in `block (2 levels) in <top (required)>'.
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:788:in `to_f'
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:788:in `block in test_to_f'
     785:     assert_raise(FloatDomainError, x) {BigDecimal(x).to_f}
     786:     x = "1e#{Float::MIN_10_EXP - Float::DIG}"
     787:     assert_nothing_raised(FloatDomainError, x) {
  => 788:       assert_in_delta(0.0, BigDecimal(x).to_f, 10**Float::MIN_10_EXP, bug6944)
     789:     }
     790:     x = "-#{x}"
     791:     assert_nothing_raised(FloatDomainError, x) {
/home/mrkn/src/github.com/ruby/bigdecimal/test/lib/core_assertions.rb:185:in `assert_nothing_raised'
/home/mrkn/src/github.com/ruby/bigdecimal/test/bigdecimal/test_bigdecimal.rb:787:in `test_to_f'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant