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

Check arity of functions being mocked #433

Merged
merged 4 commits into from
Jan 3, 2018
Merged

Conversation

philomates
Copy link
Collaborator

Addresses #431
For a test like this:

(defn my-inc 
  ([a b] (- (+ a (inc b)) b))
  ([a b c] (- (+ a (inc b)) b))
  ([a b c d & others] 1))

(defn strange-adder [a b]
  (+ (my-inc a) b))

(fact
  (strange-adder 1 2) => 300
  (provided (my-inc 1) => 298))

You will get output like this

FAIL at (aaaaaa_the_basics.clj:292)
You faked #'my-inc with an argument count that doesn't match the function's defined arguements:
Provided 1 argument(s), where valid options are: 2, 3, or 4+ arguments

FAIL at (aaaaaa_the_basics.clj:292)
These calls were not made the right number of times:
    (my-inc 1) [expected at least once, actually never called]

(defn f [n m] 100)
(defn second-arg [a b]
(+ a (f a (g b))))

Copy link
Collaborator Author

@philomates philomates Jan 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug fix of this PR revealed this incorrect test (where f needed to be rebound to something that takes 2 args) :)

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

Successfully merging this pull request may close these issues.

1 participant