-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#16] improve test coverage & fix discovered bugs.
- Loading branch information
Showing
29 changed files
with
590 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(ns claro.data.ops.fmap-test | ||
(:require [clojure.test.check :as tc] | ||
[clojure.test.check | ||
[clojure-test :refer [defspec]] | ||
[generators :as gen] | ||
[properties :as prop]] | ||
[clojure.test :refer :all] | ||
[claro.test :as test] | ||
[claro.data :as data] | ||
[claro.data.ops.fmap :as ops] | ||
[claro.engine.fixtures :refer [make-engine]])) | ||
|
||
;; ## Resolvable | ||
|
||
(defrecord Identity [v] | ||
data/Resolvable | ||
(resolve! [_ _] | ||
v)) | ||
|
||
(def gen-nums | ||
(gen/not-empty | ||
(gen/vector | ||
(gen/one-of | ||
[gen/int | ||
(gen/fmap ->Identity gen/int)])))) | ||
|
||
(def gen-op | ||
(gen/elements [vector + hash-set])) | ||
|
||
;; ## Tests | ||
|
||
(defspec t-fmap (test/times 100) | ||
(let [run!! (comp deref (make-engine))] | ||
(prop/for-all | ||
[nums gen-nums, op gen-op] | ||
(let [value (apply ops/fmap op nums)] | ||
(= (apply op (run!! nums)) (run!! value)))))) | ||
|
||
(defspec t-fmap-on (test/times 100) | ||
(let [run!! (comp deref (make-engine))] | ||
(prop/for-all | ||
[nums gen-nums, op gen-op] | ||
(let [value (apply ops/fmap-on #(every? number? %&) op nums)] | ||
(= (apply op (run!! nums)) (run!! value)))))) | ||
|
||
(defspec t-fmap! (test/times 100) | ||
(let [run!! (comp deref (make-engine))] | ||
(prop/for-all | ||
[nums gen-nums, op gen-op] | ||
(let [value (apply ops/fmap! op nums)] | ||
(= (apply op (run!! nums)) (run!! value)))))) |
Oops, something went wrong.