<=> operator should return nil when invoked with an incomparable object (#38772).

Patch by Go MAEDA.


git-svn-id: https://svn.redmine.org/redmine/trunk@22269 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2023-06-29 14:42:54 +00:00
parent ebf3fb3b4f
commit 945a82b5c0
16 changed files with 45 additions and 13 deletions

View File

@@ -179,4 +179,10 @@ class EnumerationTest < ActiveSupport::TestCase
override.destroy
assert_equal [1, 2, 3], [a, b, c].map(&:reload).map(&:position)
end
def test_spaceship_operator_with_incomparable_value_should_return_nil
e = Enumeration.first
assert_nil e <=> nil
assert_nil e <=> 'foo'
end
end