Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow both type-constaint only and value, to used. #14

Open
oxinabox opened this issue Sep 24, 2019 · 0 comments
Open

Allow both type-constaint only and value, to used. #14

oxinabox opened this issue Sep 24, 2019 · 0 comments

Comments

@oxinabox
Copy link
Owner

this kinda works, but you need to have it ordered right,
and it always prints a warning.


julia> @stub bar
(::Stub{:bar}) (generic function with 1 method)

julia> @expect bar(::Int)=false
false

julia> @expect bar(1)=true    # should not warn
┌ Warning: Expectation already set
│   name = :bar
│   argvals = (1,)
│   sig = (Int64,)
└ @ Main ?:0
true

julia> bar(1)
true

julia> bar(2)
false

julia> @stub foo
(::Stub{:foo}) (generic function with 1 method)

julia> @expect foo(1)=true
true

julia> @expect foo(::Int)=false  # should not warn
┌ Warning: Expectation already set
│   name = :foo
│   argvals = (ExpectationStubs.DoNotCare{Int64}(),)
│   sig = (Int64,)
└ @ Main ?:0
false

julia> foo(1)  # Wrong!
false

It should always prioritize value over type constraint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant