We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 73c38b8 commit 6bcd5d9Copy full SHA for 6bcd5d9
1 file changed
test/clojure/core_test/peek.cljc
@@ -0,0 +1,26 @@
1
+(ns clojure.core-test.peek
2
+ (:require [clojure.test :refer [deftest testing is are]]
3
+ [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))
4
+
5
+(when-var-exists clojure.core/peek
6
+ (deftest test-peek
7
8
+ (testing "list"
9
+ (is (nil? (peek '())))
10
+ (is (= :a (peek '(:a :b :c)))))
11
12
+ (testing "vector"
13
+ (is (nil? (peek [])))
14
+ (is (= :c (peek [:a :b :c]))))
15
16
+ (testing "nil"
17
+ (is (nil? (peek nil))))
18
19
+ (testing "bad shape"
20
+ (are [coll] (thrown? #?(:cljs js/Error :default Exception) (peek coll))
21
+ #{1 2 3}
22
+ {:a 1 :b 2}
23
+ (cons 1 '())
24
+ (range 10)
25
+ "str"
26
+ 42))))
0 commit comments