Add tests for clojure.core/identity#907
Open
brandoncorrea wants to merge 1 commit into
Open
Conversation
NoahTheDuke
reviewed
Jun 12, 2026
| (deftest test-identity | ||
| (is (NaN? (identity ##NaN))) | ||
| (doseq [value test-vals] | ||
| (is (identical? value (identity value)))))) |
Contributor
There was a problem hiding this comment.
maybe put the value or the type of value as the docstring for the assertion?
Contributor
There was a problem hiding this comment.
on second thought, i don't know if that's required...
Author
There was a problem hiding this comment.
Happy to add docstrings, but my hope is that failing assertion will document the value in the terminal output.
jasalt
reviewed
Jun 13, 2026
| [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) | ||
|
|
||
| ; Values for tests are declared eagerly, instead of using | ||
| ; clojure.test/are. Some dialects evaluate `are` params more |
Contributor
There was a problem hiding this comment.
Huh, where exactly closure.test/are behaves oddly like that? Questioning why that wouldn’t be considered a bug to fix in a dialect (ticket could be linked here).
Author
There was a problem hiding this comment.
Actually, it seems all supported dialects fail the same way in these scenarios: jvm, cljs, cljr, bb, lpy, and phel.
; fails with different object references
(deftest atoms-are=
(are [x] (= x x)
(atom nil)))
; fails with 3 instead of 1 (x referenced 3 times in do block)
(deftest increment-atom
(let [counter (atom 0)]
(are [x] (do x x x)
(swap! counter inc))
(is (= 1 @counter))))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #305.
isvsareAs commented in the code, some dialects seem to evaluate
areparameters more than once, which is problematic for object equality. Test values are declared eagerly and tested usingdoseq/isinstead.##NaN
It turns out that most dialects don't consider
##NaNto be=oridentical?to itself. This case is tested separately withNaN?.