diff --git a/lib/et-orbi/time.rb b/lib/et-orbi/time.rb index cf531e9..5f7a870 100644 --- a/lib/et-orbi/time.rb +++ b/lib/et-orbi/time.rb @@ -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) diff --git a/test/eo_time_test.rb b/test/eo_time_test.rb index c9fc480..a9d5ddb 100644 --- a/test/eo_time_test.rb +++ b/test/eo_time_test.rb @@ -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