mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
401b64c4e8
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
47 lines
1.9 KiB
Ruby
47 lines
1.9 KiB
Ruby
require_relative '../../spec_helper'
|
|
require 'bigdecimal'
|
|
|
|
describe "BigDecimal#sign" do
|
|
|
|
it "defines several constants for signs" do
|
|
# are these really correct?
|
|
BigDecimal::SIGN_POSITIVE_INFINITE.should == 3
|
|
BigDecimal::SIGN_NEGATIVE_INFINITE.should == -3
|
|
BigDecimal::SIGN_POSITIVE_ZERO.should == 1
|
|
BigDecimal::SIGN_NEGATIVE_ZERO.should == -1
|
|
BigDecimal::SIGN_POSITIVE_FINITE.should == 2
|
|
BigDecimal::SIGN_NEGATIVE_FINITE.should == -2
|
|
end
|
|
|
|
it "returns positive value if BigDecimal greater than 0" do
|
|
BigDecimal("1").sign.should == BigDecimal::SIGN_POSITIVE_FINITE
|
|
BigDecimal("1E-20000000").sign.should == BigDecimal::SIGN_POSITIVE_FINITE
|
|
BigDecimal("1E200000000").sign.should == BigDecimal::SIGN_POSITIVE_FINITE
|
|
BigDecimal("Infinity").sign.should == BigDecimal::SIGN_POSITIVE_INFINITE
|
|
end
|
|
|
|
it "returns negative value if BigDecimal less than 0" do
|
|
BigDecimal("-1").sign.should == BigDecimal::SIGN_NEGATIVE_FINITE
|
|
BigDecimal("-1E-9990000").sign.should == BigDecimal::SIGN_NEGATIVE_FINITE
|
|
BigDecimal("-1E20000000").sign.should == BigDecimal::SIGN_NEGATIVE_FINITE
|
|
BigDecimal("-Infinity").sign.should == BigDecimal::SIGN_NEGATIVE_INFINITE
|
|
end
|
|
|
|
it "returns positive zero if BigDecimal equals positive zero" do
|
|
BigDecimal("0").sign.should == BigDecimal::SIGN_POSITIVE_ZERO
|
|
BigDecimal("0E-200000000").sign.should == BigDecimal::SIGN_POSITIVE_ZERO
|
|
BigDecimal("0E200000000").sign.should == BigDecimal::SIGN_POSITIVE_ZERO
|
|
end
|
|
|
|
it "returns negative zero if BigDecimal equals negative zero" do
|
|
BigDecimal("-0").sign.should == BigDecimal::SIGN_NEGATIVE_ZERO
|
|
BigDecimal("-0E-200000000").sign.should == BigDecimal::SIGN_NEGATIVE_ZERO
|
|
BigDecimal("-0E200000000").sign.should == BigDecimal::SIGN_NEGATIVE_ZERO
|
|
end
|
|
|
|
it "returns BigDecimal::SIGN_NaN if BigDecimal is NaN" do
|
|
BigDecimal("NaN").sign.should == BigDecimal::SIGN_NaN
|
|
end
|
|
|
|
end
|
|
|