diff options
Diffstat (limited to 'spec/ruby')
| -rw-r--r-- | spec/ruby/core/method/unbind_spec.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/core/module/instance_method_spec.rb | 8 | ||||
| -rw-r--r-- | spec/ruby/core/unboundmethod/equal_value_spec.rb | 39 | ||||
| -rw-r--r-- | spec/ruby/core/unboundmethod/shared/to_s.rb | 16 |
4 files changed, 58 insertions, 17 deletions
diff --git a/spec/ruby/core/method/unbind_spec.rb b/spec/ruby/core/method/unbind_spec.rb index cdd3a808f2..bdedd513ce 100644 --- a/spec/ruby/core/method/unbind_spec.rb +++ b/spec/ruby/core/method/unbind_spec.rb @@ -27,8 +27,16 @@ describe "Method#unbind" do @string.should =~ /MethodSpecs::MyMod/ end - it "returns a String containing the Module the method is referenced from" do - @string.should =~ /MethodSpecs::MySub/ + ruby_version_is ""..."3.2" do + it "returns a String containing the Module the method is referenced from" do + @string.should =~ /MethodSpecs::MySub/ + end + end + + ruby_version_is "3.2" do + it "returns a String containing the Module the method is referenced from" do + @string.should =~ /MethodSpecs::MyMod/ + end end end diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb index 30e27bb180..8d006e647e 100644 --- a/spec/ruby/core/module/instance_method_spec.rb +++ b/spec/ruby/core/module/instance_method_spec.rb @@ -45,10 +45,14 @@ describe "Module#instance_method" do @parent_um.inspect.should =~ /\bModuleSpecs::InstanceMeth\b/ @child_um.inspect.should =~ /\bfoo\b/ @child_um.inspect.should =~ /\bModuleSpecs::InstanceMeth\b/ - @child_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + @mod_um.inspect.should =~ /\bbar\b/ @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethMod\b/ - @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + + ruby_version_is ""..."3.2" do + @child_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + @mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/ + end end it "raises a TypeError if the given name is not a String/Symbol" do diff --git a/spec/ruby/core/unboundmethod/equal_value_spec.rb b/spec/ruby/core/unboundmethod/equal_value_spec.rb index b21677687e..036c6b7f8c 100644 --- a/spec/ruby/core/unboundmethod/equal_value_spec.rb +++ b/spec/ruby/core/unboundmethod/equal_value_spec.rb @@ -76,19 +76,38 @@ describe "UnboundMethod#==" do (@identical_body == @original_body).should == false end - it "returns false if same method but one extracted from a subclass" do - (@parent == @child1).should == false - (@child1 == @parent).should == false - end + ruby_version_is ""..."3.2" do + it "returns false if same method but one extracted from a subclass" do + (@parent == @child1).should == false + (@child1 == @parent).should == false + end - it "returns false if same method but extracted from two different subclasses" do - (@child2 == @child1).should == false - (@child1 == @child2).should == false + it "returns false if same method but extracted from two different subclasses" do + (@child2 == @child1).should == false + (@child1 == @child2).should == false + end + + it "returns false if methods are the same but added from an included Module" do + (@includee == @includer).should == false + (@includer == @includee).should == false + end end - it "returns false if methods are the same but added from an included Module" do - (@includee == @includer).should == false - (@includer == @includee).should == false + ruby_version_is "3.2" do + it "returns true if same method but one extracted from a subclass" do + (@parent == @child1).should == true + (@child1 == @parent).should == true + end + + it "returns false if same method but extracted from two different subclasses" do + (@child2 == @child1).should == true + (@child1 == @child2).should == true + end + + it "returns true if methods are the same but added from an included Module" do + (@includee == @includer).should == true + (@includer == @includee).should == true + end end it "returns false if both have same Module, same name, identical body but not the same" do diff --git a/spec/ruby/core/unboundmethod/shared/to_s.rb b/spec/ruby/core/unboundmethod/shared/to_s.rb index 38503c3c60..b92bb0b207 100644 --- a/spec/ruby/core/unboundmethod/shared/to_s.rb +++ b/spec/ruby/core/unboundmethod/shared/to_s.rb @@ -20,12 +20,22 @@ describe :unboundmethod_to_s, shared: true do it "the String shows the method name, Module defined in and Module extracted from" do @from_module.send(@method).should =~ /\bfrom_mod\b/ @from_module.send(@method).should =~ /\bUnboundMethodSpecs::Mod\b/ - @from_method.send(@method).should =~ /\bUnboundMethodSpecs::Methods\b/ + + ruby_version_is ""..."3.2" do + @from_method.send(@method).should =~ /\bUnboundMethodSpecs::Methods\b/ + end end it "returns a String including all details" do - @from_module.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod" - @from_method.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod" + ruby_version_is ""..."3.2" do + @from_module.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod" + @from_method.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Methods(UnboundMethodSpecs::Mod)#from_mod" + end + + ruby_version_is "3.2" do + @from_module.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Mod#from_mod" + @from_method.send(@method).should.start_with? "#<UnboundMethod: UnboundMethodSpecs::Mod#from_mod" + end end it "does not show the defining module if it is the same as the origin" do |
