From 4321ec5e39bdb817fbcc61cc40a42b5a23a0a1ce Mon Sep 17 00:00:00 2001 From: Morgan Astra Date: Wed, 14 Nov 2018 12:49:17 -0800 Subject: Update deps to modern versions and remove midje --- test/pronouns/pages_test.clj | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test/pronouns') diff --git a/test/pronouns/pages_test.clj b/test/pronouns/pages_test.clj index 04c14ce..e32a2ee 100644 --- a/test/pronouns/pages_test.clj +++ b/test/pronouns/pages_test.clj @@ -1,10 +1,12 @@ (ns pronouns.pages-test (:require [pronouns.pages :as pages] - [midje.sweet :refer :all])) + [clojure.test :refer [deftest testing is are]])) -(fact "prose-comma-list turns a list of strings into a prose list with commas" - (pages/prose-comma-list ["foo"]) => "foo" - (pages/prose-comma-list ["foo" "bar"]) => "foo and bar" - (pages/prose-comma-list ["foo" "bar" "baz"]) => "foo, bar, and baz" - (pages/prose-comma-list ["foo" "bar" "baz" "bobble"]) => "foo, bar, baz, and bobble" - (pages/prose-comma-list []) => "") +(deftest prose-comma-list + (testing "prose-comma-list turns a list of strings into a prose list" + (are [call result] (= call result) + (pages/prose-comma-list ["foo"]) "foo" + (pages/prose-comma-list ["foo" "bar"]) "foo and bar" + (pages/prose-comma-list ["foo" "bar" "baz"]) "foo, bar, and baz" + (pages/prose-comma-list ["foo" "bar" "baz" "bobble"]) "foo, bar, baz, and bobble" + (pages/prose-comma-list []) ""))) -- cgit From 9a7112784ea22b6c5595bb9879205d073b1c4253 Mon Sep 17 00:00:00 2001 From: Morgan Astra Date: Wed, 14 Nov 2018 13:46:38 -0800 Subject: Add test to catch common errors in pronouns.tab --- test/pronouns/resource_test.clj | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/pronouns/resource_test.clj (limited to 'test/pronouns') 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")))) -- cgit From 2083d66ddb7d34d18eb18b4917265f7d8dfe4a4e Mon Sep 17 00:00:00 2001 From: Morgan Astra Date: Wed, 14 Nov 2018 14:11:18 -0800 Subject: Add tests for table lookup functions --- src/pronouns/util.clj | 2 -- test/pronouns/util_test.clj | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 test/pronouns/util_test.clj (limited to 'test/pronouns') 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 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"])) + -- cgit From 67f0a0768750ff98715a48aefc44f315c4875c8c Mon Sep 17 00:00:00 2001 From: Morgan Astra Date: Wed, 14 Nov 2018 21:47:31 -0800 Subject: Fix ns issues --- project.clj | 2 +- test/pronouns/util_test.clj | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'test/pronouns') diff --git a/project.clj b/project.clj index a3d6bcf..a0f77fd 100644 --- a/project.clj +++ b/project.clj @@ -15,5 +15,5 @@ ;; FIXME morgan.astra <2018-11-14 Wed> ;; Is this production profile used for anything? :profiles {:production {:env {:production true}} - :dev {:dependencies [[ring/ring-devel "1.7.1"]]}} + :test {:dependencies [[ring/ring-devel "1.7.1"]]}} :ring {:handler pronouns.web/app}) diff --git a/test/pronouns/util_test.clj b/test/pronouns/util_test.clj index 031f0f9..3aecc2a 100644 --- a/test/pronouns/util_test.clj +++ b/test/pronouns/util_test.clj @@ -1,9 +1,8 @@ (ns pronouns.util-test (:require [pronouns.util :as util] - [clojure.test :refer [deftest testing is]])) + [clojure.test :refer [deftest testing is are]])) -(def test-table [ - ["ze" "hir" "hir" "hirs" "hirself"] +(def test-table [["ze" "hir" "hir" "hirs" "hirself"] ["ze" "zir" "zir" "zirs" "zirself"] ["she" "her" "her" "hers" "herself"] ["he" "him" "his" "his" "himself"] @@ -12,19 +11,19 @@ (deftest table-filters (testing "table-front-filter" - (are [arg return] (= (table-front-filter arg test-table) return) + (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] (= (table-end-filter arg test-table) return) + (are [arg return] (= (util/table-end-filter arg test-table) return) ["themself"] [["they" "them" "their" "theirs" "themself"]] - ["themselves" [["they" "them" "their" "theirs" "themselves"]]]))) + ["themselves"] [["they" "them" "their" "theirs" "themselves"]]))) (deftest table-lookup - (are [arg return] (= (table-lookup arg test-table) return) + (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"] -- cgit