# HG changeset patch # User Zachary Kanfer # Date 1506701384 14400 # Fri Sep 29 12:09:44 2017 -0400 # Node ID 57c7cab432b4010f4c04e7c4db77ebbbb19ebe83 # Parent 9fa0834d7130a529d11c91e7c2277734cb4902fe fix a bunch of tests that apparently I forgot to fix upon updating org-parser diff --git a/tests.el b/tests.el --- a/tests.el +++ b/tests.el @@ -39,18 +39,18 @@ (ert-deftest make-top-level-slide/title-has-type-title () - (should (equal (gethash :type (zpresent--make-top-level-slide (car (org-parser-parse-string "* title\n:PROPERTIES:\n:type: title\n:END:\n")))) + (should (equal (gethash :type (zpresent--make-top-level-slide (car (gethash :content (org-parser-parse-string "* title\n:PROPERTIES:\n:type: title\n:END:\n"))))) :title))) (ert-deftest make-top-level-slide/title-has-type-normal () - (should (equal (gethash :type (zpresent--make-top-level-slide (car (org-parser-parse-string "* title\n:")))) + (should (equal (gethash :type (zpresent--make-top-level-slide (car (gethash :content (org-parser-parse-string "* title\n:"))))) :normal))) (ert-deftest make-following-slide/original-slide-not-updated () (let* ((original-slide (zpresent--make-slide "I'm the title!")) (original-copy (copy-hash-table original-slide)) - (new-slide (zpresent--make-following-slide original-slide (car (org-parser-parse-string "* New body text.")) 1 0))) + (new-slide (zpresent--make-following-slide original-slide (car (gethash :content (org-parser-parse-string "* New body text."))) 1 0))) (dolist (key (hash-table-keys original-slide)) (should (equal (gethash key original-slide) (gethash key original-copy)))) @@ -59,64 +59,64 @@ (ert-deftest make-following-slide/check-title () (let* ((original-slide (zpresent--make-slide "I'm the title!")) - (new-slide (zpresent--make-following-slide original-slide (car (org-parser-parse-string "* New body text.")) 1 0))) + (new-slide (zpresent--make-following-slide original-slide (car (gethash :content (org-parser-parse-string "* New body text."))) 1 0))) (should (equal "I'm the title!" (gethash :title new-slide))))) (ert-deftest make-following-slide/check-new-body () (let* ((original-slide (zpresent--make-slide "I'm the title!")) - (new-slide (zpresent--make-following-slide original-slide (car (org-parser-parse-string "* New body text.")) 1 0))) + (new-slide (zpresent--make-following-slide original-slide (car (gethash :content (org-parser-parse-string "* New body text."))) 1 0))) (should (equal '((" ▸ " "New body text.")) (gethash :body new-slide))))) (ert-deftest make-following-slide/check-added-body () (let* ((original-slide (zpresent--make-slide "I'm the title!" "Initial body.")) - (new-slide (zpresent--make-following-slide original-slide (car (org-parser-parse-string "* New body text.")) 1 0))) + (new-slide (zpresent--make-following-slide original-slide (car (gethash :content (org-parser-parse-string "* New body text."))) 1 0))) (should (equal '("Initial body." (" ▸ " "New body text.")) (gethash :body new-slide))))) (ert-deftest make-following-slide/with-explicit-parent () (let* ((original-slide (zpresent--make-slide "I'm the title!" "Initial body.")) (new-slide (zpresent--make-following-slide original-slide - (car (org-parser-parse-string "* New body text.")) + (car (gethash :content (org-parser-parse-string "* New body text."))) 1 0 - (car (org-parser-parse-string "* fake parent\n:PROPERTIES:\n:child-bullet-type: .\n:END:"))))) + (car (gethash :content (org-parser-parse-string "* fake parent\n:PROPERTIES:\n:child-bullet-type: .\n:END:")))))) (should (equal '("Initial body." (" 1. " "New body text.")) (gethash :body new-slide))))) (ert-deftest extract-current-text/simple-headline () (should (equal '(("simple headline")) - (zpresent--extract-current-text (car (org-parser-parse-string "* simple headline")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string "* simple headline"))))))) (ert-deftest extract-current-text/nested-headline () (should (equal '(("nested headline")) - (zpresent--extract-current-text (car (org-parser-parse-string "** nested headline")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string "** nested headline"))))))) (ert-deftest extract-current-text/simple-headline-with-multiple-line-body () (should (equal '(("nested headline") ("with body") ("over multiple lines")) - (zpresent--extract-current-text (car (org-parser-parse-string "** nested headline\nwith body\nover multiple lines")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string "** nested headline\nwith body\nover multiple lines"))))))) (ert-deftest extract-current-text/simple-plain-list () (should (equal '(("simple plain list")) - (zpresent--extract-current-text (car (org-parser-parse-string "- simple plain list")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string "- simple plain list"))))))) (ert-deftest extract-current-text/nested-plain-list () (should (equal '(("nested plain list")) - (zpresent--extract-current-text (car (org-parser-parse-string " - nested plain list")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string " - nested plain list"))))))) (ert-deftest extract-current-text/simple-plain-list-with-multiple-line-body () (should (equal '(("nested plain list") ("with body") ("over multiple lines")) - (zpresent--extract-current-text (car (org-parser-parse-string " - nested plain list\nwith body\nover multiple lines")))))) + (zpresent--extract-current-text (car (gethash :content (org-parser-parse-string " - nested plain list\nwith body\nover multiple lines"))))))) (ert-deftest make-body/simple-headline () (should (equal '((" ▸ " "headline")) - (zpresent--make-body (car (org-parser-parse-string "* headline")) 1 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "* headline"))) 1 0)))) (ert-deftest make-body/link-in-headline () - (let ((body (zpresent--make-body (car (org-parser-parse-string "* headline [[http://example.com][with link]] in it")) 1 0))) + (let ((body (zpresent--make-body (car (gethash :content (org-parser-parse-string "* headline [[http://example.com][with link]] in it"))) 1 0))) (should (equal 1 (length body))) (let ((title-line (first body))) (should (equal 4 (length title-line))) @@ -130,7 +130,7 @@ (should (equal " in it" (fourth title-line)))))) (ert-deftest make-body/link-in-headline-with-body () - (let ((body (zpresent--make-body (car (org-parser-parse-string "* headline [[http://example.com][with link]] in it\nand now a body [[http://example.com][with a link!]]\nwith two parts")) 1 0))) + (let ((body (zpresent--make-body (car (gethash :content (org-parser-parse-string "* headline [[http://example.com][with link]] in it\nand now a body [[http://example.com][with a link!]]\nwith two parts"))) 1 0))) (should (equal 3 (length body))) (cl-multiple-value-bind (first-line second-line third-line) body @@ -158,49 +158,49 @@ (ert-deftest make-body/indented-headline () (should (equal '((" ▸ " "my headline")) - (zpresent--make-body (car (org-parser-parse-string "** my headline")) 2 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "** my headline"))) 2 0)))) (ert-deftest make-body/plain-list () (should (equal '((" " "a plain list")) - (zpresent--make-body (car (org-parser-parse-string "- a plain list")) 1 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "- a plain list"))) 1 0)))) (ert-deftest make-body/indented-plain-list () (should (equal '((" " "in too deep")) - (zpresent--make-body (car (org-parser-parse-string " - in too deep")) 2 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string " - in too deep"))) 2 0)))) (ert-deftest make-body/two-line-headline () (should (equal '((" ▸ " "top headline") (" " "on two lines")) - (zpresent--make-body (car (org-parser-parse-string "* top headline\non two lines")) 2 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "* top headline\non two lines"))) 2 0)))) (ert-deftest make-body/ignores-children () (should (equal '((" ▸ " "headline")) - (zpresent--make-body (car (org-parser-parse-string "* headline\n** I'm nested, you guys!")) 1 0)))) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "* headline\n** I'm nested, you guys!"))) 1 0)))) (ert-deftest make-body/two-line-headline-not-at-top () (should (equal '((" ▸ " "headline") (" " "on two lines")) - (zpresent--make-body (car (gethash :children (car (org-parser-parse-string "* top\n** headline\non two lines")))) 2 0)))) + (zpresent--make-body (car (gethash :children (car (gethash :content (org-parser-parse-string "* top\n** headline\non two lines"))))) 2 0)))) (ert-deftest make-body/ordered-list-first-item () (should (equal '((" 1. " "First stuff")) - (zpresent--make-body (first (gethash :children (car (org-parser-parse-string "* top\n1. First stuff\n2. Other stuff\n")))) + (zpresent--make-body (first (gethash :children (car (gethash :content (org-parser-parse-string "* top\n1. First stuff\n2. Other stuff\n"))))) 1 0)))) (ert-deftest make-body/ordered-list-because-of-parent-properties () (should (equal '((" 2. " "Other stuff")) - (zpresent--make-body (car (org-parser-parse-string "* Other stuff")) + (zpresent--make-body (car (gethash :content (org-parser-parse-string "* Other stuff"))) 1 1 - (car (org-parser-parse-string "* whatever\n:PROPERTIES:\n:child-bullet-type: .\n:END:")))))) + (car (gethash :content (org-parser-parse-string "* whatever\n:PROPERTIES:\n:child-bullet-type: .\n:END:"))))))) (ert-deftest make-body/ordered-list-second-item () (should (equal '((" 2. " "Other stuff")) - (zpresent--make-body (second (gethash :children (car (org-parser-parse-string "* top\n1. First stuff\n2. Other stuff\n")))) + (zpresent--make-body (second (gethash :children (car (gethash :content (org-parser-parse-string "* top\n1. First stuff\n2. Other stuff\n"))))) 1 1)))) (ert-deftest make-body/block () - (let ((body (zpresent--make-body (first (gethash :children (car (org-parser-parse-string "* whatever\n** nested -- this causes an error!\n#+BEGIN_SRC emacs-lisp\n (format \"hi %s\"\n \"mom\")\n#+END_SRC")))) + (let ((body (zpresent--make-body (first (gethash :children (car (gethash :content (org-parser-parse-string "* whatever\n** nested -- this causes an error!\n#+BEGIN_SRC emacs-lisp\n (format \"hi %s\"\n \"mom\")\n#+END_SRC"))))) 2 0))) (should (equal 2 (length body))) @@ -217,90 +217,90 @@ (ert-deftest get-bullet-type/regular-asterisk () (should (equal ?* - (zpresent--get-bullet-type (car (org-parser-parse-string "* whatever")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* whatever"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/regular-paren () (should (equal ?\) - (zpresent--get-bullet-type (car (org-parser-parse-string "1) whatever")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "1) whatever"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/regular-period () (should (equal ?. - (zpresent--get-bullet-type (car (org-parser-parse-string "1. whatever")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "1. whatever"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/asterisk-property () (should (equal ?* - (zpresent--get-bullet-type (car (org-parser-parse-string "* whatever")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* whatever"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/paren-property () (should (equal ?\) - (zpresent--get-bullet-type (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:END:")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:END:"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/period-property () (should (equal ?. - (zpresent--get-bullet-type (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:")) - (car (org-parser-parse-string "* whatever")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:"))) + (car (gethash :content (org-parser-parse-string "* whatever"))))))) (ert-deftest get-bullet-type/no-bullet-type-parent-with-child-type () (should (equal ?. - (zpresent--get-bullet-type (car (org-parser-parse-string "* whatever")) - (car (org-parser-parse-string "* top\n:PROPERTIES:\n:child-bullet-type: .\n:bullet-type: )\n:END:")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* whatever"))) + (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:child-bullet-type: .\n:bullet-type: )\n:END:"))))))) (ert-deftest get-bullet-type/no-bullet-type-parent-with-no-child-type () (should (equal ?* - (zpresent--get-bullet-type (car (org-parser-parse-string "* whatever")) - (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* whatever"))) + (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:"))))))) (ert-deftest get-bullet-type/bullet-type-parent-with-child-type () (should (equal ?. - (zpresent--get-bullet-type (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:child-bullet-type: )\n:END:")) - (car (org-parser-parse-string "- top\n:PROPERTIES:\n:child-bullet-type: *\n:END:")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:child-bullet-type: )\n:END:"))) + (car (gethash :content (org-parser-parse-string "- top\n:PROPERTIES:\n:child-bullet-type: *\n:END:"))))))) (ert-deftest get-bullet-type/bullet-type-parent-with-no-child-type () (should (equal ?\) - (zpresent--get-bullet-type (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:child-bullet-type: .\n:END:")) - (car (org-parser-parse-string "- top\n:PROPERTIES:\n:bullet-type: .\n:END:")))))) + (zpresent--get-bullet-type (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:child-bullet-type: .\n:END:"))) + (car (gethash :content (org-parser-parse-string "- top\n:PROPERTIES:\n:bullet-type: .\n:END:"))))))) (ert-deftest format-bullet/headline () (should (equal "▸" - (zpresent--format-bullet (car (org-parser-parse-string "* headline")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "* headline"))) 0)))) (ert-deftest format-bullet/paren-ordered-list () (should (equal "1)" - (zpresent--format-bullet (car (org-parser-parse-string "12) headline")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "12) headline"))) 0)))) (ert-deftest format-bullet/paren-ordered-list-set-by-parent () (should (equal "12)" - (zpresent--format-bullet (car (org-parser-parse-string "* headline")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "* headline"))) 11 - (car(org-parser-parse-string "* headline\n:PROPERTIES:\n:child-bullet-type: )\n:END:")))))) + (car (gethash :content (org-parser-parse-string "* headline\n:PROPERTIES:\n:child-bullet-type: )\n:END:"))))))) (ert-deftest format-bullet/dot-ordered-list () (should (equal "12." - (zpresent--format-bullet (car (org-parser-parse-string "3. headline")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "3. headline"))) 11)))) (ert-deftest format-bullet/headline-property () (should (equal "▸" - (zpresent--format-bullet (car (org-parser-parse-string "* headline")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "* headline"))) 0)))) (ert-deftest format-bullet/paren-ordered-list-property () (should (equal "4)" - (zpresent--format-bullet (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:END:")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: )\n:END:"))) 3)))) (ert-deftest format-bullet/dot-ordered-list-property () (should (equal "2." - (zpresent--format-bullet (car (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:")) + (zpresent--format-bullet (car (gethash :content (org-parser-parse-string "* top\n:PROPERTIES:\n:bullet-type: .\n:END:"))) 1)))) @@ -1137,61 +1137,61 @@ (ert-deftest format/ordered-lists-start-at-1 () (should (equal '(" 1. " "first child.") - (first (gethash :body (first (zpresent--format (org-parser-parse-string "* top\n1. first child.\n2. second child.")))))))) + (first (gethash :body (first (zpresent--format (gethash :content (org-parser-parse-string "* top\n1. first child.\n2. second child."))))))))) (ert-deftest format/ordered-list-second-item-is-2 () (should (equal '(" 2. " "second child.") - (second (gethash :body (first (zpresent--format (org-parser-parse-string "* top\n1. first child.\n2. second child.")))))))) + (second (gethash :body (first (zpresent--format (gethash :content (org-parser-parse-string "* top\n1. first child.\n2. second child."))))))))) (ert-deftest format/nested-ordered-lists-start-at-1 () (should (equal '(" 1. " "first double-nested child.") - (second (gethash :body (first (zpresent--format (org-parser-parse-string "* top\n1. first nested list.\n 1. first double-nested child.\n 2. second double-nested child.")))))))) + (second (gethash :body (first (zpresent--format (gethash :content (org-parser-parse-string "* top\n1. first nested list.\n 1. first double-nested child.\n 2. second double-nested child."))))))))) (ert-deftest format/nested-ordered-lists-second-item-is-2 () (should (equal '(" 2. " "second double-nested child.") - (third (gethash :body (fourth (zpresent--format (org-parser-parse-string "* top :slide:\n1. first nested list. :slide:\n 1. first double-nested child. :slide:\n 2. second double-nested child.")))))))) + (third (gethash :body (fourth (zpresent--format (gethash :content (org-parser-parse-string "* top :slide:\n1. first nested list. :slide:\n 1. first double-nested child. :slide:\n 2. second double-nested child."))))))))) (ert-deftest format-structure/single-headline () (should (equal '(("my headline")) - (gethash :title (first (zpresent--format-structure (car (org-parser-parse-string "* my headline")))))))) + (gethash :title (first (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* my headline"))))))))) (ert-deftest format-structure/single-body () (should (equal '((" ▸ " "the body here")) - (gethash :body (second (zpresent--format-structure (car (org-parser-parse-string "* my headline :slide:\n** the body here")))))))) + (gethash :body (second (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* my headline :slide:\n** the body here"))))))))) (ert-deftest format-structure/goes-until-slide () (should (equal 2 - (length (zpresent--format-structure (car (org-parser-parse-string "* headline\n** second\n** third :slide:\n** fourth\n** fifth"))))))) + (length (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* headline\n** second\n** third :slide:\n** fourth\n** fifth")))))))) (ert-deftest format-structure/single-headline-is-checkpoint () (should (gethash :checkpoint - (first (zpresent--format-structure (car (org-parser-parse-string "* headline\n"))))))) + (first (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* headline\n")))))))) (ert-deftest format-structure/headline-with-children-is-checkpoint () (should (gethash :checkpoint - (first (zpresent--format-structure (car (org-parser-parse-string "* headline\n** nested but that shouldn't matter"))))))) + (first (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* headline\n** nested but that shouldn't matter")))))))) (ert-deftest format-structure/second-slide-is-not-checkpoint () (should-not (gethash :checkpoint - (second (zpresent--format-structure (car (org-parser-parse-string "* headline :slide:\n** nested and I'm not a checkpoint"))))))) + (second (zpresent--format-structure (car (gethash :content (org-parser-parse-string "* headline :slide:\n** nested and I'm not a checkpoint")))))))) (ert-deftest get-last-descendant/no-children () (should (equal '("top") (gethash :text - (zpresent--get-last-descendant (car (org-parser-parse-string "* top"))))))) + (zpresent--get-last-descendant (car (gethash :content (org-parser-parse-string "* top")))))))) (ert-deftest get-last-descendant/many-children-no-grandchildren () (should (equal '("child3") (gethash :text - (zpresent--get-last-descendant (car (org-parser-parse-string "* top\n** child1\n** child2\n** child3"))))))) + (zpresent--get-last-descendant (car (gethash :content (org-parser-parse-string "* top\n** child1\n** child2\n** child3")))))))) (ert-deftest get-last-descendant/many-grandchildren () (should (equal '("grandchild33") (gethash :text - (zpresent--get-last-descendant (car (org-parser-parse-string "* top\n** child1\n*** grandchild11\n** child2\n*** grandchild21\n*** grandchild22\n** child3\n*** grandchild31\n*** grandchild32\n*** grandchild33"))))))) + (zpresent--get-last-descendant (car (gethash :content (org-parser-parse-string "* top\n** child1\n*** grandchild11\n** child2\n*** grandchild21\n*** grandchild22\n** child3\n*** grandchild31\n*** grandchild32\n*** grandchild33"))))))))