mirror of
https://github.com/PeterCamilleri/fOOrth
synced 2024-11-16 07:47:56 +01:00
Corrected a bug in converting array to duration.
This commit is contained in:
parent
68de808c3a
commit
80bd492ee3
2 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue