Sha256: c9393f62edad1e200cb081c9029387e3dec48914aed3580bd68594a660df697b
Contents?: true
Size: 917 Bytes
Versions: 396
Compression:
Stored size: 917 Bytes
Contents
(ns accumulate-test (:require [clojure.test :refer [deftest is]] accumulate)) (defn- square [n] (* n n)) (defn- to-s [xs] (apply str xs)) (deftest empty-accumulation (is (= [] (accumulate/accumulate square [])))) (deftest accumulate-squares (is (= [1 4 9] (accumulate/accumulate square [1 2 3])))) (deftest accumulate-upcases (is (= ["HELLO", "WORLD"] (->> ["hello" "world"] (accumulate/accumulate clojure.string/upper-case) (map to-s))))) (deftest accumulate-reversed-strings (is (= ["eht" "kciuq" "nworb" "xof" "cte"] (->> ["the" "quick" "brown" "fox" "etc"] (accumulate/accumulate reverse) (map to-s))))) (deftest accumulate-recursively (is (= [["a1" "a2" "a3"] ["b1" "b2" "b3"] ["c1" "c2" "c3"]] (-> #(accumulate/accumulate (fn [n] (str % n)) [1 2 3]) (accumulate/accumulate "abc")))))
Version data entries
396 entries across 396 versions & 1 rubygems