Skip to content

Commit 900aad5

Browse files
committed
Add more specs for super call arguments.
1 parent 8fa0d25 commit 900aad5

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

spec/ruby/language/fixtures/super.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,52 @@ def m_modified(a, b, *args)
455455
end
456456
end
457457

458+
module ZSuperWithRestAndPost
459+
class A
460+
def m(*args, a, b)
461+
args
462+
end
463+
464+
def m_modified(*args, a, b)
465+
args
466+
end
467+
end
468+
469+
class B < A
470+
def m(*args, a, b)
471+
super
472+
end
473+
474+
def m_modified(*args, a, b)
475+
args[1] = 14
476+
super
477+
end
478+
end
479+
end
480+
481+
module ZSuperWithRestOthersAndPost
482+
class A
483+
def m(a, *args, b)
484+
args
485+
end
486+
487+
def m_modified(a, *args, b)
488+
args
489+
end
490+
end
491+
492+
class B < A
493+
def m(a, *args, b)
494+
super
495+
end
496+
497+
def m_modified(a, *args, b)
498+
args[1] = 14
499+
super
500+
end
501+
end
502+
end
503+
458504
module ZSuperWithRestReassigned
459505
class A
460506
def a(*args)

spec/ruby/language/super_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ def obj.foobar(array)
293293

294294
it "without explicit arguments passes arguments and rest arguments" do
295295
SuperSpecs::ZSuperWithRestAndOthers::B.new.m(1, 2, 3, 4, 5).should == [3, 4, 5]
296+
SuperSpecs::ZSuperWithRestAndOthers::B.new.m(1, 2).should == []
297+
end
298+
299+
it "without explicit arguments passes arguments, rest arguments, and post arguments" do
300+
SuperSpecs::ZSuperWithRestAndPost::B.new.m(1, 2, 3, 4, 5).should == [1, 2, 3]
301+
SuperSpecs::ZSuperWithRestOthersAndPost::B.new.m(1, 2, 3, 4, 5).should == [2, 3, 4]
302+
SuperSpecs::ZSuperWithRestAndPost::B.new.m(1, 2).should == []
303+
SuperSpecs::ZSuperWithRestOthersAndPost::B.new.m(1, 2).should == []
296304
end
297305

298306
it "without explicit arguments passes arguments and rest arguments including any modifications" do

0 commit comments

Comments
 (0)