Sha256: 14233208ff5498cdbf2084b0073d5ef5c0497de58ceed965705f22d39a714d6b

Contents?: true

Size: 626 Bytes

Versions: 5

Compression:

Stored size: 626 Bytes

Contents

require File.expand_path(File.dirname(__FILE__)) + '/spec_helper.rb'

MPFR.set_default_prec(256)

def check_comparison(a, b)
  ((a < b) == (MPFR.new(a) < MPFR.new(b))).should be_true
  ((a > b) == (MPFR.new(a) > MPFR.new(b))).should be_true
  ((a == b) == (MPFR.new(a) == MPFR.new(b))).should be_true
end

describe MPFR, "when comparing two numbers" do
  it "should return the same result to built-in Numeric comparison" do
    args = GenerateNumber.float_arguments(2, 1000)
    args += [[0.0, 0.0], [-2.89, -2.89], [5.2, 2.9], [1000, 1000], [8.7, 8.7]]

    args.each do |ary|
      check_comparison(*ary)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-mpfr-0.0.12 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.11 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.10 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.9 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.8 spec/mpfr/comparison_spec.rb