Sha256: 2741d0d0144703f20ad2bd0eb2fb6cc77e94785c9c669572e304fd379b26d290

Contents?: true

Size: 608 Bytes

Versions: 4

Compression:

Stored size: 608 Bytes

Contents

require 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

4 entries across 4 versions & 1 rubygems

Version Path
ruby-mpfr-0.0.7 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.6 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.5 spec/mpfr/comparison_spec.rb
ruby-mpfr-0.0.4 spec/mpfr/comparison_spec.rb