Skip to content

Commit

Permalink
* Add test case for incorrect order of method overloading
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Oct 9, 2024
1 parent 7ccb491 commit 43457aa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions features/advanced/pattern_matching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,32 @@ Feature: Method Overloading
"""
sound: woof
"""

Scenario: Incorrect Positional Args Method
Given a file named "incorrect_positional_args_method.rb" with:
"""ruby
require "contracts"
C = Contracts
class Example
include Contracts::Core
# Notice that this method's contract is wider than the one below
# This would cause this method to be called every time but never the one below
Contract C::Num => C::Num
def fact(x)
x * fact(x - 1)
end
Contract 1 => 1
def fact(x)
x
end
end
puts Example.new.fact(4)
"""
When I run `ruby incorrect_positional_args_method.rb`
Then the output should contain:
"""
stack level too deep (SystemStackError)
"""

0 comments on commit 43457aa

Please sign in to comment.