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

Failed prerequisites with wrong lazy sequence does not print out the lazy sequence #464

Open
dfbernal opened this issue Jul 25, 2019 · 2 comments

Comments

@dfbernal
Copy link

dfbernal commented Jul 25, 2019

When evaluating a prerequisite that expects a certain lazy sequence Midje correctly fails when the lazy sequence does not match the expectation but does not return what the lazy sequence was. The following code demonstrates this:

(defn bar [lst]
  nil)

(defn foo []
  (bar (map #(hash-map :n %) [1 2])))

(fact "test"
  (foo) => [4 5]
  (provided (bar [1 2]) => [4 5]))

And the output is:

FAIL at (core.clj:10)
You never said #'bar would be called with these arguments:
    ["<an unrealized lazy sequence>"]

FAIL at (core.clj:10)
These calls were not made the right number of times:
    (bar [1 2]) [expected at least once, actually never called]

FAIL test at (core.clj:9)
Expected:
[4 5]
Actual:
"`bar` returned this string because it was called with an unexpected argument"

It would be very useful to see what the called parameters were instead of having the test output indicate that it was an unrealized lazy sequence. It would help when debugging since it allows you to see what the code was sending to the prerequisite.

@philomates
Copy link
Collaborator

Hi @dfbernal,

you mean you'd like to see

You never said #'bar would be called with these arguments:
    [({:n 1} {:n 2})]

instead of the following?

You never said #'bar would be called with these arguments:
    ["<an unrealized lazy sequence>"]

In theory we can do this, but it would mean evaluating the lazy-sequence. Since I didn't write the code that chose to print the "<an unrealized lazy sequence>" message, I don't know what trade-offs were weighed when deciding to avoid evaluating the lazy seq. @marick can you recall the details of this decision?

@dfbernal
Copy link
Author

dfbernal commented Aug 19, 2019

Yes, exactly. That's the feature I'd like to see if possible. It would keep me from using mapv when debugging tests 😃

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

2 participants