summaryrefslogtreecommitdiff
path: root/spec/ruby/library/bigdecimal/inspect_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/bigdecimal/inspect_spec.rb')
-rw-r--r--spec/ruby/library/bigdecimal/inspect_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/library/bigdecimal/inspect_spec.rb b/spec/ruby/library/bigdecimal/inspect_spec.rb
new file mode 100644
index 0000000000..7ce47142b2
--- /dev/null
+++ b/spec/ruby/library/bigdecimal/inspect_spec.rb
@@ -0,0 +1,30 @@
+require_relative '../../spec_helper'
+require 'bigdecimal'
+
+describe "BigDecimal#inspect" do
+
+ before :each do
+ @bigdec = BigDecimal("1234.5678")
+ end
+
+ it "returns String" do
+ @bigdec.inspect.kind_of?(String).should == true
+ end
+
+ it "looks like this" do
+ @bigdec.inspect.should == "0.12345678e4"
+ end
+
+ it "does not add an exponent for zero values" do
+ BigDecimal("0").inspect.should == "0.0"
+ BigDecimal("+0").inspect.should == "0.0"
+ BigDecimal("-0").inspect.should == "-0.0"
+ end
+
+ it "properly cases non-finite values" do
+ BigDecimal("NaN").inspect.should == "NaN"
+ BigDecimal("Infinity").inspect.should == "Infinity"
+ BigDecimal("+Infinity").inspect.should == "Infinity"
+ BigDecimal("-Infinity").inspect.should == "-Infinity"
+ end
+end