-
Notifications
You must be signed in to change notification settings - Fork 26
Test vec #792
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
Test vec #792
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| (ns clojure.core-test.vec | ||
| (:require [clojure.test :refer [deftest testing is are]] | ||
| [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) | ||
|
|
||
| (when-var-exists vec | ||
| (deftest test-vec | ||
|
|
||
| (testing "vec coll" | ||
| (are [expected coll] (= expected (vec coll)) | ||
| [] nil | ||
| [] '() | ||
| [] [] | ||
| [] #{} | ||
| [] {} | ||
| [] "" | ||
| [nil nil nil] '(nil nil nil) | ||
| [1 2 3] '(1 2 3) | ||
| [1 2 3] [1 2 3] | ||
| [1 2 3] (sorted-set 1 2 3) | ||
| [1 2 3] (range 1 4) | ||
| [[:a 1] [:b 2]] {:a 1 :b 2} | ||
| [\a \b \c] "abc")) | ||
|
|
||
| #?(:cljr "cljr does not alias array" | ||
| :default (testing "array aliasing" | ||
| (let [arr (to-array [1 2 3]), v (vec arr)] | ||
| (is (= [1 2 3] v)) | ||
| (aset arr 0 -1) | ||
| (is (= [-1 2 3] v))))) | ||
|
Comment on lines
+28
to
+29
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small nitpick, even though it's not required, it might be clearer that this mutation and the assertion are related if they were in a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree this mutable code is surprising but I don't see how to test this case differently. I wonder why clj-kondo warns of "redundant do" when adding a I don't see how to apply
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah since you're testing |
||
|
|
||
| (testing "bad shape" | ||
| (are [arg] (thrown? #?(:cljs js/Error :default Exception) (vec arg)) | ||
| 42 | ||
| 3.14 | ||
| true | ||
| :a | ||
| (transient []))))) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very neat test case.