Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
gigasquid committed Feb 1, 2019
1 parent 32c9bfe commit a5db1f2
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,24 @@
(deftest test-list-creation-with-return-a-copy-of-first
(let [native-resources (atom {})
return-val (resource-scope/using
(let [temp-ndarrays (mapv (constantly (ndarray/ones [3 1])) (range 5))
(let [temp-ndarrays (repeatedly 3 #(ndarray/ones [3 1]))
_ (swap! native-resources assoc :temp-ndarrays temp-ndarrays)]
(ndarray/copy (first temp-ndarrays))))]
(is (false? (ndarray/is-disposed return-val)))
(is (every? true? (mapv ndarray/is-disposed (:temp-ndarrays @native-resources))))))

;;; If you don't assign them all to a let vector binding and just return the first
;; then they are disposed as usual
(deftest test-list-creation-with-return-a-copy-of-first
(let [native-resources (atom [])
return-val (resource-scope/using
(first (repeatedly 5 #(do
(let [x (ndarray/ones [3 1])]
(swap! native-resources conj x)
x)))))]
(is (false? (ndarray/is-disposed return-val)))
(is (every? true? (mapv ndarray/is-disposed (:temp-ndarrays @native-resources))))))

(deftest test-with-let
(let [native-resources (atom {})
x (ndarray/ones [2 2])
Expand Down

0 comments on commit a5db1f2

Please sign in to comment.