babashka/test-resources/lib_tests/com/wsscode/misc/refs_test.cljc
Gabriel Horner 093709386a
Add some additional libraries (#1138)
* Add some additional libraries to test

Also improved docs around add-libtest
Close #1137
Close #1128

* Add method needed for supporting pyramid

Pyramid tests passed locally but that was on jvm

* Remove pyramid tests and do in subsequent PR

* Revert "Add method needed for supporting pyramid"

This reverts commit 4d84a2a2ac.

* Skip exoscale tests for windows since most aren't windows compatible
2022-01-14 14:56:09 +01:00

36 lines
860 B
Clojure

(ns com.wsscode.misc.refs-test
(:require
[clojure.test :refer [deftest is are run-tests testing]]
[com.wsscode.misc.refs :refer [atom?] :as refs]))
(deftest kw-identical?-test
(is (not (refs/kw-identical? :foo :bar)))
(is (not (refs/kw-identical? :foo "foo")))
(is (refs/kw-identical? :foo :foo))
(is (refs/kw-identical? :foo (keyword "foo"))))
(deftest atom?-test
(is (true? (atom? (atom "x"))))
(is (false? (atom? "x"))))
(deftest greset!-test
(let [x (atom nil)]
(refs/greset! x "val")
(is (= @x "val")))
(let [x (volatile! nil)]
(refs/greset! x "val")
(is (= @x "val"))))
(deftest gswap!-test
(let [x (atom 10)]
(refs/gswap! x inc)
(is (= @x 11)))
(let [x (volatile! 10)]
(refs/gswap! x inc)
(is (= @x 11)))
(let [x (volatile! 10)]
(refs/gswap! x + 1 2 3 4 5)
(is (= @x 25))))