Test: defined?(super) in BasicObject returns nil

Ensure it returns `nil` instead of segmentation faulting
This commit is contained in:
Gary Tou 2023-04-25 23:22:48 -04:00 committed by Aaron Patterson
parent 1883dc5bde
commit 5dd46a345a

View File

@ -303,6 +303,20 @@ class TestDefined < Test::Unit::TestCase
assert_equal("super", o.x, bug8367)
end
def test_super_in_basic_object
BasicObject.class_eval do
def a
defined?(super)
end
end
assert_nil(a)
BasicObject.class_eval do
undef_method :a
end
end
def test_super_toplevel
assert_separately([], "assert_nil(defined?(super))")
end