Sha256: 8a134de49a5dd6fabf3cbf9bdbc2bde88521eface7ce0df297b77f389c3b4685

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

require 'test/unit'
require 'test/framework'
require 'units'

class TC_unit_arithmetic < Test::Unit::TestCase
  
  understands UnitsTest

  def test_unit_arithmetic

    Units.create :length do |m|
      m.system :english do |s|
        s.unit :name => :inch,
               :plural => :inches,
               :abbrev => :in
      end
    end
    
    inch = Units.length.english.inch.equals
    assert(inch.to_s == "1 inch")
    assert(inch == 1.inch)
    
    yard = inch*36
    assert(yard.to_s == "36 inches")
    assert(yard == 36.in)

    foot = yard/3
    assert(foot.to_s == "12 inches")
    assert(foot == 12.in)
    
    half_foot = foot-6
    assert(half_foot.to_s == "6 inches")
    assert(half_foot == 6.in)
    
    yard_and_a_half = yard+18
    assert(yard_and_a_half.to_s == "54 inches")
    assert(yard_and_a_half == 54.in)

  end
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eymiha_units-0.1.0 test/tc_unit_arithmetic.rb