summaryrefslogtreecommitdiff
path: root/spec/ruby/core/true/singleton_method_spec.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-06-22 09:44:51 -0700
committerJeremy Evans <code@jeremyevans.net>2023-07-26 07:27:15 -0700
commit786a864900ceee6ed89d7df81698bbbe7e7bd6ae (patch)
treeeec3826a102ced34b8e158faa3b48a169124b8da /spec/ruby/core/true/singleton_method_spec.rb
parent9b405a18bea7825cba794e42a1fef58a48451ec3 (diff)
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]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7973
Diffstat (limited to 'spec/ruby/core/true/singleton_method_spec.rb')
-rw-r--r--spec/ruby/core/true/singleton_method_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/true/singleton_method_spec.rb b/spec/ruby/core/true/singleton_method_spec.rb
new file mode 100644
index 0000000000..f765054c5f
--- /dev/null
+++ b/spec/ruby/core/true/singleton_method_spec.rb
@@ -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