Sha256: 805bd8cc4b602b8506be4b0467cc1712a453c1a8e4c7894bbce04cb452703f8a

Contents?: true

Size: 1.48 KB

Versions: 396

Compression:

Stored size: 1.48 KB

Contents

(defmodule strain-tests
  (behaviour ltest-unit)
  (export all))

(include-lib "ltest/include/ltest-macros.lfe")

(deftest empty-keep
  (is-equal () (strain:keep #'under-10?/1 ())))

(deftest keep-everything
  (is-equal '(1 2 3) (strain:keep #'under-10?/1 '(1 2 3))))

(deftest keep-first-last
  (is-equal '(1 3) (strain:keep #'odd?/1 '(1 2 3))))

(deftest keep-nothing
  (is-equal () (strain:keep #'even?/1 '(1 3 5 7))))

(deftest keep-neither-first-nor-last
  (is-equal '(2) (strain:keep #'even?/1 '(1 2 3))))

(deftest keep-strings
  (let ((strs '("apple" "zebra" "banana" "zombies" "cherimoya" "zealot")))
    (is-equal '("zebra" "zombies" "zealot")
              (strain:keep #'starts-with-z?/1 strs))))

(deftest empty-discard
  (is-equal () (strain:discard #'under-10?/1 ())))

(deftest discard-everything
  (is-equal () (strain:discard #'under-10?/1 '(1 2 3))))

(deftest discard-first-and-last
  (is-equal '(2) (strain:discard #'odd?/1 '(1 2 3))))

(deftest discard-nothing
  (is-equal '(1 3 5 7) (strain:discard #'even?/1 '(1 3 5 7))))

(deftest discard-neither-first-nor-last
  (is-equal '(1 3) (strain:discard #'even?/1 '(1 2 3))))

(deftest discard-strings
  (let ((strs '("apple" "zebra" "banana" "zombies" "cherimoya" "zealot")))
    (is-equal '("apple" "banana" "cherimoya")
              (strain:discard #'starts-with-z?/1 strs))))

(defun even? (n) (=:= (rem n 2) 0))

(defun odd? (n) (> (rem n 2) 0))

(defun starts-with-z? (str) (=:= (string:sub_string str 1 1) "z"))

(defun under-10? (n) (< n 10))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.179 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.178 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.177 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.176 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.175 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.174 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.173 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.172 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.171 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.170 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.169 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.167 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.166 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.165 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.164 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.163 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.162 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.161 tracks/lfe/exercises/strain/test/strain-tests.lfe
trackler-2.2.1.160 tracks/lfe/exercises/strain/test/strain-tests.lfe