Sha256: e29d6258c1e680b2f8287f94ca6a6c10d0662e82a52f73879410b2d0585bdc8e

Contents?: true

Size: 514 Bytes

Versions: 6

Compression:

Stored size: 514 Bytes

Contents

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require "phys/units"

U = Phys::Unit
Q = Phys::Quantity

RSpec::Matchers.define :be_sfloat_close_to do |y|
  match do |x|
    if x==0 && y==0
      true 
    else
      x = x.to_f
      (x-y).abs/(x.abs+y.abs) < 1.2e-7
    end
  end
end

RSpec::Matchers.define :be_a_quantity_close_to do |expected|
  match do |actual|
    if !(Phys::Quantity===actual && Phys::Quantity===expected)
      false
    else
      actual.close_to(expected,1.2e-7)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
phys-units-0.9.7 spec/helper.rb
phys-units-0.9.6 spec/helper.rb
phys-units-0.9.5 spec/helper.rb
phys-units-0.9.4 spec/helper.rb
phys-units-0.9.3 spec/helper.rb
phys-units-0.9.2 spec/helper.rb