spec/mpfr/allocate_spec.rb in ruby-mpfr-0.0.10 vs spec/mpfr/allocate_spec.rb in ruby-mpfr-0.0.11
- old
+ new
@@ -1,8 +1,8 @@
require File.expand_path(File.dirname(__FILE__)) + '/spec_helper.rb'
-describe MPFR, 'when allocating objects from integer' do
+describe MPFR, 'when allocating objects from numbers' do
it "should equal bignum" do
MPFR.set_default_prec(100)
num = 1
for i in 0..300
num *= 10
@@ -21,25 +21,37 @@
MPFR.new(str).should == MPFR(str)
end
end
+ it "should equal float" do
+ MPFR.set_default_prec(256)
+ error = MPFR.new('1.0e-10')
+ GenerateNumber.float(100) do |f|
+ MPFR.new(f).should == f
+ end
+ end
+
+end
+
+describe MPFR, 'when allocating from objects that is not numbers' do
it "should allocate from string" do
MPFR.set_default_prec(53)
for i in 0..1000
MPFR.new(i.to_s).should == i
end
end
- it "should equal float" do
- MPFR.set_default_prec(256)
- error = MPFR.new('1.0e-10')
- GenerateNumber.float(100) do |f|
- MPFR.new(f).should == f
- end
+ it "should raise error" do
+ lambda { MPFR.new(nil) }.should raise_error
+ lambda { MPFR.new(false) }.should raise_error
+ lambda { MPFR.new([]) }.should raise_error
+ lambda { MPFR.new(:sym) }.should raise_error
end
+end
+describe MPFR, 'when creating new objects' do
it "should duplicate" do
MPFR.set_default_prec(141)
for i in 0..1000
a = rand(10**10)
b = rand(10**50)
@@ -66,8 +78,6 @@
b = MPFR.new(str)
c = a.coerce(str)[0]
b.should == c
end
end
-
end
-