Skip to content

Commit

Permalink
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/mri/ruby/test_comparable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: false
require 'test/unit'
require_relative 'envutil'

class TestComparable < Test::Unit::TestCase
def setup
@@ -18,12 +18,18 @@ def test_equal
assert_equal(true, @o == nil)
cmp->(x) do 1; end
assert_equal(false, @o == nil)
cmp->(x) do nil; end
assert_equal(false, @o == nil)

cmp->(x) do raise NotImplementedError, "Not a RuntimeError" end
assert_raise(NotImplementedError) { @o == nil }
bug7688 = '[ruby-core:51389] [Bug #7688]'
cmp->(x) do raise StandardError, "A standard error should be rescued"; end
warn = /Comparable#== will no more rescue exceptions .+ in the next release/
assert_warn(warn, bug7688) { @o == nil }

bug7688 = 'Comparable#== should not silently rescue' \
'any Exception [ruby-core:51389] [Bug #7688]'
cmp->(x) do raise StandardError end
assert_raise(StandardError, bug7688) { @o == nil }
cmp->(x) do "bad value"; end
assert_raise(ArgumentError, bug7688) { @o == nil }
end

def test_gt

0 comments on commit 568ddd8

Please sign in to comment.