Sha256: 065f18e20adb6bb54445000a75743314772486374002b1821b3b7eec05ce97a5
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'test/unit' require 'test/framework' require 'eymiha/units' class TC_unit_equality < Test::Unit::TestCase include UnitsTest def test_unit_equality Units.create :length do |m| m.system :english do |s| s.unit :name => :inch, :plural => :inches, :abbrev => :in s.unit :name => :foot, :plural => :feet, :abbrev => [ :ft ], :equals => 12.inches s.unit :name => :yard, :abbrevs => :yd, :equals => 3.feet 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") a = 12.feet assert(a.numeric == 12) assert(a.unit == {foot => 1}) assert(a.to_s == "12 feet") b = (2.0.ft^2)**0.5 c = 1.4142135623.ft assert(b != c) assert(b =~ c) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eymiha_units-1.0.1 | test/tc_unit_equality.rb |
eymiha_units-1.0.0 | test/tc_unit_equality.rb |