Corrected a bug in converting array to duration.

This commit is contained in:
Peter Camilleri 2015-07-11 22:49:51 -04:00
parent 68de808c3a
commit 80bd492ee3
2 changed files with 7 additions and 2 deletions

View file

@ -90,6 +90,11 @@ class TimeLibraryTester < Minitest::Test
foorth_raises('[ 1 1 1 1 1 1 1 ] .to_duration!')
foorth_raises('[ 1 "apple" 1 1 ] .to_duration!')
foorth_equal('[ 2.5 ] .to_duration', [XfOOrth::Duration.new( (2.5).to_r)])
foorth_equal('[ 2.5 0 ] .to_duration', [XfOOrth::Duration.new( 150.to_r)])
foorth_equal('[ 2.5 0 0 ] .to_duration', [XfOOrth::Duration.new( 9000.to_r)])
foorth_equal('[ 2.5 0 0 0 ] .to_duration', [XfOOrth::Duration.new( 216000.to_r)])
end
def test_converting_from_a_duration

View file

@ -85,7 +85,7 @@ module XfOOrth
begin
result, interval = 0, Duration::Intervals.reverse_each
self.reverse_each {|value| result += value * interval.next }
vm.push(result)
vm.push(Duration.new(result))
rescue
vm.push(nil)
end
@ -95,7 +95,7 @@ module XfOOrth
begin
result, interval = 0, Duration::Intervals.reverse_each
self.reverse_each {|value| result += value * interval.next }
vm.push(result)
vm.push(Duration.new(result))
rescue
error "F40: Cannot convert #{self.to_s} to a Duration instance"
end