File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns clojure.core-test.pop-bang
2+ (:require [clojure.test :refer [are deftest is testing]]
3+ [clojure.core-test.portability #?(:cljs :refer-macros :default :refer ) [when-var-exists ]]))
4+
5+ (when-var-exists pop!
6+ (deftest test-pop!
7+
8+ (testing " nominal cases"
9+ (are [expected vec] (= expected (persistent! (pop! (transient vec))))
10+ [] [nil ]
11+ [] [1 ]
12+ [1 2 ] [1 2 3 ]
13+ [:c :b ] [:c :b :a ]))
14+
15+ (testing " cannot pop! empty vector"
16+ (is (thrown? #?(:cljs js/Error :default Exception) (pop! (transient [])))))
17+
18+ (testing " cannot pop! after call to persistent!"
19+ (let [t (transient [0 1 ]), _ (persistent! t)]
20+ (is (thrown? #?(:cljs js/Error :cljr Exception :default Error) (pop! t)))))
21+
22+ (testing " bad shapes"
23+ (are [arg] (thrown? #?(:cljs js/Error :default Exception) (pop! arg))
24+ (transient {:a 0 })
25+ (transient #{0 })
26+ [0 ]
27+ '(0 )
28+ #{0 }
29+ (range 3 )
30+ true
31+ false
32+ " s"
33+ 3.14
34+ 42
35+ nil ))))
You can’t perform that action at this time.
0 commit comments