update packages
This commit is contained in:
5
lisp/org/testing/examples/babel.el
Normal file
5
lisp/org/testing/examples/babel.el
Normal file
@@ -0,0 +1,5 @@
|
||||
(string-match-p "^#[[:digit:]]+$" "#123")
|
||||
|
||||
;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]
|
||||
;; detangle changes
|
||||
;; linked content to detangle:1 ends here
|
||||
@@ -488,3 +488,16 @@ nil
|
||||
#+BEGIN_SRC emacs-lisp :output-dir xxx :file foo.bar
|
||||
nil
|
||||
#+END_SRC
|
||||
* detangle
|
||||
** false positive
|
||||
The =[[= causes a false positive which ~org-babel-detangle~ should handle properly
|
||||
#+begin_src emacs-lisp :tangle yes
|
||||
(string-match-p "^#[[:digit:]]+$" "#123")
|
||||
#+end_src
|
||||
** linked content to detangle
|
||||
:PROPERTIES:
|
||||
:ID: 73115FB0-6565-442B-BB95-50195A499EF4
|
||||
:END:
|
||||
#+begin_src emacs-lisp :tangle yes :comments link
|
||||
;; detangle
|
||||
#+end_src
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
return 0;
|
||||
#+end_src
|
||||
|
||||
#+source: simple
|
||||
#+begin_src cpp :includes <iostream> :results silent
|
||||
std::cout << 42;
|
||||
return 0;
|
||||
#+end_src
|
||||
|
||||
#+source: simple
|
||||
#+begin_src D :results silent
|
||||
writefln ("%s", 42);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
:ID: 0ba56632-8dc1-405c-a083-c204bae477cf
|
||||
:END:
|
||||
** Generic shell: no arrays
|
||||
#+begin_src sh :exports results :var array=sample_array
|
||||
#+begin_src sh :exports results :results output :var array=sample_array
|
||||
echo ${array}
|
||||
#+end_src
|
||||
|
||||
@@ -34,7 +34,7 @@ Bash will see a simple indexed array. In this test, we check that the
|
||||
returned value is indeed only the first item of the array, as opposed to
|
||||
the generic serialiation that will return all elements of the array as
|
||||
a single string.
|
||||
#+begin_src bash :exports results :var array=sample_array
|
||||
#+begin_src bash :exports results :results output :var array=sample_array
|
||||
echo ${array}
|
||||
#+end_src
|
||||
|
||||
@@ -47,7 +47,7 @@ echo ${array}
|
||||
:END:
|
||||
** Generic shell: no special handing
|
||||
The shell will see all values as a single string.
|
||||
#+begin_src sh :exports results :var table=sample_mapping_table
|
||||
#+begin_src sh :exports results :results output :var table=sample_mapping_table
|
||||
echo ${table}
|
||||
#+end_src
|
||||
|
||||
@@ -57,7 +57,7 @@ echo ${table}
|
||||
** Bash shell: support for associative arrays
|
||||
Bash will see a table that contains the first column as the 'index'
|
||||
of the associative array, and the second column as the value.
|
||||
#+begin_src bash :exports results :var table=sample_mapping_table
|
||||
#+begin_src bash :exports :results output results :var table=sample_mapping_table
|
||||
echo ${table[second]}
|
||||
#+end_src
|
||||
|
||||
@@ -69,7 +69,7 @@ echo ${table[second]}
|
||||
:ID: 82320a48-3409-49d7-85c9-5de1c6d3ff87
|
||||
:END:
|
||||
** Generic shell: no special handing
|
||||
#+begin_src sh :exports results :var table=sample_big_table
|
||||
#+begin_src sh :exports results :results output :var table=sample_big_table
|
||||
echo ${table}
|
||||
#+end_src
|
||||
|
||||
@@ -79,7 +79,7 @@ echo ${table}
|
||||
** Bash shell: support for associative arrays with lists
|
||||
Bash will see an associative array that contains each row as a single
|
||||
string. Bash cannot handle lists in associative arrays.
|
||||
#+begin_src bash :exports results :var table=sample_big_table
|
||||
#+begin_src bash :exports results :results output :var table=sample_big_table
|
||||
echo ${table[spaghetti]}
|
||||
#+end_src
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#+property: header-args :var foo=1
|
||||
#+property: header-args+ :var bar=2
|
||||
:PROPERTIES:
|
||||
:header-args: :var foo=1
|
||||
:header-args+: :var bar=2
|
||||
:END:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(+ foo bar)
|
||||
|
||||
@@ -32,60 +32,67 @@
|
||||
(org-babel-next-src-block 1)
|
||||
(should (= 42 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/symbol-include ()
|
||||
"Hello world program with unquoted :includes."
|
||||
(if (executable-find org-babel-C++-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 2)
|
||||
(should (= 42 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-D/simple-program ()
|
||||
"Hello world program."
|
||||
(if (executable-find org-babel-D-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 2)
|
||||
(org-babel-next-src-block 3)
|
||||
(should (= 42 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/integer-var ()
|
||||
"Test of an integer variable."
|
||||
(if (executable-find org-babel-C++-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 3)
|
||||
(org-babel-next-src-block 4)
|
||||
(should (= 12 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-D/integer-var ()
|
||||
"Test of an integer variable."
|
||||
(if (executable-find org-babel-D-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 4)
|
||||
(org-babel-next-src-block 5)
|
||||
(should (= 12 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/two-integer-var ()
|
||||
"Test of two input variables"
|
||||
(if (executable-find org-babel-C++-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 5)
|
||||
(org-babel-next-src-block 6)
|
||||
(should (= 22 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-D/two-integer-var ()
|
||||
"Test of two input variables"
|
||||
(if (executable-find org-babel-D-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 6)
|
||||
(org-babel-next-src-block 7)
|
||||
(should (= 22 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/string-var ()
|
||||
"Test of a string input variable"
|
||||
(if (executable-find org-babel-C++-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 7)
|
||||
(org-babel-next-src-block 8)
|
||||
(should (equal "word 4" (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-D/string-var ()
|
||||
"Test of a string input variable"
|
||||
(if (executable-find org-babel-D-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 8)
|
||||
(org-babel-next-src-block 9)
|
||||
(should (equal "word 4" (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/preprocessor ()
|
||||
"Test of a string variable"
|
||||
(if (executable-find org-babel-C++-compiler)
|
||||
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
|
||||
(org-babel-next-src-block 9)
|
||||
(org-babel-next-src-block 10)
|
||||
(should (= 42 (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-C/table ()
|
||||
|
||||
@@ -250,6 +250,34 @@ call_test-newline[:eval yes :results raw]('(1\n2))<point>"
|
||||
<point>#+call: bar()"
|
||||
(org-babel-execute-src-block nil (org-babel-lob-get-info))))))
|
||||
|
||||
(ert-deftest test-ob-lob/confirm-evaluate ()
|
||||
"Test confirmation when exporting lob calls."
|
||||
;; With the default `org-confirm-babel-evaluate' of t, the caller is
|
||||
;; queried one time.
|
||||
(should
|
||||
(= 1
|
||||
(let ((org-export-use-babel t)
|
||||
(org-confirm-babel-evaluate t)
|
||||
(confirm-evaluate-calls 0))
|
||||
(cl-letf (((symbol-function 'yes-or-no-p)
|
||||
(lambda (&rest _ignore)
|
||||
(cl-incf confirm-evaluate-calls)
|
||||
t)))
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
#+name: foo
|
||||
#+begin_src emacs-lisp
|
||||
nil
|
||||
#+end_src
|
||||
|
||||
#+call: foo()"
|
||||
(let ((string (buffer-string)))
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert string)
|
||||
(org-babel-exp-process-buffer)
|
||||
confirm-evaluate-calls))))))))
|
||||
|
||||
(provide 'test-ob-lob)
|
||||
|
||||
;;; test-ob-lob.el ends here
|
||||
|
||||
@@ -102,9 +102,6 @@ return x
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/session-multiline ()
|
||||
;; FIXME workaround to prevent starting prompt leaking into output
|
||||
(run-python)
|
||||
(sleep-for 0 10)
|
||||
(should
|
||||
(equal "20"
|
||||
(org-test-with-temp-text "#+begin_src python :session :results output
|
||||
@@ -138,6 +135,78 @@ if True:
|
||||
(org-babel-execute-maybe)
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/if-else-block ()
|
||||
(should
|
||||
(equal "success" (org-test-with-temp-text "#+begin_src python :session :results value
|
||||
value = 'failure'
|
||||
if False:
|
||||
pass
|
||||
else:
|
||||
value = 'success'
|
||||
value
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/indent-block-with-blank-lines ()
|
||||
(should
|
||||
(equal 20
|
||||
(org-test-with-temp-text "#+begin_src python :session :results value
|
||||
foo = 0
|
||||
for i in range(10):
|
||||
foo += 1
|
||||
|
||||
foo += 1
|
||||
|
||||
foo
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/assign-underscore ()
|
||||
(should
|
||||
(equal "success"
|
||||
(org-test-with-temp-text "#+begin_src python :session :results value
|
||||
_ = 'failure'
|
||||
'success'
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/multiline-var ()
|
||||
(should
|
||||
(equal "a\nb\nc"
|
||||
(org-test-with-temp-text "#+begin_src python :var text=\"a\\nb\\nc\"
|
||||
return text
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/multiline-str ()
|
||||
(should
|
||||
(equal "a\nb\nc"
|
||||
(org-test-with-temp-text "#+begin_src python
|
||||
text=\"a\\nb\\nc\"
|
||||
return text
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/header-var-assignment ()
|
||||
(should
|
||||
(equal "success"
|
||||
(org-test-with-temp-text "#+begin_src python :var text=\"failure\"
|
||||
text
|
||||
text=\"success\"
|
||||
return text
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/session-value-sleep ()
|
||||
(should
|
||||
(equal "success"
|
||||
(org-test-with-temp-text "#+begin_src python :session :results value
|
||||
import time
|
||||
time.sleep(.1)
|
||||
'success'
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(provide 'test-ob-python)
|
||||
|
||||
;;; test-ob-python.el ends here
|
||||
|
||||
@@ -52,55 +52,59 @@ ob-comint.el, which was not previously tested."
|
||||
"No arrays for generic"
|
||||
(org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
|
||||
(org-babel-next-src-block)
|
||||
(should (equal "one two three" (org-babel-execute-src-block)))))
|
||||
(should (equal "one two three" (org-trim (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-shell/bash-uses-arrays ()
|
||||
"Bash arrays"
|
||||
(org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
|
||||
(org-babel-next-src-block 2)
|
||||
(should (equal "one" (org-babel-execute-src-block)))))
|
||||
(should (equal "one" (org-trim (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-shell/generic-uses-no-assoc-arrays ()
|
||||
"No associative arrays for generic"
|
||||
(should
|
||||
(equal "first one second two third three"
|
||||
(org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
|
||||
(org-babel-next-src-block)
|
||||
(org-babel-execute-src-block))))
|
||||
(org-test-at-id
|
||||
"bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
|
||||
(org-babel-next-src-block)
|
||||
(org-trim (org-babel-execute-src-block)))))
|
||||
(should
|
||||
(equal "bread 2 kg spaghetti 20 cm milk 50 dl"
|
||||
(org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
|
||||
(org-babel-next-src-block)
|
||||
(org-babel-execute-src-block)))))
|
||||
(org-test-at-id
|
||||
"82320a48-3409-49d7-85c9-5de1c6d3ff87"
|
||||
(org-babel-next-src-block)
|
||||
(org-trim (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-shell/bash-uses-assoc-arrays ()
|
||||
"Bash associative arrays"
|
||||
(should
|
||||
(equal "two"
|
||||
(org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
|
||||
(org-babel-next-src-block 2)
|
||||
(org-babel-execute-src-block))))
|
||||
(org-test-at-id
|
||||
"bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
|
||||
(org-babel-next-src-block 2)
|
||||
(org-trim (org-babel-execute-src-block)))))
|
||||
;; Bash associative arrays as strings for the row.
|
||||
(should
|
||||
(equal "20 cm"
|
||||
(org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
|
||||
(org-babel-next-src-block 2)
|
||||
(org-babel-execute-src-block)))))
|
||||
(org-test-at-id
|
||||
"82320a48-3409-49d7-85c9-5de1c6d3ff87"
|
||||
(org-babel-next-src-block 2)
|
||||
(org-trim (org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest ob-shell/simple-list ()
|
||||
"Test list variables in shell."
|
||||
;; With bash, a list is turned into an array.
|
||||
(should
|
||||
(= 2
|
||||
(org-test-with-temp-text
|
||||
"#+BEGIN_SRC bash :var l='(1 2)\necho ${l[1]}\n#+END_SRC"
|
||||
(org-babel-execute-src-block))))
|
||||
(equal "2"
|
||||
(org-test-with-temp-text
|
||||
"#+BEGIN_SRC bash :results output :var l='(1 2)\necho ${l[1]}\n#+END_SRC"
|
||||
(org-trim (org-babel-execute-src-block)))))
|
||||
;; On sh, it is a string containing all values.
|
||||
(should
|
||||
(equal "1 2"
|
||||
(org-test-with-temp-text
|
||||
"#+BEGIN_SRC sh :var l='(1 2)\necho ${l}\n#+END_SRC"
|
||||
(org-babel-execute-src-block)))))
|
||||
"#+BEGIN_SRC sh :results output :var l='(1 2)\necho ${l}\n#+END_SRC"
|
||||
(org-trim (org-babel-execute-src-block))))))
|
||||
|
||||
(provide 'test-ob-shell)
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'subr-x)
|
||||
|
||||
;; TODO
|
||||
;; (ert-deftest ob-tangle/noweb-on-tangle ()
|
||||
;; "Noweb header arguments tangle correctly.
|
||||
@@ -85,7 +87,7 @@
|
||||
(regexp-quote "# [[https://orgmode.org][Org mode]]")
|
||||
(org-test-with-temp-text-in-file
|
||||
"[[https://orgmode.org][Org mode]]
|
||||
#+header: :comments org :tangle \"test-ob-tangle.sh\"
|
||||
#+header: :comments org :results output :tangle \"test-ob-tangle.sh\"
|
||||
#+begin_src sh
|
||||
echo 1
|
||||
#+end_src"
|
||||
@@ -120,26 +122,64 @@ echo 1
|
||||
(search-forward "[H:2]]" nil t))))
|
||||
(delete-file "test-ob-tangle.el")))))
|
||||
|
||||
(ert-deftest ob-tangle/comment-links-relative-file ()
|
||||
"Test relative file name handling when commenting with links."
|
||||
(should
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H
|
||||
#+header: :tangle \"test-ob-tangle.el\" :comments link
|
||||
#+begin_src emacs-lisp
|
||||
1
|
||||
#+end_src"
|
||||
(unwind-protect
|
||||
(let ((org-babel-tangle-use-relative-file-links t))
|
||||
(org-babel-tangle)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents "test-ob-tangle.el")
|
||||
(buffer-string)
|
||||
(goto-char (point-min))
|
||||
(search-forward
|
||||
(concat "[file:" (file-name-nondirectory file))
|
||||
nil t)))
|
||||
(delete-file "test-ob-tangle.el"))))
|
||||
(should
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H
|
||||
#+header: :tangle \"test-ob-tangle.el\" :comments link
|
||||
#+begin_src emacs-lisp
|
||||
1
|
||||
#+end_src"
|
||||
(unwind-protect
|
||||
(let ((org-babel-tangle-use-relative-file-links nil))
|
||||
(org-babel-tangle)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents "test-ob-tangle.el")
|
||||
(buffer-string)
|
||||
(goto-char (point-min))
|
||||
(search-forward (concat "[file:" file) nil t)))
|
||||
(delete-file "test-ob-tangle.el")))))
|
||||
|
||||
(ert-deftest ob-tangle/jump-to-org ()
|
||||
"Test `org-babel-tangle-jump-to-org' specifications."
|
||||
;; Standard test.
|
||||
(should
|
||||
(equal
|
||||
"* H\n#+begin_src emacs-lisp\n1\n#+end_src"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H\n#+begin_src emacs-lisp\n1\n#+end_src"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string))))))
|
||||
;; Multiple blocks in the same section.
|
||||
(should
|
||||
(equal
|
||||
"2"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H
|
||||
(let ((org-file-apps '((t . emacs))))
|
||||
(should
|
||||
(equal
|
||||
"* H\n#+begin_src emacs-lisp\n1\n#+end_src"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H\n#+begin_src emacs-lisp\n1\n#+end_src"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string))))))
|
||||
;; Multiple blocks in the same section.
|
||||
(should
|
||||
(equal
|
||||
"2"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H
|
||||
|
||||
first block
|
||||
|
||||
@@ -153,49 +193,49 @@ another block
|
||||
2
|
||||
#+end_src
|
||||
"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:2]]\n<point>2\n;; H:2 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-substring (line-beginning-position)
|
||||
(line-end-position)))))))
|
||||
;; Preserve position within the source code.
|
||||
(should
|
||||
(equal
|
||||
"1)"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H\n#+begin_src emacs-lisp\n(+ 1 1)\n#+end_src"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n(+ 1 <point>1)\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))))
|
||||
;; Blocks before first heading.
|
||||
(should
|
||||
(equal
|
||||
"Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(org-test-with-temp-text-in-file
|
||||
"Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string))))))
|
||||
;; Special case: buffer starts with a source block.
|
||||
(should
|
||||
(equal
|
||||
"#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(org-test-with-temp-text-in-file
|
||||
"#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string)))))))
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:2]]\n<point>2\n;; H:2 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-substring (line-beginning-position)
|
||||
(line-end-position)))))))
|
||||
;; Preserve position within the source code.
|
||||
(should
|
||||
(equal
|
||||
"1)"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* H\n#+begin_src emacs-lisp\n(+ 1 1)\n#+end_src"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n(+ 1 <point>1)\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))))
|
||||
;; Blocks before first heading.
|
||||
(should
|
||||
(equal
|
||||
"Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(org-test-with-temp-text-in-file
|
||||
"Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string))))))
|
||||
;; Special case: buffer starts with a source block.
|
||||
(should
|
||||
(equal
|
||||
"#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(org-test-with-temp-text-in-file
|
||||
"#+begin_src emacs-lisp\n1\n#+end_src\n* H"
|
||||
(let ((file (buffer-file-name)))
|
||||
(org-test-with-temp-text
|
||||
(format ";; [[file:%s][H:1]]\n<point>1\n;; H:1 ends here\n"
|
||||
(file-name-nondirectory file))
|
||||
(org-babel-tangle-jump-to-org)
|
||||
(buffer-string))))))))
|
||||
|
||||
(ert-deftest ob-tangle/nested-block ()
|
||||
"Test tangling of org file with nested block."
|
||||
@@ -380,6 +420,52 @@ another block
|
||||
(org-split-string (buffer-string))))
|
||||
(delete-file file))))))
|
||||
|
||||
(ert-deftest ob-tangle/multiple-noweb-in-line ()
|
||||
"Test handling of multiple noweb references in a single line."
|
||||
(should
|
||||
(equal '("1" "2" "1")
|
||||
(let ((file (make-temp-file "org-tangle-")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(org-test-with-temp-text-in-file
|
||||
(format "
|
||||
#+name: block1
|
||||
#+begin_src elisp
|
||||
1
|
||||
#+end_src
|
||||
|
||||
#+name: block2
|
||||
#+begin_src elisp
|
||||
2
|
||||
#+end_src
|
||||
|
||||
#+name: block3
|
||||
#+begin_src elisp :noweb yes :tangle %s
|
||||
<<block1>> <<block2>> <<block1>>
|
||||
#+end_src"
|
||||
file)
|
||||
(let ((org-babel-noweb-error-all-langs nil)
|
||||
(org-babel-noweb-error-langs nil))
|
||||
(org-babel-tangle)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(org-split-string (buffer-string))))
|
||||
(delete-file file))))))
|
||||
|
||||
(ert-deftest ob-tangle/detangle-false-positive ()
|
||||
"Test handling of false positive link during detangle."
|
||||
(let (buffer)
|
||||
(unwind-protect
|
||||
(org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
|
||||
(org-babel-detangle)
|
||||
(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
|
||||
(setq buffer (current-buffer))
|
||||
(org-babel-next-src-block)
|
||||
(should (equal (string-trim (org-element-property
|
||||
:value (org-element-at-point)))
|
||||
";; detangle changes"))))
|
||||
(kill-buffer buffer))))
|
||||
|
||||
(provide 'test-ob-tangle)
|
||||
|
||||
;;; test-ob-tangle.el ends here
|
||||
|
||||
@@ -277,7 +277,7 @@ at the beginning of a line."
|
||||
(org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob/inline-src_blk-default-results-replace-line-1 ()
|
||||
(let ((test-line "src_sh{echo 1}")
|
||||
(let ((test-line "src_sh[:results output]{echo 1}")
|
||||
(org-babel-inline-result-wrap "=%s="))
|
||||
;; src_ at bol line 1...
|
||||
(org-test-with-temp-text
|
||||
@@ -465,6 +465,47 @@ at the beginning of a line."
|
||||
(buffer-substring-no-properties
|
||||
(point-min) (point-max)))))))
|
||||
|
||||
(ert-deftest test-ob/inline-src_blk-wrap ()
|
||||
(let ((org-babel-inline-result-wrap "=%s="))
|
||||
;; Export: use export snippet.
|
||||
(should
|
||||
(string-match-p
|
||||
"@@foo:1@@"
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap export foo]{1}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match-p
|
||||
"src_foo{1}"
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap src foo]{1}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match-p
|
||||
"src_foo\\[parameter\\]{1}"
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap src foo parameter]{1}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match-p
|
||||
"=1="
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap example]{1}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))
|
||||
;; Anything else is ignored.
|
||||
(should
|
||||
(string-match-p
|
||||
"{{{results(1)}}}"
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap foo]{1}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match-p
|
||||
"{{{results(a\\\\,b)}}}"
|
||||
(org-test-with-temp-text "src_emacs-lisp[:wrap foo]{\"a,b\"}"
|
||||
(org-babel-execute-maybe)
|
||||
(buffer-string))))))
|
||||
|
||||
(ert-deftest test-ob/combining-scalar-and-raw-result-types ()
|
||||
(org-test-with-temp-text-in-file "
|
||||
|
||||
@@ -507,7 +548,7 @@ echo \"[[file:./cv.cls]]\"
|
||||
(ert-deftest test-ob/just-one-results-block ()
|
||||
"Test that evaluating two times the same code block does not result in a
|
||||
duplicate results block."
|
||||
(org-test-with-temp-text "#+begin_src sh\necho Hello\n#+end_src\n"
|
||||
(org-test-with-temp-text "#+begin_src sh :results output\necho Hello\n#+end_src\n"
|
||||
(org-babel-execute-src-block)
|
||||
(org-babel-execute-src-block) ; second code block execution
|
||||
(should (search-forward "Hello")) ; the string inside the source code block
|
||||
@@ -545,6 +586,17 @@ duplicate results block."
|
||||
(org-babel-next-src-block 1)
|
||||
(should (looking-at org-babel-src-block-regexp))))
|
||||
|
||||
(ert-deftest test-ob/replace-special-block-result ()
|
||||
(should-error
|
||||
(org-test-with-temp-text "
|
||||
#+begin_src emacs-lisp :wrap special<point>
|
||||
'foo
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)
|
||||
(org-babel-execute-src-block)
|
||||
(buffer-string)
|
||||
(search-forward "#+begin_special" nil nil 2))))
|
||||
|
||||
(ert-deftest test-ob/catches-all-references ()
|
||||
(org-test-with-temp-text "
|
||||
#+NAME: literal-example
|
||||
@@ -782,6 +834,18 @@ x
|
||||
* C
|
||||
#+begin_src emacs-lisp :noweb-ref foo
|
||||
C
|
||||
#+end_src"
|
||||
(org-babel-expand-noweb-references))))
|
||||
;; Preserve case when replacing Noweb reference.
|
||||
(should
|
||||
(equal "(ignore)"
|
||||
(org-test-with-temp-text "
|
||||
#+begin_src emacs-lisp :noweb-ref AA
|
||||
\(ignore)
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp :noweb yes<point>
|
||||
<<AA>>
|
||||
#+end_src"
|
||||
(org-babel-expand-noweb-references)))))
|
||||
|
||||
@@ -991,7 +1055,7 @@ x
|
||||
#+end_src
|
||||
|
||||
* next heading")))
|
||||
'("sh" "emacs-lisp")))
|
||||
'("emacs-lisp")))
|
||||
|
||||
(ert-deftest test-ob/org-babel-results-indented-wrap ()
|
||||
"Ensure that wrapped results are inserted correction when indented.
|
||||
@@ -1423,7 +1487,7 @@ Paragraph"
|
||||
| 1 | bar |
|
||||
| 2 | baz |
|
||||
|
||||
#+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
|
||||
#+begin_src sh :var data=input-table :results table :exports results :colnames '(Rev Author)
|
||||
echo \"$data\"
|
||||
#+end_src
|
||||
|
||||
@@ -1440,7 +1504,7 @@ echo \"$data\"
|
||||
| 1 | bar |
|
||||
| 2 | baz |
|
||||
|
||||
#+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
|
||||
#+begin_src sh :var data=input-table :results table :exports results :colnames '(Rev Author)
|
||||
echo \"$data\"
|
||||
#+end_src
|
||||
"
|
||||
@@ -1580,7 +1644,32 @@ line 1
|
||||
(org-babel-execute-src-block)
|
||||
(let ((case-fold-search t)) (search-forward "result" nil t))
|
||||
(downcase (buffer-substring-no-properties (line-beginning-position 2)
|
||||
(point-max)))))))
|
||||
(point-max))))))
|
||||
(should
|
||||
(string-match-p
|
||||
",#"
|
||||
(org-test-with-temp-text "#+begin_src emacs-lisp :wrap export foo
|
||||
\"#+keyword: value\"
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match-p
|
||||
",#"
|
||||
(org-test-with-temp-text "#+begin_src emacs-lisp :wrap src foo
|
||||
\"#+keyword: value\"
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)
|
||||
(buffer-string))))
|
||||
;; Do not comma-escape when the block is not verbatim.
|
||||
(should-not
|
||||
(string-match-p
|
||||
",#"
|
||||
(org-test-with-temp-text "#+begin_src emacs-lisp :wrap special
|
||||
\"#+keyword: value\"
|
||||
#+end_src"
|
||||
(org-babel-execute-src-block)
|
||||
(buffer-string)))))
|
||||
|
||||
(ert-deftest test-ob/safe-header-args ()
|
||||
"Detect safe and unsafe header args."
|
||||
@@ -1657,6 +1746,20 @@ line 1
|
||||
(cdr (assq :file (nth 2 (org-babel-get-src-block-info t))))))
|
||||
))
|
||||
|
||||
(ert-deftest test-ob/file-mode ()
|
||||
"Ensure that :file-mode results in expected permissions."
|
||||
(should
|
||||
(equal #o755
|
||||
(org-test-with-temp-text-in-file "
|
||||
#+begin_src emacs-lisp :results file :file t.sh :file-mode (identity #o755)
|
||||
nil
|
||||
#+end_src"
|
||||
(org-babel-next-src-block)
|
||||
(org-babel-execute-src-block)
|
||||
(unwind-protect
|
||||
(file-modes "t.sh")
|
||||
(delete-file "t.sh"))))))
|
||||
|
||||
(ert-deftest test-ob-core/dir-mkdirp ()
|
||||
"Test :mkdirp with :dir header combination."
|
||||
(should-not
|
||||
@@ -1836,6 +1939,45 @@ default-directory
|
||||
(message (car pair))
|
||||
(should (eq (org-test-babel-confirm-evaluate (car pair)) (cdr pair)))))))
|
||||
|
||||
(ert-deftest test-ob/check-eval-noweb-expanded ()
|
||||
"`org-confirm-babel-evaluate' function receives expanded noweb refs."
|
||||
(should
|
||||
(equal t
|
||||
(org-test-with-temp-text "
|
||||
#+name: foo
|
||||
#+begin_src emacs-lisp
|
||||
:bar
|
||||
#+end_src
|
||||
|
||||
<point>#+begin_src emacs-lisp :noweb yes
|
||||
<<foo>>
|
||||
#+end_src"
|
||||
(let ((org-confirm-babel-evaluate
|
||||
(lambda (_ body)
|
||||
(not (string-match-p ":bar" body)))))
|
||||
(org-babel-check-confirm-evaluate
|
||||
(org-babel-get-src-block-info))))))
|
||||
;; The code block passed to `org-confirm-babel-evaluate' does not
|
||||
;; include coderefs.
|
||||
(should
|
||||
(equal t
|
||||
(org-test-with-temp-text "
|
||||
#+name: foo
|
||||
#+begin_src emacs-lisp
|
||||
:bar
|
||||
#+end_src
|
||||
|
||||
<point>#+begin_src emacs-lisp :noweb yes
|
||||
#(ref:foo)
|
||||
<<foo>>
|
||||
#+end_src"
|
||||
(let ((org-coderef-label-format "#(ref:%s)")
|
||||
(org-confirm-babel-evaluate
|
||||
(lambda (_ body)
|
||||
(string-match-p "ref:foo" body))))
|
||||
(org-babel-check-confirm-evaluate
|
||||
(org-babel-get-src-block-info)))))))
|
||||
|
||||
(defun org-test-ob/update-block-body ()
|
||||
"Test `org-babel-update-block-body' specifications."
|
||||
(should
|
||||
@@ -2001,34 +2143,33 @@ default-directory
|
||||
;; Handle hashes with times.
|
||||
(should
|
||||
(equal
|
||||
"#+RESULTS[<2014-03-04 00:41:10> bbbb]:"
|
||||
"#+RESULTS[(2014-03-04 00:41:10) bbbb]:"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
<point>#+BEGIN_SRC emacs-lisp
|
||||
"#+BEGIN_SRC emacs-lisp
|
||||
\(+ 1 1)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[<2012-03-29 16:40:12> aaaa]:"
|
||||
#+RESULTS[(2012-03-29 16:40:12) aaaa]:"
|
||||
(let ((org-babel-results-keyword "RESULTS")
|
||||
(org-babel-hash-show-time t))
|
||||
(cl-letf (((symbol-function 'format-time-string)
|
||||
(lambda (&rest _) "<2014-03-04 00:41:10>")))
|
||||
(lambda (&rest _) "(2014-03-04 00:41:10)")))
|
||||
(goto-char (org-babel-where-is-src-block-result nil nil "bbbb"))
|
||||
(org-trim (buffer-substring-no-properties (point) (point-max))))))))
|
||||
(should
|
||||
(equal
|
||||
"#+RESULTS[<2012-03-29 16:40:12> aaaa]:"
|
||||
"#+RESULTS[(2012-03-29 16:40:12) aaaa]:"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
<point>#+BEGIN_SRC emacs-lisp
|
||||
\(+ 1 1)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS[<2012-03-29 16:40:12> aaaa]:"
|
||||
#+RESULTS[(2012-03-29 16:40:12) aaaa]:"
|
||||
(let ((org-babel-results-keyword "RESULTS")
|
||||
(org-babel-hash-show-time t))
|
||||
(cl-letf (((symbol-function 'format-time-string)
|
||||
(lambda (&rest _) "<2014-03-04 00:41:10>")))
|
||||
(lambda (&rest _) "(2014-03-04 00:41:10)")))
|
||||
(goto-char (org-babel-where-is-src-block-result nil nil "aaaa"))
|
||||
(org-trim (buffer-substring-no-properties (point) (point-max))))))))
|
||||
;; RESULTS keyword may not be the last affiliated keyword.
|
||||
@@ -2120,14 +2261,44 @@ abc
|
||||
(org-babel-execute-src-block))))))
|
||||
|
||||
(ert-deftest test-ob/string-to-number ()
|
||||
(should (= 0 (org-babel--string-to-number "0")))
|
||||
(should (= 1 (org-babel--string-to-number "1")))
|
||||
(should (eq nil (org-babel--string-to-number "000")))
|
||||
(should (eq nil (org-babel--string-to-number "001")))
|
||||
(should (eq nil (org-babel--string-to-number "010")))
|
||||
(should (= 100 (org-babel--string-to-number "100")))
|
||||
(should (= 0.1 (org-babel--string-to-number "0.1")))
|
||||
(should (= 1.0 (org-babel--string-to-number "1.0"))))
|
||||
(should (= 0 (org-babel--string-to-number "0")))
|
||||
(should (= 1 (org-babel--string-to-number "1")))
|
||||
(should (eq nil (org-babel--string-to-number "1 2")))
|
||||
(should (= 1000.0 (org-babel--string-to-number "1e3")))
|
||||
(should (eq 0 (org-babel--string-to-number "000")))
|
||||
(should (eq 1 (org-babel--string-to-number "001")))
|
||||
(should (eq 10 (org-babel--string-to-number "010")))
|
||||
(should (= 100 (org-babel--string-to-number "100")))
|
||||
(should (= 0.1 (org-babel--string-to-number "0.1")))
|
||||
(should (= 1.0 (org-babel--string-to-number "1.0"))))
|
||||
|
||||
(ert-deftest test-ob/import-elisp-from-file ()
|
||||
"Test `org-babel-import-elisp-from-file'."
|
||||
(should
|
||||
(equal
|
||||
(org-test-with-temp-text-in-file "line 1\nline 2\n"
|
||||
(cl-letf (((symbol-function 'display-warning)
|
||||
(lambda (&rest _) (error "No warnings should occur"))
|
||||
(org-table-convert-region-max-lines 2)))
|
||||
(org-babel-import-elisp-from-file (buffer-file-name))))
|
||||
'(("line" 1)
|
||||
("line" 2))))
|
||||
;; If an error occurs during table conversion, it is shown with
|
||||
;; `display-warning' rather than as a message to make sure the
|
||||
;; caller sees it.
|
||||
(should-error
|
||||
(org-test-with-temp-text-in-file "line 1\nline 2\n"
|
||||
(cl-letf (((symbol-function 'display-warning)
|
||||
(lambda (&rest _) (error "Warning should be displayed")))
|
||||
(org-table-convert-region-max-lines 1))
|
||||
(org-babel-import-elisp-from-file (buffer-file-name)))))
|
||||
;; But an empty file (as is the case when there are no execution
|
||||
;; results) does not trigger a warning.
|
||||
(should-not
|
||||
(org-test-with-temp-text-in-file ""
|
||||
(cl-letf (((symbol-function 'display-warning)
|
||||
(lambda (&rest _) (error "No warnings should occur"))))
|
||||
(org-babel-import-elisp-from-file (buffer-file-name))))))
|
||||
|
||||
(provide 'test-ob)
|
||||
|
||||
|
||||
@@ -133,6 +133,32 @@
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
;; On a headline, remove TODO and COMMENT keywords, priority cookie,
|
||||
;; and tags.
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* TODO H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* COMMENT H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* [#A] H1"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
(org-test-with-temp-text-in-file "* H1 :tag:"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*H1][H1]]" file)
|
||||
(org-store-link nil))))))
|
||||
;; On a headline, remove any link from description.
|
||||
(should
|
||||
(let (org-store-link-props org-stored-links)
|
||||
@@ -217,7 +243,7 @@
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s][file:%s]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(org-store-link nil))))))
|
||||
;; C-u prefix reverses `org-context-in-file-links' in non-Org
|
||||
;; buffer.
|
||||
(should
|
||||
@@ -237,7 +263,95 @@
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s][file:%s]]" file file)
|
||||
(org-store-link '(16))))))))
|
||||
(org-store-link '(16)))))))
|
||||
;; Context does not include special search syntax.
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "(two)"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "# two"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "*two"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "( two )"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "# two"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "#( two )"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "#** ((## two) )"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should-not
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "(two"
|
||||
(fundamental-mode)
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::two]]" file file)
|
||||
(org-store-link nil))))))
|
||||
;; Context also ignore statistics cookies and special headlines
|
||||
;; data.
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "* TODO [#A] COMMENT foo :bar:"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*foo][foo]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "* foo[33%]bar"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*foo bar][foo bar]]" file file)
|
||||
(org-store-link nil))))))
|
||||
(should
|
||||
(let ((org-stored-links nil)
|
||||
(org-context-in-file-links t))
|
||||
(org-test-with-temp-text-in-file "* [%][/] foo [35%] bar[3/5]"
|
||||
(let ((file (buffer-file-name)))
|
||||
(equal (format "[[file:%s::*foo bar][foo bar]]" file file)
|
||||
(org-store-link nil)))))))
|
||||
|
||||
|
||||
;;; Radio Targets
|
||||
|
||||
@@ -111,13 +111,14 @@
|
||||
(buf (get-buffer org-agenda-buffer-name))
|
||||
org-agenda-files)
|
||||
(when buf (kill-buffer buf))
|
||||
(org-test-with-temp-text "<2017-03-17 Fri>"
|
||||
(org-follow-timestamp-link)) ;creates a sticky agenda
|
||||
(org-test-agenda--kill-all-agendas)
|
||||
(org-agenda-list)
|
||||
(should (= 1 (length (org-test-agenda--agenda-buffers))))
|
||||
(should (string= "*Org Agenda*"
|
||||
(buffer-name (car (org-test-agenda--agenda-buffers))))))
|
||||
(dolist (fn '(org-agenda-list org-todo-list))
|
||||
(org-test-with-temp-text "<2017-03-17 Fri>"
|
||||
(org-follow-timestamp-link)) ;creates a sticky agenda
|
||||
(org-test-agenda--kill-all-agendas)
|
||||
(funcall fn)
|
||||
(should (= 1 (length (org-test-agenda--agenda-buffers))))
|
||||
(should (string= "*Org Agenda*"
|
||||
(buffer-name (car (org-test-agenda--agenda-buffers)))))))
|
||||
(org-test-agenda--kill-all-agendas))
|
||||
|
||||
(ert-deftest test-org-agenda/sticky-agenda-name-after-reload ()
|
||||
|
||||
@@ -57,6 +57,44 @@
|
||||
(forward-line -1)
|
||||
(org-element-property :title (org-element-at-point))))))
|
||||
|
||||
(ert-deftest test-org-archive/datetree ()
|
||||
"Test `org-archive-subtree' with a datetree target."
|
||||
(org-test-at-time "<2020-07-05 Sun>"
|
||||
;; Test in buffer target with no additional subheadings...
|
||||
(should
|
||||
(string-match-p
|
||||
(regexp-quote "*** 2020-07-05 Sunday\n**** a")
|
||||
(org-test-with-temp-text-in-file "* a\n"
|
||||
(let ((org-archive-location "::datetree/"))
|
||||
(org-archive-subtree)
|
||||
(buffer-string)))))
|
||||
;; ... and with `org-odd-levels-only' non-nil.
|
||||
(should
|
||||
(string-match-p
|
||||
(regexp-quote "***** 2020-07-05 Sunday\n******* a")
|
||||
(org-test-with-temp-text-in-file "* a\n"
|
||||
(let ((org-archive-location "::datetree/")
|
||||
(org-odd-levels-only t))
|
||||
(org-archive-subtree)
|
||||
(buffer-string)))))
|
||||
;; Test in buffer target with an additional subheading...
|
||||
(should
|
||||
(string-match-p
|
||||
(regexp-quote "*** 2020-07-05 Sunday\n**** a\n***** b")
|
||||
(org-test-with-temp-text-in-file "* b\n"
|
||||
(let ((org-archive-location "::datetree/* a"))
|
||||
(org-archive-subtree)
|
||||
(buffer-string)))))
|
||||
;; ... and with `org-odd-levels-only' non-nil.
|
||||
(should
|
||||
(string-match-p
|
||||
(regexp-quote "***** 2020-07-05 Sunday\n******* a\n********* b")
|
||||
(org-test-with-temp-text-in-file "* b\n"
|
||||
(let ((org-archive-location "::datetree/* a")
|
||||
(org-odd-levels-only t))
|
||||
(org-archive-subtree)
|
||||
(buffer-string)))))))
|
||||
|
||||
(ert-deftest test-org-archive/to-archive-sibling ()
|
||||
"Test `org-archive-to-archive-sibling' specifications."
|
||||
;; Archive sibling before or after archive heading.
|
||||
|
||||
@@ -30,80 +30,81 @@
|
||||
|
||||
(ert-deftest test-org-attach/dir ()
|
||||
"Test `org-attach-get' specifications."
|
||||
(should (equal "Text in fileA\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 157) ;; First attachment link
|
||||
(org-open-at-point)
|
||||
(buffer-string))))
|
||||
(should-not (equal "Text in fileB\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 219) ;; Second attachment link
|
||||
(let ((org-attach-use-inheritance nil))
|
||||
(org-open-at-point)
|
||||
(buffer-string)))))
|
||||
(should (equal "Text in fileB\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 219) ;; Second attachment link
|
||||
(let ((org-attach-use-inheritance t))
|
||||
(let ((org-file-apps '((t . emacs))))
|
||||
(should (equal "Text in fileA\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 157) ;; First attachment link
|
||||
(org-open-at-point)
|
||||
(buffer-string)))))
|
||||
(should-not (equal "att1"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 179) ;; H1.1
|
||||
(let ((org-attach-use-inheritance nil))
|
||||
(org-attach-dir)))))
|
||||
(should (equal "att1"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 179) ;; H1.1
|
||||
(let ((org-attach-use-inheritance t))
|
||||
(org-attach-dir)))))
|
||||
(should (equal '("fileC" "fileD")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 239) ;; H1.2
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
(should (equal '("fileC" "fileD")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 239) ;; H1.2
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
(should (equal '("fileE")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 289) ;; H2
|
||||
(let ((org-attach-id-dir "data/"))
|
||||
(org-attach-file-list (org-attach-dir))))))
|
||||
(should (equal "peek-a-boo\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 289) ;; H2
|
||||
(let ((org-attach-id-dir "data/"))
|
||||
(org-attach-open-in-emacs)
|
||||
(buffer-string)))))
|
||||
(should (equal '("fileA" "fileB")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 336) ;; H3
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
;; Test for folder not initialized in the filesystem
|
||||
(should-not (org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance nil)
|
||||
(org-attach-id-dir "data/"))
|
||||
(org-attach-dir))))
|
||||
;; Not yet initialized folder should be found if no-fs-check is
|
||||
;; non-nil
|
||||
(should (equal "data/ab/cd12345"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance nil)
|
||||
(org-attach-id-dir "data/"))
|
||||
(file-relative-name (org-attach-dir nil t))))))
|
||||
(should (equal '("fileA" "fileB")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance t))
|
||||
;; This is where it gets a bit sketchy...! DIR always has
|
||||
;; priority over ID, even if ID is declared "higher up" in the
|
||||
;; tree. This can potentially be revised. But it is also
|
||||
;; pretty clean. DIR is always higher in priority than ID right
|
||||
;; now, no matter the depth in the tree.
|
||||
(org-attach-file-list (org-attach-dir)))))))
|
||||
(buffer-string))))
|
||||
(should-not (equal "Text in fileB\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 219) ;; Second attachment link
|
||||
(let ((org-attach-use-inheritance nil))
|
||||
(org-open-at-point)
|
||||
(buffer-string)))))
|
||||
(should (equal "Text in fileB\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 219) ;; Second attachment link
|
||||
(let ((org-attach-use-inheritance t))
|
||||
(org-open-at-point)
|
||||
(buffer-string)))))
|
||||
(should-not (equal "att1"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 179) ;; H1.1
|
||||
(let ((org-attach-use-inheritance nil))
|
||||
(org-attach-dir)))))
|
||||
(should (equal "att1"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 179) ;; H1.1
|
||||
(let ((org-attach-use-inheritance t))
|
||||
(org-attach-dir)))))
|
||||
(should (equal '("fileC" "fileD")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 239) ;; H1.2
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
(should (equal '("fileC" "fileD")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 239) ;; H1.2
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
(should (equal '("fileE")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 289) ;; H2
|
||||
(let ((org-attach-id-dir "data/"))
|
||||
(org-attach-file-list (org-attach-dir))))))
|
||||
(should (equal "peek-a-boo\n"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 289) ;; H2
|
||||
(let ((org-attach-id-dir "data/"))
|
||||
(org-attach-open-in-emacs)
|
||||
(buffer-string)))))
|
||||
(should (equal '("fileA" "fileB")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 336) ;; H3
|
||||
(org-attach-file-list (org-attach-dir)))))
|
||||
;; Test for folder not initialized in the filesystem
|
||||
(should-not (org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance nil)
|
||||
(org-attach-id-dir "data/"))
|
||||
(org-attach-dir))))
|
||||
;; Not yet initialized folder should be found if no-fs-check is
|
||||
;; non-nil
|
||||
(should (equal "data/ab/cd12345"
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance nil)
|
||||
(org-attach-id-dir "data/"))
|
||||
(file-relative-name (org-attach-dir nil t))))))
|
||||
(should (equal '("fileA" "fileB")
|
||||
(org-test-in-example-file org-test-attachments-file
|
||||
(goto-char 401) ;; H3.1
|
||||
(let ((org-attach-use-inheritance t))
|
||||
;; This is where it gets a bit sketchy...! DIR always has
|
||||
;; priority over ID, even if ID is declared "higher up" in the
|
||||
;; tree. This can potentially be revised. But it is also
|
||||
;; pretty clean. DIR is always higher in priority than ID right
|
||||
;; now, no matter the depth in the tree.
|
||||
(org-attach-file-list (org-attach-dir))))))))
|
||||
|
||||
(ert-deftest test-org-attach/dired-attach-to-next-best-subtree/1 ()
|
||||
"Attach file at point in dired to subtree."
|
||||
|
||||
@@ -742,6 +742,16 @@
|
||||
`(("t" "Text" plain (file ,file) ""
|
||||
:immediate-finish t))))
|
||||
(org-capture nil "t")
|
||||
(buffer-string)))))
|
||||
;; Test :unnarrowed property without a "%?" marker.
|
||||
(should
|
||||
(equal "SUCCESS\n"
|
||||
(org-test-with-temp-text-in-file ""
|
||||
(let* ((file (buffer-file-name))
|
||||
(org-capture-templates
|
||||
`(("t" "Text" plain (file ,file) "SUCCESS"
|
||||
:unnarrowed t :immediate-finish t))))
|
||||
(org-capture nil "t")
|
||||
(buffer-string))))))
|
||||
|
||||
(provide 'test-org-capture)
|
||||
|
||||
@@ -577,7 +577,7 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
||||
;; If there is no file attached to the document, link directly to
|
||||
;; the headline.
|
||||
(should
|
||||
(string-match-p "| +\\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
(string-match-p "| +\\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
@@ -585,7 +585,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
;; Otherwise, link to the headline in the current file.
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[file:filename::Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[file:filename::\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
(org-test-with-temp-text-in-file
|
||||
"* Foo
|
||||
@@ -600,28 +600,28 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
;; headline.
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* TODO Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* [#A] Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* COMMENT Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo :tag:
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
@@ -629,14 +629,14 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
;; Remove statistics cookie from headline description.
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [50%]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo]\\[Foo]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [1/2]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
@@ -645,14 +645,14 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
;; links if there is no description.
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [[https://orgmode.org][Org mode]]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t :lang en"))))
|
||||
(should
|
||||
(string-match-p
|
||||
"| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
|
||||
"| \\[\\[\\*Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [[https://orgmode.org]]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
@@ -1053,6 +1053,39 @@ CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 16:00] => 8:00"
|
||||
(let ((system-time-locale "en_US"))
|
||||
(test-org-clock-clocktable-contents
|
||||
":step month :mstart 4 :block 2014 :stepskip0 t")))))
|
||||
;; Test ":step semimonth".
|
||||
(should
|
||||
(string-match-p
|
||||
"
|
||||
.*?\\[2014-03-01 .*
|
||||
.*
|
||||
.*
|
||||
|.*?| \\*8:00\\* |
|
||||
.*
|
||||
| Foo +| 8:00 +|
|
||||
|
||||
.*?\\[2014-03-16 .*
|
||||
.*
|
||||
.*
|
||||
|.*?| \\*2:00\\* |
|
||||
.*
|
||||
| Foo +| 2:00 +|
|
||||
|
||||
.*?\\[2014-04-01 .*
|
||||
.*
|
||||
.*
|
||||
|.*?| \\*7:00\\* |
|
||||
.*
|
||||
| Foo +| 7:00 +|
|
||||
"
|
||||
(org-test-with-temp-text
|
||||
"* Foo
|
||||
CLOCK: [2014-03-04 Tue 08:00]--[2014-03-04 Tue 16:00] => 8:00
|
||||
CLOCK: [2014-03-24 Mon 08:00]--[2014-03-24 Mon 10:00] => 2:00
|
||||
CLOCK: [2014-04-03 Thu 08:00]--[2014-04-03 Thu 15:00] => 7:00"
|
||||
(let ((system-time-locale "en_US"))
|
||||
(test-org-clock-clocktable-contents
|
||||
":step semimonth :block 2014 :stepskip0 t")))))
|
||||
;; Test ":step year".
|
||||
(should
|
||||
(string-match-p
|
||||
|
||||
@@ -1519,7 +1519,24 @@
|
||||
(org-test-with-temp-text
|
||||
"* H src_emacs-lisp{(+ 1 1)} 1\n<point>#+BEGIN: columnview\n#+END:"
|
||||
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
|
||||
(buffer-substring-no-properties (point) (point-max))))))
|
||||
(buffer-substring-no-properties (point) (point-max)))))
|
||||
;; Active time stamps are displayed as inactive.
|
||||
(should
|
||||
(equal
|
||||
"#+BEGIN: columnview
|
||||
| ITEM | d | s | t |
|
||||
|------+------------------+------------------+------------------|
|
||||
| H | [2020-05-14 Thu] | [2020-05-11 Mon] | [2020-06-10 Wed] |
|
||||
#+END:"
|
||||
(org-test-with-temp-text
|
||||
"* H
|
||||
SCHEDULED: <2020-05-11 Mon> DEADLINE: <2020-05-14 Thu>
|
||||
<2020-06-10 Wed>
|
||||
<point>#+BEGIN: columnview\n#+END:"
|
||||
(let ((org-columns-default-format
|
||||
"%ITEM %DEADLINE(d) %SCHEDULED(s) %TIMESTAMP(t)"))
|
||||
(org-update-dblock))
|
||||
(buffer-substring-no-properties (point) (point-max))))))
|
||||
|
||||
(provide 'test-org-colview)
|
||||
;;; test-org-colview.el ends here
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
;; When date is missing, create it.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text ""
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
@@ -34,7 +34,7 @@
|
||||
;; Do not create new year node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
@@ -42,24 +42,24 @@
|
||||
;; Do not create new month node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n** 2012-03 month"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n\n** 2012-03 month"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(org-trim (buffer-string)))))
|
||||
;; Do not create new day node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(org-trim (buffer-string)))))
|
||||
;; Sort new entry in right place.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-02 .*\n\\*\\*\\* 2012-02-01 .*\n\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-02 .*\n\n\\*\\*\\* 2012-02-01 .*\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'"
|
||||
(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012))
|
||||
(org-datetree-find-date-create '(2 1 2012)))
|
||||
@@ -68,14 +68,14 @@
|
||||
;; in entry. When set to `inactive', insert an inactive one.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*<\\1.*?>\\'"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*<\\1.*?>\\'"
|
||||
(org-test-with-temp-text "* 2012\n"
|
||||
(let ((org-datetree-add-timestamp t))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(org-trim (buffer-string)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*\\[\\1.*?\\]\\'"
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*\\[\\1.*?\\]\\'"
|
||||
(org-test-with-temp-text "* 2012\n"
|
||||
(let ((org-datetree-add-timestamp 'inactive))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
@@ -91,9 +91,9 @@
|
||||
(org-trim (buffer-string)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\* H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n\\*\\*\\* 2012"
|
||||
"\\*\\* H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n\n\\*\\*\\* 2012"
|
||||
(org-test-with-temp-text
|
||||
"* H1\n** H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n* H2"
|
||||
"* H1\n\n** H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n\n* H2"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(org-trim (buffer-string)))))
|
||||
@@ -101,24 +101,35 @@
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\*\\* 2012-03-29"
|
||||
(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day"
|
||||
(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(buffer-substring (point) (line-end-position)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\*\\* 2012-03-29"
|
||||
(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day"
|
||||
(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day"
|
||||
(let ((org-datetree-add-timestamp t))
|
||||
(org-datetree-find-date-create '(3 29 2012)))
|
||||
(buffer-substring (point) (line-end-position))))))
|
||||
|
||||
(ert-deftest test-org-datetree/find-month-create ()
|
||||
"Test `org-datetree-find-month-create' specifications."
|
||||
;; When date is missing, create it with the entry under month.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2012\n\n\\*\\* 2012-03 .*\\'"
|
||||
(org-test-with-temp-text ""
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-month-create '(3 29 2012)))
|
||||
(org-trim (buffer-string))))))
|
||||
|
||||
(ert-deftest test-org-datetree/find-iso-week-create ()
|
||||
"Test `org-datetree-find-iso-date-create' specificaiton."
|
||||
;; When date is missing, create it.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text ""
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
@@ -126,7 +137,7 @@
|
||||
;; Do not create new year node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text "* 2015\n"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
@@ -134,23 +145,23 @@
|
||||
;; Do not create new month node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text "* 2015\n** 2015-W01"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text "* 2015\n\n** 2015-W01"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(org-trim (buffer-string)))))
|
||||
;; Do not create new day node when one exists.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text "* 2015\n** 2015-W01\n*** 2014-12-31 day"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* 2014-12-31 .*\\'"
|
||||
(org-test-with-temp-text "* 2015\n\n** 2015-W01\n\n*** 2014-12-31 day"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(org-trim (buffer-string)))))
|
||||
;; Sort new entry in right place.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* 2014-12-31 .*\n\n\\*\\* 2015-W36\n\\*\\*\\* 2015-09-01 .*\\'"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* 2014-12-31 .*\n\n\\*\\* 2015-W36\n\n\\*\\*\\* 2015-09-01 .*\\'"
|
||||
(org-test-with-temp-text "* 2015"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(9 1 2015))
|
||||
@@ -160,14 +171,14 @@
|
||||
;; in entry. When set to `inactive', insert an inactive one.
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* \\(2014-12-31\\) .*\n[ \t]*<\\1.*?>\\'"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* \\(2014-12-31\\) .*\n[ \t]*<\\1.*?>\\'"
|
||||
(org-test-with-temp-text "* 2015\n"
|
||||
(let ((org-datetree-add-timestamp t))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(org-trim (buffer-string)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\`\\* 2015\n\\*\\* 2015-W01\n\\*\\*\\* \\(2014-12-31\\) .*\n[ \t]*\\[\\1.*?\\]\\'"
|
||||
"\\`\\* 2015\n\n\\*\\* 2015-W01\n\n\\*\\*\\* \\(2014-12-31\\) .*\n[ \t]*\\[\\1.*?\\]\\'"
|
||||
(org-test-with-temp-text "* 2015\n"
|
||||
(let ((org-datetree-add-timestamp 'inactive))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
@@ -183,9 +194,9 @@
|
||||
(org-trim (buffer-string)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\* H1.1\n:PROPERTIES:\n:WEEK_TREE: t\n:END:\n\\*\\*\\* 2015"
|
||||
"\\*\\* H1.1\n:PROPERTIES:\n:WEEK_TREE: t\n:END:\n\n\\*\\*\\* 2015"
|
||||
(org-test-with-temp-text
|
||||
"* H1\n** H1.1\n:PROPERTIES:\n:WEEK_TREE: t\n:END:\n* H2"
|
||||
"* H1\n** H1.1\n:PROPERTIES:\n:WEEK_TREE: t\n:END:\n\n* H2"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(org-trim (buffer-string)))))
|
||||
@@ -193,14 +204,14 @@
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\*\\* 2014-12-31"
|
||||
(org-test-with-temp-text "* 2015\n** 2015-W01\n*** 2014-12-31 day"
|
||||
(org-test-with-temp-text "* 2015\n\n** 2015-W01\n\n*** 2014-12-31 day"
|
||||
(let ((org-datetree-add-timestamp nil))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(buffer-substring (point) (line-end-position)))))
|
||||
(should
|
||||
(string-match
|
||||
"\\*\\*\\* 2014-12-31"
|
||||
(org-test-with-temp-text "* 2015\n** 2015-W01\n*** 2014-12-31 day"
|
||||
(org-test-with-temp-text "* 2015\n\n** 2015-W01\n\n*** 2014-12-31 day"
|
||||
(let ((org-datetree-add-timestamp t))
|
||||
(org-datetree-find-iso-week-create '(12 31 2014)))
|
||||
(buffer-substring (point) (line-end-position))))))
|
||||
|
||||
@@ -121,7 +121,15 @@
|
||||
(should (equal "0.5min"
|
||||
(let ((org-duration-format
|
||||
'(("h" . nil) ("min" . nil) (special . 1))))
|
||||
(org-duration-from-minutes 0.5)))))
|
||||
(org-duration-from-minutes 0.5))))
|
||||
;; Handle compact form.
|
||||
(should (equal "0h50min"
|
||||
(let ((org-duration-format '(("h" . t) ("min" . t) compact)))
|
||||
(org-duration-from-minutes 50))))
|
||||
(should (equal "1d0:10"
|
||||
(let ((org-duration-format
|
||||
'(("d" . nil) (special . h:mm) compact)))
|
||||
(org-duration-from-minutes (+ (* 24 60) 10))))))
|
||||
|
||||
(ert-deftest test-org-duration/p ()
|
||||
"Test `org-duration-p' specifications."
|
||||
@@ -130,7 +138,9 @@
|
||||
(should (org-duration-p "123:12"))
|
||||
(should (org-duration-p "1:23:45"))
|
||||
(should (org-duration-p "3d 3h 4min"))
|
||||
(should (org-duration-p "3d3h4min"))
|
||||
(should (org-duration-p "3d 13:35"))
|
||||
(should (org-duration-p "3d13:35"))
|
||||
(should (org-duration-p "2.35h"))
|
||||
;; Handle custom units, but return nil for unknown units.
|
||||
(should-not (org-duration-p "1minute"))
|
||||
@@ -146,7 +156,7 @@
|
||||
(should-not (org-duration-p "3::12"))
|
||||
(should-not (org-duration-p "3:2"))
|
||||
(should-not (org-duration-p "3:12:4"))
|
||||
;; Return nil in mixed mode if H:MM:SS part is not last.
|
||||
;; Return nil in mixed mode if H:MM:SS part is not the last one.
|
||||
(should-not (org-duration-p "3d 13:35 13h")))
|
||||
|
||||
(ert-deftest test-org-duration/h:mm-only-p ()
|
||||
|
||||
@@ -568,42 +568,38 @@ Some other text
|
||||
(ert-deftest test-org-element/comment-parser ()
|
||||
"Test `comment' parser."
|
||||
;; Regular comment.
|
||||
(should
|
||||
(org-test-with-temp-text "# Comment"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity)))
|
||||
(should (eq 'comment
|
||||
(org-test-with-temp-text "# Comment"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
;; Inline comment.
|
||||
(should
|
||||
(org-test-with-temp-text " # Comment"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity)))
|
||||
(should (eq 'comment
|
||||
(org-test-with-temp-text " # Comment"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
;; Preserve indentation.
|
||||
(should
|
||||
(equal
|
||||
(org-element-property
|
||||
:value
|
||||
(org-test-with-temp-text "# No blank\n# One blank"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
|
||||
"No blank\n One blank"))
|
||||
(equal "No blank\n One blank"
|
||||
(org-element-property
|
||||
:value
|
||||
(org-test-with-temp-text "# No blank\n# One blank"
|
||||
(org-element-at-point)))))
|
||||
;; Comment with blank lines.
|
||||
(should
|
||||
(equal
|
||||
(org-element-property
|
||||
:value
|
||||
(org-test-with-temp-text "# First part\n# \n#\n# Second part"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
|
||||
"First part\n\n\nSecond part"))
|
||||
(equal "First part\n\n\nSecond part"
|
||||
(org-element-property
|
||||
:value
|
||||
(org-test-with-temp-text "# First part\n# \n#\n# Second part"
|
||||
(org-element-at-point)))))
|
||||
;; Do not mix comments and keywords.
|
||||
(should
|
||||
(eq 1
|
||||
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
||||
(length (org-element-map (org-element-parse-buffer) 'comment
|
||||
'identity)))))
|
||||
#'identity)))))
|
||||
(should
|
||||
(equal "comment"
|
||||
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
||||
(org-element-property
|
||||
:value
|
||||
(org-element-map (org-element-parse-buffer) 'comment
|
||||
'identity nil t)))))
|
||||
(org-test-with-temp-text
|
||||
"#+key: value\n<point># comment\n#+key: value"
|
||||
(org-element-property :value (org-element-at-point)))))
|
||||
;; Correctly handle non-empty blank lines at the end of buffer.
|
||||
(should
|
||||
(org-test-with-temp-text "# A\n "
|
||||
@@ -1925,6 +1921,15 @@ e^{i\\pi}+1=0
|
||||
(let ((element (org-element-at-point)))
|
||||
(list (org-element-property :key element)
|
||||
(org-element-property :value element))))))
|
||||
;; The insides of property blocks on document level are parsed the
|
||||
;; same way as headline property blocks. I.e. the concept of
|
||||
;; `node-property' apply also for properties in those blocks.
|
||||
(should
|
||||
(equal '("abc" "value")
|
||||
(org-test-with-temp-text ":PROPERTIES:\n<point>:abc: value\n:END:"
|
||||
(let ((element (org-element-at-point)))
|
||||
(list (org-element-property :key element)
|
||||
(org-element-property :value element))))))
|
||||
;; Value should be trimmed.
|
||||
(should
|
||||
(equal "value"
|
||||
@@ -2111,6 +2116,20 @@ Outside list"
|
||||
(org-test-with-temp-text
|
||||
"* H\nDEADLINE: <2014-03-04 tue.>\n<point>:PROPERTIES:\n:prop: value\n:END:"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
;; Parse property drawer at the beginning of the document, possibly
|
||||
;; after some initial comments.
|
||||
(should
|
||||
(eq 'property-drawer
|
||||
(org-test-with-temp-text "<point>:PROPERTIES:\n:prop: value\n:END:"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
(should
|
||||
(eq 'property-drawer
|
||||
(org-test-with-temp-text "# C\n# C\n<point>:PROPERTIES:\n:prop: value\n:END:"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
(should-not
|
||||
(eq 'property-drawer
|
||||
(org-test-with-temp-text "\n<point>:PROPERTIES:\n:prop: value\n:END:"
|
||||
(org-element-type (org-element-at-point)))))
|
||||
;; Allow properties without value and no property at all.
|
||||
(should
|
||||
(eq 'property-drawer
|
||||
|
||||
@@ -146,7 +146,6 @@ p2
|
||||
*************** p3
|
||||
p4
|
||||
*************** END
|
||||
|
||||
"
|
||||
(org-flag-subtree t)
|
||||
(org-cycle)
|
||||
|
||||
@@ -205,6 +205,32 @@ Paragraph 2"
|
||||
|
||||
(ert-deftest test-org-lint/obsolete-properties-drawer ()
|
||||
"Test `org-lint-obsolete-properties-drawer' checker."
|
||||
(should-not
|
||||
(org-test-with-temp-text "
|
||||
* H
|
||||
:PROPERTIES:
|
||||
:SOMETHING: foo
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "
|
||||
* H
|
||||
SCHEDULED: <2012-03-29>
|
||||
:PROPERTIES:
|
||||
:SOMETHING: foo
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text ":PROPERTIES:
|
||||
:SOMETHING: foo
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "# Comment
|
||||
:PROPERTIES:
|
||||
:SOMETHING: foo
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer))))
|
||||
(should
|
||||
(org-test-with-temp-text "
|
||||
* H
|
||||
@@ -218,6 +244,12 @@ Paragraph
|
||||
* H
|
||||
:PROPERTIES:
|
||||
This is not a node property
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer))))
|
||||
(should
|
||||
(org-test-with-temp-text "Paragraph
|
||||
:PROPERTIES:
|
||||
:FOO: bar
|
||||
:END:"
|
||||
(org-lint '(obsolete-properties-drawer)))))
|
||||
|
||||
@@ -361,6 +393,9 @@ SCHEDULED: <2012-03-29 thu.>"
|
||||
(should
|
||||
(org-test-with-temp-text ":DRAWER:"
|
||||
(org-lint '(incomplete-drawer))))
|
||||
(should
|
||||
(org-test-with-temp-text ":DRAWER:\n:ODD:\n:END:"
|
||||
(org-lint '(incomplete-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text ":DRAWER:\n:END:"
|
||||
(org-lint '(incomplete-drawer)))))
|
||||
|
||||
@@ -479,18 +479,82 @@ b. Item 2<point>"
|
||||
- Item 3.1
|
||||
"))))
|
||||
|
||||
(ert-deftest test-org-list/cycle-item-identation ()
|
||||
"Test `org-list-cycle-item-indentation' specifications."
|
||||
;; Refuse to indent non-empty items.
|
||||
(should-not
|
||||
(org-test-with-temp-text "- item - item2<point>"
|
||||
(org-cycle-item-indentation)))
|
||||
;; First try to indent item.
|
||||
(should
|
||||
(equal "- item\n - sub-item\n - "
|
||||
(org-test-with-temp-text "- item\n - sub-item\n - <point>"
|
||||
(org-cycle-item-indentation)
|
||||
(buffer-string))))
|
||||
;; If first indentation is not possible, outdent item.
|
||||
(should
|
||||
(equal "- item\n- "
|
||||
(org-test-with-temp-text "- item\n - <point>"
|
||||
(org-cycle-item-indentation)
|
||||
(buffer-string))))
|
||||
;; Throw an error when item cannot move either way.
|
||||
(should-error
|
||||
(org-test-with-temp-text "- "
|
||||
(org-cycle-item-indentation)))
|
||||
;; On repeated commands, cycle through all the indented positions,
|
||||
;; then through all the outdented ones, then move back to initial
|
||||
;; position.
|
||||
(should
|
||||
(equal '(4 6 0 2)
|
||||
(org-test-with-temp-text "- i0\n - i1\n - s1\n - <point>"
|
||||
(let ((indentations nil))
|
||||
(org-cycle-item-indentation)
|
||||
(dotimes (_ 3)
|
||||
(let ((last-command 'org-cycle-item-indentation))
|
||||
(push (current-indentation) indentations)
|
||||
(org-cycle-item-indentation)))
|
||||
(reverse (cons (current-indentation) indentations))))))
|
||||
;; Refuse to indent the first item in a sub-list. Also refuse to
|
||||
;; outdent an item with a next sibling.
|
||||
(should-error
|
||||
(org-test-with-temp-text "- item\n - <point>\n - sub-item 2"
|
||||
(org-cycle-item-indentation)))
|
||||
;; When cycling back into initial position, preserve bullet type.
|
||||
(should
|
||||
(equal "1. item\n - "
|
||||
(org-test-with-temp-text "1. item\n - <point>"
|
||||
(org-cycle-item-indentation)
|
||||
(let ((last-command 'org-cycle-item-indentation))
|
||||
(org-cycle-item-indentation))
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "1. item\n - tag :: "
|
||||
(org-test-with-temp-text "1. item\n - tag :: <point>"
|
||||
(org-cycle-item-indentation)
|
||||
(let ((last-command 'org-cycle-item-indentation))
|
||||
(org-cycle-item-indentation))
|
||||
(buffer-string))))
|
||||
;; When starting at top level, never outdent.
|
||||
(should
|
||||
(org-test-with-temp-text "- item\n- <point>"
|
||||
(org-cycle-item-indentation)
|
||||
(let ((last-command 'org-cycle-item-indentation))
|
||||
(org-cycle-item-indentation))
|
||||
(buffer-string))))
|
||||
|
||||
(ert-deftest test-org-list/move-item-down ()
|
||||
"Test `org-move-item-down' specifications."
|
||||
;; Standard test.
|
||||
(org-test-with-temp-text "- item 1\n- item 2"
|
||||
(org-move-item-down)
|
||||
(should (equal (buffer-string)
|
||||
"- item 2\n- item 1")))
|
||||
(should
|
||||
(equal "- item 2\n- item 1"
|
||||
(org-test-with-temp-text "- item 1\n- item 2"
|
||||
(org-move-item-down)
|
||||
(buffer-string))))
|
||||
;; Keep same column in item.
|
||||
(org-test-with-temp-text "- item 1\n- item 2"
|
||||
(forward-char 4)
|
||||
(org-move-item-down)
|
||||
(should (looking-at "em 1")))
|
||||
(should
|
||||
(org-test-with-temp-text "- it<point>em 1\n- item 2"
|
||||
(org-move-item-down)
|
||||
(looking-at "em 1")))
|
||||
;; Move sub-items.
|
||||
(org-test-with-temp-text "- item 1\n - sub-item 1\n- item 2"
|
||||
(org-move-item-down)
|
||||
@@ -504,28 +568,34 @@ b. Item 2<point>"
|
||||
(org-move-item-down)
|
||||
(buffer-string))))
|
||||
;; Error when trying to move the last item...
|
||||
(org-test-with-temp-text "- item 1\n- item 2"
|
||||
(forward-line)
|
||||
(should-error (org-move-item-down)))
|
||||
(should-error
|
||||
(org-test-with-temp-text "- item 1\n- item 2"
|
||||
(forward-line)
|
||||
(org-move-item-down)))
|
||||
;; ... unless `org-list-use-circular-motion' is non-nil. In this
|
||||
;; case, move to the first item.
|
||||
(org-test-with-temp-text "- item 1\n- item 2\n- item 3"
|
||||
(forward-line 2)
|
||||
(let ((org-list-use-circular-motion t)) (org-move-item-down))
|
||||
(should (equal (buffer-string) "- item 3\n- item 1\n- item 2\n")))
|
||||
(should
|
||||
(equal "- item 3\n- item 1\n- item 2\n"
|
||||
(org-test-with-temp-text "- item 1\n- item 2\n<point>- item 3"
|
||||
(let ((org-list-use-circular-motion t)) (org-move-item-down))
|
||||
(buffer-string))))
|
||||
;; Preserve item visibility.
|
||||
(org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
|
||||
(let ((org-cycle-include-plain-lists t))
|
||||
(search-forward "- item 1")
|
||||
(org-cycle)
|
||||
(search-forward "- item 2")
|
||||
(org-cycle))
|
||||
(search-backward "- item 1")
|
||||
(org-move-item-down)
|
||||
(forward-line)
|
||||
(should (org-invisible-p2))
|
||||
(search-backward " body 2")
|
||||
(should (org-invisible-p2)))
|
||||
(should
|
||||
(equal
|
||||
'(outline outline)
|
||||
(org-test-with-temp-text
|
||||
"* Headline\n<point>- item 1\n body 1\n- item 2\n body 2"
|
||||
(let ((org-cycle-include-plain-lists t))
|
||||
(org-cycle)
|
||||
(search-forward "- item 2")
|
||||
(org-cycle))
|
||||
(search-backward "- item 1")
|
||||
(org-move-item-down)
|
||||
(forward-line)
|
||||
(list (org-invisible-p2)
|
||||
(progn
|
||||
(search-backward " body 2")
|
||||
(org-invisible-p2))))))
|
||||
;; Preserve children visibility.
|
||||
(org-test-with-temp-text "* Headline
|
||||
- item 1
|
||||
@@ -607,9 +677,11 @@ b. Item 2<point>"
|
||||
(should-error (org-move-item-up)))
|
||||
;; ... unless `org-list-use-circular-motion' is non-nil. In this
|
||||
;; case, move to the first item.
|
||||
(org-test-with-temp-text "- item 1\n- item 2\n- item 3"
|
||||
(let ((org-list-use-circular-motion t)) (org-move-item-up))
|
||||
(should (equal (buffer-string) "- item 2\n- item 3\n- item 1")))
|
||||
(should
|
||||
(equal "- item 2\n- item 3\n- item 1"
|
||||
(org-test-with-temp-text "- item 1\n- item 2\n- item 3"
|
||||
(let ((org-list-use-circular-motion t)) (org-move-item-up))
|
||||
(buffer-string))))
|
||||
;; Preserve item visibility.
|
||||
(org-test-with-temp-text "* Headline\n- item 1\n body 1\n- item 2\n body 2"
|
||||
(let ((org-cycle-include-plain-lists t))
|
||||
@@ -747,6 +819,18 @@ b. Item 2<point>"
|
||||
(org-test-with-temp-text "- <point>item"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
;; When called at the very end of the list, insert new item as
|
||||
;; a sibling of the very last one.
|
||||
(should
|
||||
(equal "- A\n\n - B\n\n - "
|
||||
(org-test-with-temp-text "- A\n\n - B\n\n<point>"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "- A\n\n - B\n\n - "
|
||||
(org-test-with-temp-text "- A\n\n - B\n\n <point>"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
;; When called on tag in a descriptive list, insert new item before
|
||||
;; current one too.
|
||||
(should
|
||||
@@ -773,6 +857,17 @@ b. Item 2<point>"
|
||||
(let ((org-M-RET-may-split-line '((default . nil))))
|
||||
(org-insert-item))
|
||||
(buffer-string))))
|
||||
;; Re-order automatically.
|
||||
(should
|
||||
(equal "1. A\n\n2. \n\n3. \n\n4. B"
|
||||
(org-test-with-temp-text "1. A<point>\n\n2. \n\n3. B"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "1. a\n2. \n b\n3. c"
|
||||
(org-test-with-temp-text "1. a<point>\n b\n2. c"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
;; Preserve list visibility when inserting an item.
|
||||
(should
|
||||
(equal
|
||||
@@ -784,7 +879,26 @@ b. Item 2<point>"
|
||||
(org-cycle)
|
||||
(org-insert-item)
|
||||
(list (get-char-property (line-beginning-position 0) 'invisible)
|
||||
(get-char-property (line-end-position 2) 'invisible)))))))
|
||||
(get-char-property (line-end-position 2) 'invisible))))))
|
||||
;; Test insertion in area after a sub-list. In particular, if point
|
||||
;; is right at the end of the previous sub-list, still insert
|
||||
;; a sub-item in that list.
|
||||
(should
|
||||
(= 2
|
||||
(org-test-with-temp-text "- item\n - sub-list\n<point> resume item"
|
||||
(org-insert-item)
|
||||
(current-indentation))))
|
||||
(should
|
||||
(= 0
|
||||
(org-test-with-temp-text "- item\n - sub-list\n resume item<point>"
|
||||
(org-insert-item)
|
||||
(current-indentation))))
|
||||
;; Test splitting with blanks around.
|
||||
(should
|
||||
(equal "- A\n B\n- C\n - D\n- [ ] E"
|
||||
(org-test-with-temp-text "- A\n B <point> C\n - D\n- [ ] E"
|
||||
(org-insert-item)
|
||||
(buffer-string)))))
|
||||
|
||||
(ert-deftest test-org-list/repair ()
|
||||
"Test `org-list-repair' specifications."
|
||||
@@ -917,6 +1031,36 @@ b. Item 2<point>"
|
||||
(org-update-checkbox-count))
|
||||
(buffer-string)))))
|
||||
|
||||
|
||||
;;; API
|
||||
|
||||
(ert-deftest test-org-list/at-radio-list-p ()
|
||||
"Test `org-at-radio-list-p' specifications."
|
||||
(should
|
||||
(org-test-with-temp-text "#+attr_org: :radio t\n<point>- foo"
|
||||
(org-at-radio-list-p)))
|
||||
(should
|
||||
(org-test-with-temp-text "#+attr_org: :radio t\n- foo\n<point>- bar"
|
||||
(org-at-radio-list-p)))
|
||||
(should
|
||||
(org-test-with-temp-text "#+ATTR_ORG: :radio t\n<point>- foo"
|
||||
(org-at-radio-list-p)))
|
||||
(should
|
||||
(org-test-with-temp-text "#+attr_org: :radio bar\n<point>- foo"
|
||||
(org-at-radio-list-p)))
|
||||
(should-not
|
||||
(org-test-with-temp-text "#+attr_org: :radio nil\n<point>- foo"
|
||||
(org-at-radio-list-p)))
|
||||
(should-not
|
||||
(org-test-with-temp-text "<point>- foo"
|
||||
(org-at-radio-list-p)))
|
||||
(should-not
|
||||
(org-test-with-temp-text "#+attr_org: :radio t\n- foo\n <point>bar"
|
||||
(org-at-radio-list-p)))
|
||||
(should-not
|
||||
(org-test-with-temp-text
|
||||
"#+attr_org: :radio t\n#+begin_example\n<point>- foo\n#+end_example"
|
||||
(org-at-radio-list-p))))
|
||||
|
||||
|
||||
;;; Miscellaneous
|
||||
@@ -971,6 +1115,13 @@ b. Item 2<point>"
|
||||
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n\n\nText"
|
||||
(org-toggle-item nil)
|
||||
(buffer-string))))
|
||||
;; When no region is marked and point is on a blank line
|
||||
;; only operate on current line.
|
||||
(should
|
||||
(equal " \n* H :tag:"
|
||||
(org-test-with-temp-text "<point> \n* H :tag:"
|
||||
(org-toggle-item nil)
|
||||
(buffer-string))))
|
||||
;; When a region is marked and first line is a headline, all
|
||||
;; headlines are turned into items.
|
||||
(should
|
||||
|
||||
@@ -304,6 +304,72 @@
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max))))))
|
||||
|
||||
(ert-deftest test-org-macro/author ()
|
||||
"Test {{{author}}} macro."
|
||||
;; Return AUTHOR keyword value.
|
||||
(should
|
||||
(equal "me"
|
||||
(org-test-with-temp-text "#+author: me\n<point>{{{author}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max)))))
|
||||
;; When AUTHOR keyword is missing, return the empty string.
|
||||
(should
|
||||
(equal ""
|
||||
(org-test-with-temp-text "{{{author}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max))))))
|
||||
|
||||
(ert-deftest test-org-macro/email ()
|
||||
"Test {{{email}}} macro."
|
||||
;; Return EMAIL keyword value.
|
||||
(should
|
||||
(equal "me@home"
|
||||
(org-test-with-temp-text "#+email: me@home\n<point>{{{email}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max)))))
|
||||
;; When EMAIL keyword is missing, return the empty string.
|
||||
(should
|
||||
(equal ""
|
||||
(org-test-with-temp-text "{{{email}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max))))))
|
||||
|
||||
(ert-deftest test-org-macro/title ()
|
||||
"Test {{{title}}} macro."
|
||||
;; Return TITLE keyword value.
|
||||
(should
|
||||
(equal "Foo!"
|
||||
(org-test-with-temp-text "#+title: Foo!\n<point>{{{title}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max)))))
|
||||
;; When TITLE keyword is missing, return the empty string.
|
||||
(should
|
||||
(equal ""
|
||||
(org-test-with-temp-text "{{{title}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max)))))
|
||||
;; When multiple TITLE keywords are used, concatenate them.
|
||||
(should
|
||||
(equal "Foo Bar!"
|
||||
(org-test-with-temp-text
|
||||
"#+title: Foo\n#+title: Bar!\n<point>{{{title}}}"
|
||||
(org-macro-initialize-templates)
|
||||
(org-macro-replace-all org-macro-templates)
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position) (point-max))))))
|
||||
|
||||
(ert-deftest test-org-macro/escape-arguments ()
|
||||
"Test `org-macro-escape-arguments' specifications."
|
||||
;; Regular tests.
|
||||
|
||||
@@ -154,6 +154,25 @@
|
||||
(org-test-with-temp-text
|
||||
"* H1\n:PROPERTIES:\n:UNNUMBERED: t\n:END:\n** H2"
|
||||
(let ((org-num-skip-unnumbered t)) (org-num-mode 1))
|
||||
(mapcar (lambda (o) (overlay-get o 'after-string))
|
||||
(overlays-in (point-min) (point-max))))))
|
||||
;; Do not choke on empty headlines.
|
||||
(should
|
||||
(equal '("1 ")
|
||||
(org-test-with-temp-text "* "
|
||||
(let ((org-num-skip-commented t)) (org-num-mode 1))
|
||||
(mapcar (lambda (o) (overlay-get o 'after-string))
|
||||
(overlays-in (point-min) (point-max))))))
|
||||
(should
|
||||
(equal '("1 ")
|
||||
(org-test-with-temp-text "* "
|
||||
(let ((org-num-skip-unnumbered t)) (org-num-mode 1))
|
||||
(mapcar (lambda (o) (overlay-get o 'after-string))
|
||||
(overlays-in (point-min) (point-max))))))
|
||||
(should
|
||||
(equal '("1 ")
|
||||
(org-test-with-temp-text "* "
|
||||
(let ((org-num-skip-footnotes t)) (org-num-mode 1))
|
||||
(mapcar (lambda (o) (overlay-get o 'after-string))
|
||||
(overlays-in (point-min) (point-max)))))))
|
||||
|
||||
|
||||
@@ -75,6 +75,21 @@
|
||||
(buffer-string))
|
||||
t)))
|
||||
|
||||
(ert-deftest test-org-pcomplete/src-block ()
|
||||
"Test Babel source block header arguments completion."
|
||||
(should
|
||||
(string-prefix-p
|
||||
"#+begin_src emacs-lisp"
|
||||
(org-test-with-temp-text "#+begin_src emac<point>"
|
||||
(pcomplete)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-prefix-p
|
||||
"#+begin_src emacs-lisp :session"
|
||||
(org-test-with-temp-text "#+begin_src emacs-lisp :sess<point>"
|
||||
(pcomplete)
|
||||
(buffer-string)))))
|
||||
|
||||
(ert-deftest test-org-pcomplete/link ()
|
||||
"Test link completion"
|
||||
(should
|
||||
|
||||
@@ -58,6 +58,17 @@
|
||||
(goto-char (point-max))
|
||||
(should-error (org-edit-special))))
|
||||
|
||||
(ert-deftest test-org-src/undo ()
|
||||
"Undo-ing an edit buffer should not go back to empty state."
|
||||
(org-test-with-temp-text "
|
||||
#+begin_src emacs-lisp<point>
|
||||
(message hello)
|
||||
#+end_src
|
||||
"
|
||||
(org-edit-special)
|
||||
(should-error (undo))
|
||||
(org-edit-src-exit)))
|
||||
|
||||
(ert-deftest test-org-src/empty-block ()
|
||||
"Editing empty block."
|
||||
(org-test-with-temp-text
|
||||
|
||||
@@ -1304,6 +1304,66 @@ See also `test-org-table/copy-field'."
|
||||
(should (string= got
|
||||
expect)))))
|
||||
|
||||
|
||||
;;; Tables as Lisp
|
||||
|
||||
(ert-deftest test-org-table/to-lisp ()
|
||||
"Test `orgtbl-to-lisp' specifications."
|
||||
;; 2x2 no header
|
||||
(should
|
||||
(equal '(("a" "b") ("c" "d"))
|
||||
(org-table-to-lisp "|a|b|\n|c|d|")))
|
||||
;; 2x2 with 1-line header
|
||||
(should
|
||||
(equal '(("a" "b") hline ("c" "d"))
|
||||
(org-table-to-lisp "|a|b|\n|-\n|c|d|")))
|
||||
;; 2x4 with 2-line header
|
||||
(should
|
||||
(equal '(("a" "b") ("A" "B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-to-lisp "|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|")))
|
||||
;; leading hlines do not get stripped
|
||||
(should
|
||||
(equal '(hline ("a" "b") hline ("c" "d"))
|
||||
(org-table-to-lisp "|-\n|a|b|\n|-\n|c|d|")))
|
||||
(should
|
||||
(equal '(hline ("a" "b") ("c" "d"))
|
||||
(org-table-to-lisp "|-\n|a|b|\n|c|d|")))
|
||||
(should
|
||||
(equal '(hline hline hline hline ("a" "b") ("c" "d"))
|
||||
(org-table-to-lisp "|-\n|-\n|-\n|-\n|a|b|\n|c|d|"))))
|
||||
|
||||
(ert-deftest test-org-table/collapse-header ()
|
||||
"Test `orgtbl-to-lisp' specifications."
|
||||
;; 2x2 no header - no collapsing
|
||||
(should
|
||||
(equal '(("a" "b") ("c" "d"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|c|d|"))))
|
||||
;; 2x2 with 1-line header - no collapsing
|
||||
(should
|
||||
(equal '(("a" "b") hline ("c" "d"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|-\n|c|d|"))))
|
||||
;; 2x4 with 2-line header - collapsed
|
||||
(should
|
||||
(equal '(("a A" "b B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|"))))
|
||||
;; 2x4 with 2-line header, custom glue - collapsed
|
||||
(should
|
||||
(equal '(("a.A" "b.B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|") ".")))
|
||||
;; 2x4 with 2-line header, threshold 1 - not collapsed
|
||||
(should
|
||||
(equal '(("a" "b") ("A" "B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|") nil 1)))
|
||||
;; 2x4 with 2-line header, threshold 2 - collapsed
|
||||
(should
|
||||
(equal '(("a A" "b B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|") nil 2)))
|
||||
;; 2x8 with 6-line header, default threshold 5 - not collapsed
|
||||
(should
|
||||
(equal '(("a" "b") ("A" "B") ("a" "b") ("A" "B") ("a" "b") ("A" "B") hline ("c" "d") ("aa" "bb"))
|
||||
(org-table-collapse-header (org-table-to-lisp "|a|b|\n|A|B|\n|a|b|\n|A|B|\n|a|b|\n|A|B|\n|-\n|c|d|\n|aa|bb|")))))
|
||||
|
||||
|
||||
;;; Radio Tables
|
||||
|
||||
(ert-deftest test-org-table/to-generic ()
|
||||
@@ -1768,7 +1828,16 @@ See also `test-org-table/copy-field'."
|
||||
(equal "| <c> |\n| 1 |\n| 123 |"
|
||||
(org-test-with-temp-text "| <c> |\n| 1 |\n| 123 |"
|
||||
(let ((org-table-number-fraction 0.5)) (org-table-align))
|
||||
(buffer-string)))))
|
||||
(buffer-string))))
|
||||
;; Handle gracefully tables with only horizontal rules.
|
||||
(should
|
||||
(org-test-with-temp-text "|-<point>--|"
|
||||
(org-table-align)
|
||||
t))
|
||||
(should
|
||||
(org-test-with-temp-text "|-<point>--|---------|\n|---|---|-----|"
|
||||
(org-table-align)
|
||||
t)))
|
||||
|
||||
(ert-deftest test-org-table/align-buffer-tables ()
|
||||
"Align all tables when updating buffer."
|
||||
@@ -1896,7 +1965,7 @@ See also `test-org-table/copy-field'."
|
||||
(org-table-sort-lines nil ?n)
|
||||
(buffer-string)))))
|
||||
|
||||
|
||||
|
||||
;;; Formulas
|
||||
|
||||
(ert-deftest test-org-table/eval-formula ()
|
||||
@@ -2340,6 +2409,50 @@ See also `test-org-table/copy-field'."
|
||||
(ignore-errors (org-table-previous-field))
|
||||
(char-after)))))
|
||||
|
||||
|
||||
;;; Deleting columns
|
||||
(ert-deftest test-org-table/delete-column ()
|
||||
"Test `org-table-delete-column'."
|
||||
;; Error when outside a table.
|
||||
(should-error
|
||||
(org-test-with-temp-text "Paragraph"
|
||||
(org-table-delete-column)))
|
||||
;; Delete first column.
|
||||
(should
|
||||
(equal "| a |\n"
|
||||
(org-test-with-temp-text
|
||||
"| <point> | a |\n"
|
||||
(org-table-delete-column)
|
||||
(buffer-string))))
|
||||
;; Delete column and check location of point.
|
||||
(should
|
||||
(= 2
|
||||
(org-test-with-temp-text
|
||||
"| a | <point>b | c |"
|
||||
(org-table-delete-column)
|
||||
(org-table-current-column))))
|
||||
;; Delete column when at end of line and after a "|".
|
||||
(should
|
||||
(equal "| a |\n"
|
||||
(org-test-with-temp-text
|
||||
"| a | b |<point>\n"
|
||||
(org-table-delete-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "| a |\n"
|
||||
(org-test-with-temp-text
|
||||
"| a | b | <point>\n"
|
||||
(org-table-delete-column)
|
||||
(buffer-string))))
|
||||
;; Delete two columns starting with the last column.
|
||||
(should
|
||||
(equal "| a |\n"
|
||||
(org-test-with-temp-text
|
||||
"| a | b | c<point> |"
|
||||
(org-table-delete-column)
|
||||
(org-table-delete-column)
|
||||
(buffer-string)))))
|
||||
|
||||
|
||||
;;; Inserting rows, inserting columns
|
||||
|
||||
@@ -2351,49 +2464,59 @@ See also `test-org-table/copy-field'."
|
||||
(org-table-insert-column)))
|
||||
;; Insert new column after current one.
|
||||
(should
|
||||
(equal "| a | |\n"
|
||||
(equal "| | a |\n"
|
||||
(org-test-with-temp-text "| a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "| a | | b |\n"
|
||||
(equal "| | a | b |\n"
|
||||
(org-test-with-temp-text "| <point>a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
;; Move point into the newly created column.
|
||||
(should
|
||||
(equal " |"
|
||||
(equal " | a |"
|
||||
(org-test-with-temp-text "| <point>a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
(should
|
||||
(equal " | b |"
|
||||
(equal " | a | b |"
|
||||
(org-test-with-temp-text "| <point>a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
;; Handle missing vertical bar in the last column.
|
||||
(should
|
||||
(equal "| a | |\n"
|
||||
(equal "| | a |\n"
|
||||
(org-test-with-temp-text "| a"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal " |"
|
||||
(equal " | a |"
|
||||
(org-test-with-temp-text "| <point>a"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
;; Handle column insertion when point is before first column.
|
||||
(should
|
||||
(equal " | a | |\n"
|
||||
(equal " | | a |\n"
|
||||
(org-test-with-temp-text " | a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal " | a | | b |\n"
|
||||
(equal " | | a | b |\n"
|
||||
(org-test-with-temp-text " | a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string)))))
|
||||
|
||||
(ert-deftest test-org-table/insert-column-with-formula ()
|
||||
"Test `org-table-insert-column' with a formula in place."
|
||||
(should
|
||||
(equal "| | 1 | 1 | 2 |
|
||||
#+TBLFM: $4=$2+$3"
|
||||
(org-test-with-temp-text
|
||||
"| 1<point> | 1 | 2 |
|
||||
#+TBLFM: $3=$1+$2"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point-min) (point-max))))))
|
||||
|
||||
|
||||
;;; Moving single cells
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -280,7 +280,12 @@ num:2 <:active")))
|
||||
(should-not
|
||||
(equal "Mine"
|
||||
(org-test-with-parsed-data "* COMMENT H1\n** H2\n#+EMAIL: Mine"
|
||||
(plist-get info :email)))))
|
||||
(plist-get info :email))))
|
||||
;; Keywords can be set to an empty value.
|
||||
(should-not
|
||||
(let ((user-full-name "Me"))
|
||||
(org-test-with-parsed-data "#+AUTHOR:"
|
||||
(plist-get info :author)))))
|
||||
|
||||
(ert-deftest test-org-export/get-subtree-options ()
|
||||
"Test setting options from headline's properties."
|
||||
@@ -2971,7 +2976,7 @@ Para2"
|
||||
(string-match
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters "foo" :export (lambda (p d f) "success"))
|
||||
(org-link-set-parameters "foo" :export (lambda (p d f i) "success"))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
@@ -2980,14 +2985,14 @@ Para2"
|
||||
'((section . (lambda (s c i) c))
|
||||
(paragraph . (lambda (p c i) c))
|
||||
(link . (lambda (l c i)
|
||||
(or (org-export-custom-protocol-maybe l c 'test)
|
||||
(or (org-export-custom-protocol-maybe l c 'test i)
|
||||
"failure")))))))))
|
||||
(should-not
|
||||
(string-match
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters
|
||||
"foo" :export (lambda (p d f) (and (eq f 'test) "success")))
|
||||
"foo" :export (lambda (p d f i) (and (eq f 'test) "success")))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
@@ -2996,7 +3001,7 @@ Para2"
|
||||
'((section . (lambda (s c i) c))
|
||||
(paragraph . (lambda (p c i) c))
|
||||
(link . (lambda (l c i)
|
||||
(or (org-export-custom-protocol-maybe l c 'no-test)
|
||||
(or (org-export-custom-protocol-maybe l c 'no-test i)
|
||||
"failure")))))))))
|
||||
;; Ignore anonymous back-ends.
|
||||
(should-not
|
||||
@@ -3004,7 +3009,7 @@ Para2"
|
||||
"success"
|
||||
(progn
|
||||
(org-link-set-parameters
|
||||
"foo" :export (lambda (p d f) (and (eq f 'test) "success")))
|
||||
"foo" :export (lambda (p d f i) (and (eq f 'test) "success")))
|
||||
(org-export-string-as
|
||||
"[[foo:path]]"
|
||||
(org-export-create-backend
|
||||
@@ -3012,7 +3017,7 @@ Para2"
|
||||
'((section . (lambda (s c i) c))
|
||||
(paragraph . (lambda (p c i) c))
|
||||
(link . (lambda (l c i)
|
||||
(or (org-export-custom-protocol-maybe l c nil)
|
||||
(or (org-export-custom-protocol-maybe l c nil i)
|
||||
"failure"))))))))))
|
||||
|
||||
(ert-deftest test-org-export/get-coderef-format ()
|
||||
@@ -4124,6 +4129,16 @@ Another text. (ref:text)
|
||||
(org-export-table-has-header-p
|
||||
(org-element-map tree 'table 'identity info 'first-match)
|
||||
info)))
|
||||
;; With a multi-line header.
|
||||
(should
|
||||
(org-test-with-parsed-data "
|
||||
| a | b |
|
||||
| 0 | 1 |
|
||||
|---+---|
|
||||
| a | w |"
|
||||
(org-export-table-has-header-p
|
||||
(org-element-map tree 'table 'identity info 'first-match)
|
||||
info)))
|
||||
;; Without an header.
|
||||
(should-not
|
||||
(org-test-with-parsed-data "
|
||||
|
||||
@@ -199,6 +199,7 @@ otherwise place the point at the beginning of the inserted text."
|
||||
(goto-char (1+ (match-beginning 0))))
|
||||
(insert inside-text)
|
||||
(goto-char (point-min))))
|
||||
(font-lock-ensure (point-min) (point-max))
|
||||
,@body)))
|
||||
(def-edebug-spec org-test-with-temp-text (form body))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user