basic rendering!
This commit is contained in:
8
doerg/test/net/deertopia/doerg/config_test.clj
Normal file
8
doerg/test/net/deertopia/doerg/config_test.clj
Normal file
@@ -0,0 +1,8 @@
|
||||
(ns net.deertopia.doerg.config-test
|
||||
(:require [net.deertopia.doerg.config :as sut]
|
||||
[clojure.test :as t]
|
||||
[clojure.spec.alpha :as s]))
|
||||
|
||||
(t/deftest default-config-is-config
|
||||
(t/testing "default config is valid"
|
||||
(t/is (s/valid? ::sut/config sut/default))))
|
||||
54
doerg/test/net/deertopia/doerg/element_test.clj
Normal file
54
doerg/test/net/deertopia/doerg/element_test.clj
Normal file
@@ -0,0 +1,54 @@
|
||||
(ns net.deertopia.doerg.element-test
|
||||
(:require [net.deertopia.doerg.element :as sut]
|
||||
[babashka.process :as p]
|
||||
[clojure.test :as t]
|
||||
[clojure.zip :as z]
|
||||
[clojure.java.io :as io]))
|
||||
|
||||
(defn sleep-vs-timeout [& {:keys [sleep timeout]}]
|
||||
(sut/deref-with-timeout
|
||||
(p/process "sleep" (format "%ds" sleep))
|
||||
(* timeout 1000)))
|
||||
|
||||
;; Ideally we would test the following property:
|
||||
;;
|
||||
;; For natural numbers n and m, evaluating the form
|
||||
;; (sut/deref-with-timeout
|
||||
;; (p/process "sleep" (format "%ds" n))
|
||||
;; (* m 1000))
|
||||
;; will throw an exception iff n < m (probably with some margin of
|
||||
;; error lol).
|
||||
;;
|
||||
;; But, this is not something that we want to run dozens-to-hundreds
|
||||
;; of times. }:p
|
||||
|
||||
(t/deftest long-sleep-vs-short-timeout
|
||||
(t/testing "long sleep vs. short timeout"
|
||||
(t/is (thrown-with-msg?
|
||||
Exception #".*timed out.*"
|
||||
(sleep-vs-timeout :sleep 5 :timeout 1)))))
|
||||
|
||||
(t/deftest short-sleep-vs-long-timeout
|
||||
(t/testing "short sleep vs. long timeout"
|
||||
(t/is (instance? babashka.process.Process
|
||||
(sleep-vs-timeout :sleep 1 :timeout 5)))))
|
||||
|
||||
(defn- first-child-of-type [parent type]
|
||||
(some #(and (sut/of-type? % type) %) (:children parent)))
|
||||
|
||||
(t/deftest known-greater-elements
|
||||
(t/testing "known greater elements satisfy `greater-element?`"
|
||||
(let [s (-> "net/deertopia/doerg/element_test/greater-elements.org"
|
||||
io/resource slurp)
|
||||
root (sut/read-string s)
|
||||
section (first-child-of-type root "section")
|
||||
headline (first-child-of-type section "headline")
|
||||
headline-text (first-child-of-type headline "text")
|
||||
paragraph (first-child-of-type section "paragraph")
|
||||
paragraph-text (first-child-of-type paragraph "text")]
|
||||
(t/is (sut/greater-element? root))
|
||||
(t/is (sut/greater-element? section))
|
||||
(t/is (sut/greater-element? headline))
|
||||
(t/is (not (sut/greater-element? headline-text)))
|
||||
(t/is (sut/greater-element? paragraph))
|
||||
(t/is (not (sut/greater-element? paragraph-text))))))
|
||||
@@ -0,0 +1,5 @@
|
||||
#+title: greater elements test
|
||||
|
||||
* a headline/section
|
||||
|
||||
this should be a greater element
|
||||
Reference in New Issue
Block a user