Sha256: 9293eac2031f4f49bf1fa701a611b8bcd1a08c9dc255e381b7d026b73e946231
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'test/unit' require 'test/framework' require 'eymiha/units' class TC_unit_hash < Test::Unit::TestCase include UnitsTest def test_unit_hash Units.create :length do |m| m.system :english do |s| s.unit :name => :inch, :plural => :inches, :abbrev => :in end end Units.create :mass do |m| m.system :english do |s| s.unit :name => :pound, :abbrev => :lb end end Units.create :time do |m| m.system :english do |s| s.unit :name => :second, :abbrev => :s end end nwu1 = 2.inches u1 = (Units.lookup :inch)[0] nwu2 = 3.pounds u2 = (Units.lookup :pound)[0] nwu3 = 5.seconds u3 = (Units.lookup :second)[0] assert(nwu1.unit == nwu1.unit.clone) nwu1.unit.merge! nwu2 assert(nwu1.unit.size == 2) assert(nwu1.unit[u1] == 1) assert(nwu1.unit[u2] == 1) nwu1.unit.merge! nwu3,-2 assert(nwu1.unit.size == 3) assert(nwu1.unit[u1] == 1) assert(nwu1.unit[u2] == 1) assert(nwu1.unit[u3] == -2) nwu1.unit.merge! nwu2,-1 assert(nwu1.unit.size == 2) assert(nwu1.unit[u1] == 1) assert(nwu1.unit[u3] == -2) unit1 = nwu1.unit**2 assert(unit1.size == 2) assert(unit1[u1] == 2) assert(unit1[u3] == -4) unit2 = UnitsHash.new(unit1,2) assert(unit2.size == 2) assert(unit2[u1] == 4) assert(unit2[u3] == -8) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eymiha_units-1.0.0 | test/tc_unit_hash.rb |
eymiha_units-1.0.1 | test/tc_unit_hash.rb |