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.180 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.179 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.178 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.177 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.176 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.175 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.174 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.173 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.172 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.171 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.170 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.169 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.167 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.166 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.165 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.164 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.163 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.162 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.161 tracks/clojure/exercises/strain/test/strain_test.clj
trackler-2.2.1.160 tracks/clojure/exercises/strain/test/strain_test.clj