This commit was merged in pull request #17.
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
|
||||
(defn- parse-resource [path]
|
||||
(-> (str "net/deertopia/doerg/element_test/" path)
|
||||
io/resource slurp sut/read-string))
|
||||
io/resource slurp
|
||||
(sut/read-string)))
|
||||
|
||||
(t/deftest known-greater-elements
|
||||
(t/testing "known greater elements satisfy `greater-element?`"
|
||||
@@ -44,32 +45,47 @@
|
||||
true)))
|
||||
|
||||
(t/deftest first-paragraph-under-first-section
|
||||
(t/testing "first paragraph should belong to a section"
|
||||
(t/is (-> (parse-resource "first-paragraph-under-first-section.org")
|
||||
first-paragraph-belongs-to-first-section?))
|
||||
(t/is (not (-> (parse-resource "first-paragraph-under-heading.org")
|
||||
first-paragraph-belongs-to-first-section?)))))
|
||||
(t/is (-> (parse-resource "first-paragraph-under-first-section.org")
|
||||
first-paragraph-belongs-to-first-section?)))
|
||||
|
||||
(defn walk-types [type & types]
|
||||
(t/deftest first-paragraph-under-heading
|
||||
(t/is (-> (parse-resource "first-paragraph-under-heading.org")
|
||||
first-paragraph-belongs-to-first-section?
|
||||
not)))
|
||||
|
||||
(defn- walk-types [type & types]
|
||||
[sut/postorder-walker #(apply sut/of-type? % type types)])
|
||||
|
||||
(defn- paragraph-ends-with-latex? [doc]
|
||||
(let [type (-> (sp/select-first [(walk-types "paragraph")
|
||||
(t/deftest paragraph-ending-with-latex
|
||||
(let [doc (parse-resource "paragraph-ending-with-latex.org")
|
||||
type (-> (sp/select-first [(walk-types "paragraph")
|
||||
(sp/must :children)
|
||||
sp/LAST]
|
||||
doc)
|
||||
sut/type)]
|
||||
(t/is type "latex-environment")))
|
||||
(t/is (= "latex-environment" type))))
|
||||
|
||||
(defn- paragraph-has-latex? [doc]
|
||||
(t/is (sp/select-first [(walk-types "paragraph")
|
||||
(sp/must :children)
|
||||
sp/ALL
|
||||
#(sut/of-type? % "latex-environment")]
|
||||
doc)))
|
||||
(t/deftest paragraph-surrounding-latex
|
||||
(let [doc (parse-resource "paragraph-surrounding-latex.org")
|
||||
children (->> doc
|
||||
(sp/select-first [(walk-types "paragraph")])
|
||||
:children
|
||||
(map sut/type))]
|
||||
(t/is (= ["text" "latex-environment" "text"]
|
||||
children))))
|
||||
|
||||
(defn- paragraph-has-multiple-latex? [doc]
|
||||
(let [paragraphs (sp/select (walk-types "paragraph") doc)]
|
||||
(t/deftest paragraph-ending-in-bold-surrounding-latex
|
||||
(let [doc (parse-resource "paragraph-ending-in-bold-surrounding-latex.org")
|
||||
children (->> doc
|
||||
(sp/select-first [(walk-types "paragraph")])
|
||||
:children
|
||||
(map sut/type))]
|
||||
(t/is (= ["text" "bold" "latex-environment" "text"]
|
||||
children))))
|
||||
|
||||
(t/deftest paragraph-with-multiple-latex
|
||||
(let [doc (parse-resource "paragraph-with-multiple-latex.org")
|
||||
paragraphs (sp/select (walk-types "paragraph") doc)]
|
||||
(t/is (= 2 (count paragraphs)))
|
||||
(let [[p₁ p₂] paragraphs]
|
||||
(doseq [[p ts] [[p₁ ["text" "latex-environment"
|
||||
@@ -79,13 +95,21 @@
|
||||
(t/is (= ts (sp/select [(sp/must :children)
|
||||
sp/ALL (sp/view sut/type)] p)))))))
|
||||
|
||||
(t/deftest paragraph-separation
|
||||
(t/testing "paragraph ending with latex"
|
||||
(-> (parse-resource "paragraph-ending-with-latex.org")
|
||||
paragraph-ends-with-latex?))
|
||||
(t/testing "paragraph surrounding latex"
|
||||
(-> (parse-resource "paragraph-surrounding-latex.org")
|
||||
paragraph-has-latex?))
|
||||
(t/testing "paragraph with interleaved latex"
|
||||
(-> (parse-resource "paragraph-with-multiple-latex.org")
|
||||
paragraph-has-multiple-latex?)))
|
||||
(t/deftest paragraph-with-separate-latex
|
||||
(let [doc (parse-resource "paragraph-with-separate-latex.org")
|
||||
cs (sp/select [(walk-types "section")
|
||||
(sp/must :children)
|
||||
sp/ALL
|
||||
(sp/view sut/type)]
|
||||
doc)]
|
||||
(t/is (= ["paragraph" "latex-environment"] cs))))
|
||||
|
||||
(t/deftest paragraph-surrounding-separate-latex
|
||||
(let [doc (parse-resource "paragraph-surrounding-separate-latex.org")
|
||||
cs (sp/select [(walk-types "section")
|
||||
(sp/must :children)
|
||||
sp/ALL
|
||||
(sp/view sut/type)]
|
||||
doc)]
|
||||
(t/is (= ["paragraph" "latex-environment" "paragraph"] cs))))
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#+title: bold-final paragraph surrounding latex
|
||||
|
||||
first part of *paragraph*
|
||||
\begin{equation*}
|
||||
\text{some \LaTeX \}:)}
|
||||
\end{equation*}
|
||||
last part of paragraph
|
||||
@@ -0,0 +1,9 @@
|
||||
#+title: paragraphs surrounding separate latex
|
||||
|
||||
a paragraph!
|
||||
|
||||
\begin{gather*}
|
||||
\text{and now, an unrelated latex fragment}
|
||||
\end{gather*}
|
||||
|
||||
more unrelated text
|
||||
@@ -0,0 +1,7 @@
|
||||
#+title: paragraph with separate latex
|
||||
|
||||
a paragraph!
|
||||
|
||||
\begin{gather*}
|
||||
\text{and now, an unrelated latex fragment}
|
||||
\end{gather*}
|
||||
Reference in New Issue
Block a user