about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMorgan Astra <m@morganastra.me>2018-11-14 14:11:18 -0800
committerMorgan Astra <m@morganastra.me>2018-11-14 14:11:18 -0800
commit2083d66ddb7d34d18eb18b4917265f7d8dfe4a4e (patch)
tree79299cbb1cf24698e5147453374150ed5339963b
parent9a7112784ea22b6c5595bb9879205d073b1c4253 (diff)
Add tests for table lookup functions
-rw-r--r--src/pronouns/util.clj2
-rw-r--r--test/pronouns/util_test.clj33
2 files changed, 33 insertions, 2 deletions
diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj
index fa14698..424e0f1 100644
--- a/src/pronouns/util.clj
+++ b/src/pronouns/util.clj
@@ -17,8 +17,6 @@
 (ns pronouns.util
   (:require [clojure.string :as s]))
 
-(defn print-and-return "for debugging" [x] (println x) x)
-
 (defn slurp-tabfile
   "Read a tabfile from a filesystem <path> as a table"
   [path]
diff --git a/test/pronouns/util_test.clj b/test/pronouns/util_test.clj
new file mode 100644
index 0000000..031f0f9
--- /dev/null
+++ b/test/pronouns/util_test.clj
@@ -0,0 +1,33 @@
+(ns pronouns.util-test
+  (:require [pronouns.util :as util]
+            [clojure.test :refer [deftest testing is]]))
+
+(def test-table [
+                 ["ze" "hir" "hir" "hirs" "hirself"]
+                 ["ze" "zir" "zir" "zirs" "zirself"]
+                 ["she" "her" "her" "hers" "herself"]
+                 ["he" "him" "his" "his" "himself"]
+                 ["they" "them" "their" "theirs" "themselves"]
+                 ["they" "them" "their" "theirs" "themself"]])
+
+(deftest table-filters
+  (testing "table-front-filter"
+    (are [arg return] (= (table-front-filter arg test-table) return)
+      ["she"] [["she" "her" "her" "hers" "herself"]]
+      ["ze"] [["ze" "hir" "hir" "hirs" "hirself"]
+              ["ze" "zir" "zir" "zirs" "zirself"]]
+      ["ze" "zir"] [["ze" "zir" "zir" "zirs" "zirself"]]))
+
+  (testing "table-end-filter"
+    (are [arg return] (= (table-end-filter arg test-table) return)
+      ["themself"] [["they" "them" "their" "theirs" "themself"]]
+      ["themselves" [["they" "them" "their" "theirs" "themselves"]]])))
+
+(deftest table-lookup
+  (are [arg return] (= (table-lookup arg test-table) return)
+    ["she"] ["she" "her" "her" "hers" "herself"]
+    ["ze"] ["ze" "hir" "hir" "hirs" "hirself"]
+    ["ze" "zir"] ["ze" "zir" "zir" "zirs" "zirself"]
+    ["they"] ["they" "them" "their" "theirs" "themselves"]
+    ["they" "..." "themself"] ["they" "them" "their" "theirs" "themself"]))
+