Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/et-orbi/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def strfz(code)

def _to_f(o)

fail ArgumentError(
fail ArgumentError.new(
"Comparison of EoTime with #{o.inspect} failed"
) unless o.respond_to?(:to_f)

Expand Down
13 changes: 13 additions & 0 deletions test/eo_time_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,19 @@
assert t0.send(comparator, t1), asserted
end
end

test 'rejects unsupported comparison operands with ArgumentError' do

ot = EtOrbi::EoTime.new(0, 'UTC')
operand = Object.new

[ :<, :<=, :>, :>=, :<=> ].each do |comparator|

assert_error(
lambda { ot.send(comparator, operand) },
ArgumentError)
end
end
end
end