Sha256: c4910ac2f4cbf9b1c68769a5c9943ee5dbf07938a9a481bd54f4c608325c3b16
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb')) class TestBigDecimal < Test::Unit::TestCase def setup initialize_context end def test_sign assert_equal -1, BigDecimal.context.sign(BigDecimal('-1.0')) assert_equal -1, BigDecimal.context.sign(BigDecimal('-10.0')) assert_equal -1, BigDecimal.context.sign(BigDecimal('-10E50')) assert_equal -1, BigDecimal.context.sign(BigDecimal('-10E-50')) assert_equal -1, BigDecimal.context.sign(BigDecimal('-723')) assert_equal -1, BigDecimal.context.sign(BigDecimal('-0.0')) assert_equal +1, BigDecimal.context.sign(BigDecimal('+1.0')) assert_equal +1, BigDecimal.context.sign(BigDecimal('+10.0')) assert_equal +1, BigDecimal.context.sign(BigDecimal('+10E50')) assert_equal +1, BigDecimal.context.sign(BigDecimal('+10E-50')) assert_equal +1, BigDecimal.context.sign(BigDecimal('+723')) assert_equal +1, BigDecimal.context.sign(BigDecimal('0.0')) assert_nil BigDecimal.context.sign(BigDecimal.context.nan) end def copy_sign assert_equal -BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('1.23'), -1) assert_equal -BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('1.23'), BigDecimal('-10')) assert_equal -BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('-1.23'), -1) assert_equal -BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('-1.23'), BigDecimal('-10')) assert_equal BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('-1.23'), +1) assert_equal BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('-1.23'), BigDecimal('+10')) assert_equal BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('1.23'), +1) assert_equal BigDecimal('1.23'), BigDecimal.context.copy_sign(BigDecimal('1.23'), BigDecimal('+10')) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flt-1.5.0 | test/test_big_decimal.rb |
flt-1.4.7 | test/test_big_decimal.rb |
flt-1.4.6 | test/test_big_decimal.rb |