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.2.1.159 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.158 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.157 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.156 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.155 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.154 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.153 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.152 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.151 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.150 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.149 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.148 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.147 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.146 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.145 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.144 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.143 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.142 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.141 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.140 tracks/clojure/exercises/strain/test/strain_test.clj