diff options
Diffstat (limited to 'spec/ruby/language/fixtures/super.rb')
| -rw-r--r-- | spec/ruby/language/fixtures/super.rb | 150 |
1 files changed, 145 insertions, 5 deletions
diff --git a/spec/ruby/language/fixtures/super.rb b/spec/ruby/language/fixtures/super.rb index 09a454bdf4..b6d4218b03 100644 --- a/spec/ruby/language/fixtures/super.rb +++ b/spec/ruby/language/fixtures/super.rb @@ -1,4 +1,4 @@ -module Super +module SuperSpecs module S1 class A def foo(a) @@ -266,7 +266,7 @@ module Super # Use this so that we can see collect all supers that we see. # One bug that arises is that we call Alias2#name from Alias2#name - # as it's superclass. In that case, either we get a runaway recursion + # as its superclass. In that case, either we get a runaway recursion # super OR we get the return value being [:alias2, :alias2, :alias1] # rather than [:alias2, :alias1]. # @@ -282,7 +282,7 @@ module Super # # When name3 is called then, Alias2 (NOT Alias3) is presented as the # current module to Alias2#name, so that when super is called, - # Alias2->superclass is next. + # Alias2's superclass is next. # # Otherwise, Alias2 is next, which is where name was to begin with, # causing the wrong #name method to be called. @@ -377,12 +377,12 @@ module Super end def b - block_ref = lambda { 15 } + block_ref = -> { 15 } [super { 14 }, super(&block_ref)] end def c - block_ref = lambda { 16 } + block_ref = -> { 16 } super(&block_ref) end end @@ -455,12 +455,114 @@ module Super end end + module ZSuperWithRestAndPost + class A + def m(*args, a, b) + args + end + + def m_modified(*args, a, b) + args + end + end + + class B < A + def m(*args, a, b) + super + end + + def m_modified(*args, a, b) + args[1] = 14 + super + end + end + end + + module ZSuperWithRestOthersAndPost + class A + def m(a, *args, b) + args + end + + def m_modified(a, *args, b) + args + end + end + + class B < A + def m(a, *args, b) + super + end + + def m_modified(a, *args, b) + args[1] = 14 + super + end + end + end + + module ZSuperWithRestReassigned + class A + def a(*args) + args + end + end + + class B < A + def a(*args) + args = ["foo"] + + super + end + end + end + + module ZSuperWithRestReassignedWithScalar + class A + def a(*args) + args + end + end + + class B < A + def a(*args) + args = "foo" + + super + end + end + end + module ZSuperWithUnderscores class A def m(*args) args end + def m3(*args) + args + end + + def m4(*args) + args + end + + def m_default(*args) + args + end + + def m_rest(*args) + args + end + + def m_pre_default_rest_post(*args) + args + end + + def m_kwrest(**kw) + kw + end + def m_modified(*args) args end @@ -471,6 +573,30 @@ module Super super end + def m3(_, _, _) + super + end + + def m4(_, _, _, _) + super + end + + def m_default(_ = 0) + super + end + + def m_rest(*_) + super + end + + def m_pre_default_rest_post(_, _, _=:a, _=:b, *_, _, _) + super + end + + def m_kwrest(**_) + super + end + def m_modified(_, _) _ = 14 super @@ -478,6 +604,20 @@ module Super end end + module ZSuperInBlock + class A + def m(arg:) + arg + end + end + + class B < A + def m(arg:) + proc { super }.call + end + end + end + module Keywords class Arguments def foo(**args) |
