Skip to content

Commit

Permalink
feat: add test case showing failure to emit condition information
Browse files Browse the repository at this point in the history
  • Loading branch information
k13gomez committed Dec 21, 2021
1 parent 5098246 commit 4c1fca8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Community
- David Goeke [@dgoeke]
- Dave Dixon [@sparkofreason]
- Baptiste Fontaine [@bfontaine]
- Jose Gomez [@k13gomez]

[@rbrush]: https://github.com/rbrush
[@mrrodriguez]: https://github.com/mrrodriguez
Expand Down
15 changes: 15 additions & 0 deletions src/test/clojure/clara/test_rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,22 @@
(query check-exception))
(is false "Scope binding test is expected to throw an exception.")
(catch Exception e e))]
(is (= {:?w 10, :?t nil}
(-> e (ex-data) :bindings))))))

(deftest test-local-scope-visible-in-test-filter
(let [check-exception (assoc (dsl/parse-query [] [[WindSpeed (= ?w windspeed)]
[Temperature (= ?t temperature)]
[:test (> ?t ?w)]])
:name "my-test-query")]

(let [e (try
(-> (mk-session [check-exception])
(insert (->WindSpeed 10 "MCI") (->Temperature nil "MCI"))
(fire-rules)
(query check-exception))
(is false "Scope binding test is expected to throw an exception.")
(catch Exception e e))]
(is (= {:?w 10, :?t nil}
(-> e (ex-data) :bindings))))))

Expand Down

0 comments on commit 4c1fca8

Please sign in to comment.