about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/pronouns/pages_test.clj23
-rw-r--r--test/pronouns/resource_test.clj12
-rw-r--r--test/pronouns/util_test.clj32
3 files changed, 67 insertions, 0 deletions
diff --git a/test/pronouns/pages_test.clj b/test/pronouns/pages_test.clj
new file mode 100644
index 0000000..7563be1
--- /dev/null
+++ b/test/pronouns/pages_test.clj
@@ -0,0 +1,23 @@
+(ns pronouns.pages-test
+  (:require [pronouns.pages :as pages]
+            [clojure.test :refer [deftest testing is are]]))
+
+(deftest prose-comma-list
+  (testing "`prose-comma-list` turns a list of strings into a prose list"
+    (are [v s] (= (pages/prose-comma-list v) s)
+      ["foo" "bar" "baz" "bobble"] "foo, bar, baz, and bobble"
+      ["foo" "bar" "baz"]          "foo, bar, and baz"
+      ["foo" "bar"]                "foo and bar"
+      ["foo"]                      "foo"
+      []                           "")))
+
+(deftest lookup-pronouns
+  (are [pronoun-strs pronouns]
+      (= (pages/lookup-pronouns pronoun-strs)
+         pronouns)
+    ["she/her"]           '(["she" "her" "her" "hers" "herself"])
+    ["she" "they"]        '(["she" "her" "her" "hers" "herself"]
+                            ["they" "them" "their" "theirs" "themselves"])
+    ["she/her" "foo/bar"] '(["she" "her" "her" "hers" "herself"])
+    ["foo/bar"]           '()
+    ["a/b/c/d/e"]         '(("a" "b" "c" "d" "e"))))
diff --git a/test/pronouns/resource_test.clj b/test/pronouns/resource_test.clj
new file mode 100644
index 0000000..38ee4e3
--- /dev/null
+++ b/test/pronouns/resource_test.clj
@@ -0,0 +1,12 @@
+(ns pronouns.resource-test
+  (:require [pronouns.util :as util]
+            [clojure.test :refer [deftest testing is]]))
+
+(deftest valid-pronouns-table
+  (let [table (util/slurp-tabfile "resources/pronouns.tab")]
+    (is table "pronouns.tab exists and is non-empty")
+    (doseq [row table]
+      (is (= (count row) 5)
+          "row has five elements")
+      (is (re-matches #".*sel(f|ves)$" (last row))
+          "final element is reflexive"))))
diff --git a/test/pronouns/util_test.clj b/test/pronouns/util_test.clj
new file mode 100644
index 0000000..3aecc2a
--- /dev/null
+++ b/test/pronouns/util_test.clj
@@ -0,0 +1,32 @@
+(ns pronouns.util-test
+  (:require [pronouns.util :as util]
+            [clojure.test :refer [deftest testing is are]]))
+
+(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] (= (util/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] (= (util/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] (= (util/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"]))
+