Skip to content

Add tests for vector? and list? #78

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

Merged
merged 4 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/clojure/core_test/list_qmark.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(ns clojure.core-test.list-qmark
(:require [clojure.test :as t :refer [deftest testing is are]]
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))

(when-var-exists clojure.core/list?
(deftest test-list?
(are [expected x] (= expected (list? x))
false [1 2 3]
false (sorted-map :a 1)
false (sorted-set :a)
true '(1 2 3)
false (hash-map :a 1)
false (array-map :a 1)
false (hash-set :a)
false (seq [1 2 3])
false (seq (sorted-map :a 1))
false (seq (sorted-set :a))
false (range 0 10)
false (range)
false nil
false 1
false 1N
false 1.0
false 1.0M
false :a-keyword
false 'a-sym
false "a string"
false \a
false (object-array 3))))
30 changes: 30 additions & 0 deletions test/clojure/core_test/vector_qmark.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(ns clojure.core-test.vector-qmark
(:require [clojure.test :as t :refer [deftest testing is are]]
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))

(when-var-exists clojure.core/vector?
(deftest test-vector?
(are [expected x] (= expected (vector? x))
true [1 2 3]
Copy link
Member

@jeaye jeaye Feb 20, 2025

Choose a reason for hiding this comment

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

I think it'd be good to have a test for map entry here, since it acts like a vector. We can do this by just doing something like (first {:a :b}). In jank, since we don't have map entries, you'll actually just get a vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch. I'll add that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, this is done. Sorry for the delay.

true (first {:a 1}) ; map entries are also vectors
false (sorted-map :a 1)
false (sorted-set :a)
false '(1 2 3)
false (hash-map :a 1)
false (array-map :a 1)
false (hash-set :a)
false (seq [1 2 3])
false (seq (sorted-map :a 1))
false (seq (sorted-set :a))
false (range 0 10)
false (range)
false nil
false 1
false 1N
false 1.0
false 1.0M
false :a-keyword
false 'a-sym
false "a string"
false \a
false (object-array 3))))