Sha256: abb69b023c88c006601d02577c18175fb2ecf8f5342155ff15c854df07c8444e

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

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

require 'units'

class TC_unit_forward_reference < Test::Unit::TestCase

  understands UnitsTest
  
  def test_unit_forward_reference

    Units.create :length do |m|
      m.system :english do |s|
        s.unit :name => :yard,
               :abbrevs => :yd,
               :equals => 3.feet
        s.unit :name => :foot,
               :plural => :feet,
               :abbrev => [ :ft ],
               :equals => 12.inches
        s.unit :name => :inch,
               :plural => :inches,
               :abbrev => :in
      end
    end
    
    inch = Units.length.english.inch
    foot = Units.length.english.foot
    yard = Units.length.english.yard

    assert(inch.equals.numeric == 1)
    assert(inch.equals.unit == {inch => 1})
    assert(foot.equals.numeric == 12)
    assert(foot.equals.unit == {inch => 1})
    assert(yard.equals.numeric == 36)
    assert(yard.equals.unit == {inch => 1})

    assert(inch.equals.to_s == "1 inch")
    assert(foot.equals.to_s == "12 inches")
    assert(yard.equals.to_s == "36 inches")

  end
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eymiha_units-0.1.0 test/tc_unit_forward_reference.rb