Sha256: c84928e8e87d952b0ddf4a2dfe2de772e22d1fd3d6defc3f6f5332d95a8444bb

Contents?: true

Size: 1.22 KB

Versions: 396

Compression:

Stored size: 1.22 KB

Contents

(ns strain-test
  (:require [clojure.test :refer [deftest is]]
            [strain :refer [retain discard]]))

(defn- fn-throw-exception [msg] (fn [& _] (throw (Exception. msg))))

(deftest empty-sequence
  (is (empty? (retain even? '()))))

(deftest empty-retain
  (is (empty? (retain odd? [2 4 6 8 10]))))

(deftest retain-single-element
  (is (= [0] (retain even? [0]))))

(deftest retain-several
  (is (= [1 3 5] (retain odd? (range 6)))))

(deftest retain-everything
  (is (= [2 4 6 8 10] (retain even? [2 4 6 8 10]))))

(deftest retain-strings
  (is (= ["string" "three"] (retain string? ["string" 1 :two "three" ["4"]]))))

(deftest empty-discard
  (is (empty? (discard even? [2 4 6 8 10]))))

(deftest discard-first
  (is (= [1 2] (discard zero? [0 1 2]))))

(deftest discard-last
  (is (= [2 1] (discard zero? [2 1 0]))))

(deftest discard-several
  (is (= [0 2 4] (discard odd? (range 6)))))

(deftest does-not-use-existing-implementations
  (with-redefs [filter  (fn-throw-exception "Implement without filter!")
                remove  (fn-throw-exception "Implement without remove!")
                filterv (fn-throw-exception "Implement without filterv!")]
    (dorun (retain even? (range 10)))
    (dorun (discard even? (range 10)))))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.0.6.0 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.18 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.17 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.16 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.15 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.14 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.13 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.12 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.11 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.10 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.9 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.8 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.7 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.6 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.5 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.4 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.3 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.2 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.1 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.0.5.0 tracks/clojure/exercises/strain/test/strain_test.clj