Skip to content

Commit

Permalink
New specs for zsuper with optional arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 19, 2015
1 parent d78025c commit d265a61
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/ruby/language/fixtures/super.rb
Expand Up @@ -370,4 +370,25 @@ def a
end
end

module ZSuperWithOptional
class A
def m(x, y, z)
z
end
end

class B < A
def m(x, y, z = 14)
super
end
end

class C < A
def m(x, y, z = 14)
z = 100
super
end
end
end

end
16 changes: 16 additions & 0 deletions spec/ruby/language/super_spec.rb
Expand Up @@ -166,4 +166,20 @@ def a(arg)
Super::ZSuperWithBlock::B.new.a.should == 14
end

it "passes optional arguments that have a default value" do
Super::ZSuperWithOptional::B.new.m(1, 2).should == 14
end

it "passes optional arguments that have a non-default value" do
Super::ZSuperWithOptional::B.new.m(1, 2, 3).should == 3
end

it "passes optional arguments that have a default value but were modified" do
Super::ZSuperWithOptional::C.new.m(1, 2).should == 100
end

it "passes optional arguments that have a non-default value but were modified" do
Super::ZSuperWithOptional::C.new.m(1, 2, 3).should == 100
end

end
3 changes: 3 additions & 0 deletions spec/truffle/tags/language/super_tags.txt
Expand Up @@ -2,3 +2,6 @@ fails:The super keyword passes along modified rest args when they weren't origin
fails:The super keyword passes along modified rest args when they were originally empty
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method
fails:The super keyword calls method_missing when a superclass method is not found
fails:The super keyword passes optional arguments that have a default value
fails:The super keyword passes optional arguments that have a default value but were modified
fails:The super keyword passes optional arguments that have a non-default value but were modified

1 comment on commit d265a61

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I should have done this.

Please sign in to comment.