contracts.ruby (adit/215) $ cat test.rb
require "contracts"
include Contracts
Contract Num => Num
def incr x
"Sdf"
end
incr(23)
contracts.ruby (adit/215) $ ruby test.rb
/Users/abhargava/contracts.ruby/lib/contracts.rb:45:in `block in <class:Contract>': Contract violation for return value: (ReturnContractError)
Expected: Num,
Actual: "Sdf"
Value guarded in: Object::incr
With Contract: Num => Num
All arguments: [23]
At: test.rb:5
from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `call'
from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `failure_callback'
from /Users/abhargava/contracts.ruby/lib/contracts/call_with.rb:82:in `call_with'
from /Users/abhargava/contracts.ruby/lib/contracts/method_handler.rb:138:in `block in redefine_method'
from test.rb:9:in `<main>'
Output:
cc @waterlink @beezee (for issue #215)