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

feature: notation for expected failures #47

Closed
dustingetz opened this issue Mar 9, 2022 · 1 comment
Closed

feature: notation for expected failures #47

dustingetz opened this issue Mar 9, 2022 · 1 comment

Comments

@dustingetz
Copy link
Member

(tests
 (p/run (! (p/for [x ~(m/watch input)] x)))
 % := [1]
 (reset! input [1 2])
 % := [1 2] ;; FAIL
 )

Syntax idea: % := [1 2] :! [1], which indicates desired expectation simultaneously with known current expected error.

Perhaps % :! [1 2] ; [1] is sufficient?

@dustingetz
Copy link
Member Author

This works in master, obviously could be a lot tighter

(defmethod t/assert-expr :hyperfiddle.rcf/fails? [msg form]
  (let [[_= & args] form
        form        (cons ::fails? (map impl/original-form args))]
    `(let [lhs#           (identity ~(first args)) ; (identity …) guards against :clojure.spec.alpha/invalid being passed to `let` macroexpansion
           rhs#           (identity ~(second args))
           [result# env#] (u/unifier* lhs# rhs#)]
       (if (u/failed? env#)
         (do (do-report {:type     :hyperfiddle.rcf/pass
                         :message  ~msg,
                         :expected '~form
                         :actual   result#})
             result#)
         (do (do-report {:type     :hyperfiddle.rcf/fail
                         :message  ~msg,
                         :expected '~form
                         :actual   (u/explain env#)})
             lhs#)))))

image

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