Skip to content

Commit 43457aa

Browse files
committed
* Add test case for incorrect order of method overloading
1 parent 7ccb491 commit 43457aa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

features/advanced/pattern_matching.feature

+29
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,32 @@ Feature: Method Overloading
102102
"""
103103
sound: woof
104104
"""
105+
106+
Scenario: Incorrect Positional Args Method
107+
Given a file named "incorrect_positional_args_method.rb" with:
108+
"""ruby
109+
require "contracts"
110+
C = Contracts
111+
112+
class Example
113+
include Contracts::Core
114+
115+
# Notice that this method's contract is wider than the one below
116+
# This would cause this method to be called every time but never the one below
117+
Contract C::Num => C::Num
118+
def fact(x)
119+
x * fact(x - 1)
120+
end
121+
122+
Contract 1 => 1
123+
def fact(x)
124+
x
125+
end
126+
end
127+
puts Example.new.fact(4)
128+
"""
129+
When I run `ruby incorrect_positional_args_method.rb`
130+
Then the output should contain:
131+
"""
132+
stack level too deep (SystemStackError)
133+
"""

0 commit comments

Comments
 (0)