Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make {Nil,True,False}Class#singleton_method always raise NameError
{Nil,True,False}Class#singleton_methods always returns [] indicating that there are no singleton methods defined, so #singleton_method should be consistent with that. Fixes [Bug #11064]
- Loading branch information
1 parent
9b405a1
commit 786a864
Showing
4 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe "FalseClass#singleton_method" do | ||
ruby_version_is '3.3' do | ||
it "raises regardless of whether FalseClass defines the method" do | ||
proc{false.singleton_method(:foo)}.should raise_error(NameError) | ||
begin | ||
def false.foo; end | ||
proc{false.singleton_method(:foo)}.should raise_error(NameError) | ||
ensure | ||
FalseClass.send(:remove_method, :foo) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe "NilClass#singleton_method" do | ||
ruby_version_is '3.3' do | ||
it "raises regardless of whether NilClass defines the method" do | ||
proc{nil.singleton_method(:foo)}.should raise_error(NameError) | ||
begin | ||
def nil.foo; end | ||
proc{nil.singleton_method(:foo)}.should raise_error(NameError) | ||
ensure | ||
NilClass.send(:remove_method, :foo) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe "TrueClass#singleton_method" do | ||
ruby_version_is '3.3' do | ||
it "raises regardless of whether TrueClass defines the method" do | ||
proc{true.singleton_method(:foo)}.should raise_error(NameError) | ||
begin | ||
def true.foo; end | ||
proc{true.singleton_method(:foo)}.should raise_error(NameError) | ||
ensure | ||
TrueClass.send(:remove_method, :foo) | ||
end | ||
end | ||
end | ||
end |