Skip to content

Conversation

@rafonsecad
Copy link
Contributor

closes #201

Copy link
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))

(when-var-exists conj
(deftest test-conj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have a test for adding to the front of an infinite seq. For example (conj (range) -1)) is valid.

(is (= '(\f \e \d \a \b \c) (conj '(\a \b \c) \d \e \f)))
(is (= [[1 2] [3 4] [5 6]] (conj [[1 2] [3 4]] [5 6])))
(is (= {:a 0 :b 1} (conj {:a 0} [:b 1])))
(is (= {:a 0 :b 1} (conj {:a 0} {:b 1})))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing map keys can also be updated. (conj {:a 0} {:a 1}), for example.

(is (thrown? js/Error (conj :a :b)))
(is (thrown? js/Error (conj {:a 0} '(:b 1))))]

:default [(is (thrown? Exception (conj "a" "b")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this one for CLJS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include one because in cljs a character is a string, so the test (is (thrown? js/Error (conj \a \b))) basically covers strings as well. Another test with strings seemed a bit redundant, but I can include it if you want

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

Successfully merging this pull request may close these issues.

clojure.core/conj

2 participants