Sha256: cd38578df094b46c0800a2855d248ebd585428148e0f48590387c2879cac2d55

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "../spec_helper.rb"))

describe MPFR, "when converting to GMP." do
  before(:all) do
    @prec = 128
    MPFR.set_default_prec(@prec)
  end

  it "should return GMP::F objects" do
    n = MPFR.new('1.234')
    n.to_mpf.should be_an_instance_of GMP::F
    n.to_mpf.should == GMP::F.new('1.234')
  end

  it "should return GMP::F objects" do
    n = MPFR.new('3.878')
    n.to_mpz.should be_an_instance_of GMP::Z
    n.to_mpz.should == GMP::Z.new(4)
  end

end

describe GMP, "when converting to MPFR." do

  it "should return MPFR objects." do
    n = GMP::F.new('-87.21')
    n.to_fr.should be_an_instance_of MPFR
    n.to_fr.should == MPFR.new('-87.21')
  end

end

describe MPFR, "when converting by method MPFR." do
  
  it "should return MPFR" do
    n = GMP::F.new('0.0279')
    MPFR(n).should be_an_instance_of MPFR
    MPFR(n, 256).should be_an_instance_of MPFR
    MPFR(n, :RNDD).should be_an_instance_of MPFR
    MPFR(n, 512, :RNDU).should be_an_instance_of MPFR
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-mpfr-0.0.17 spec/gmp/convert_spec.rb
ruby-mpfr-0.0.16 spec/gmp/convert_spec.rb
ruby-mpfr-0.0.15 spec/gmp/convert_spec.rb