Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e078e4e

Browse files
committedMay 26, 2015
Port specs for UnboundMethod and Method
Ported specs for UnboundMethod#super_method and Method#super_method. Like Float#next_float Float#prev_float they were introduced in rubyspec by @jemc but didn't made it into rubinius itself.
1 parent 952991e commit e078e4e

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed
 

Diff for: ‎spec/ruby/core/method/fixtures/classes.rb

+12
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,24 @@ class A
9999
def baz(a, b)
100100
self.class
101101
end
102+
def overridden; end
102103
end
103104

104105
class B < A
106+
def overridden; end
107+
end
108+
109+
module BetweenBAndC
110+
def overridden; end
105111
end
106112

107113
class C < B
114+
include BetweenBAndC
115+
def overridden; end
116+
end
117+
118+
module OverrideAgain
119+
def overridden; end
108120
end
109121

110122
class D

Diff for: ‎spec/ruby/core/method/super_method_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require File.expand_path('../../../spec_helper', __FILE__)
2+
require File.expand_path('../fixtures/classes', __FILE__)
3+
4+
describe "Method#super_method" do
5+
it "returns the method that would be called by super in the method" do
6+
obj = MethodSpecs::C.new
7+
obj.extend MethodSpecs::OverrideAgain
8+
meth = obj.method(:overridden)
9+
10+
s_meth = meth.super_method
11+
s_meth.owner.should == MethodSpecs::C
12+
s_meth.receiver.should == obj
13+
s_meth.name.should == :overridden
14+
15+
ss_meth = meth.super_method.super_method
16+
ss_meth.owner.should == MethodSpecs::BetweenBAndC
17+
ss_meth.receiver.should == obj
18+
ss_meth.name.should == :overridden
19+
20+
sss_meth = meth.super_method.super_method.super_method
21+
sss_meth.owner.should == MethodSpecs::B
22+
sss_meth.receiver.should == obj
23+
sss_meth.name.should == :overridden
24+
end
25+
end

Diff for: ‎spec/ruby/core/unboundmethod/fixtures/classes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ class A
7373
def baz(a, b)
7474
return [__FILE__, self.class]
7575
end
76+
def overriden; end
7677
end
7778

7879
class B < A
80+
def overridden; end
7981
end
8082

8183
class C < B
84+
def overridden; end
8285
end
8386
end

Diff for: ‎spec/ruby/core/unboundmethod/super_method_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require File.expand_path('../../../spec_helper', __FILE__)
2+
require File.expand_path('../fixtures/classes', __FILE__)
3+
4+
describe "UnboundMethod#super_method" do
5+
it "returns the method that would be called by super in the method" do
6+
meth = UnboundMethodSpecs::C.instance_method(:overridden)
7+
meth = meth.super_method
8+
meth.should == UnboundMethodSpecs::B.instance_method(:overridden)
9+
meth = meth.super_method
10+
meth.should == UnboundMethodSpecs::A.instance_method(:overridden)
11+
end
12+
end

Diff for: ‎spec/tags/ruby/core/method/super_method_tags.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails: returns the method that would be called by super in the method
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails: returns the method that would be called by super in the method

0 commit comments

Comments
 (0)
Please sign in to comment.