test-ob-lob.el 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ;;; test-ob-lob.el
  2. ;; Copyright (c) 2010 Eric Schulte
  3. ;; Authors: Eric Schulte
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments:
  7. ;; Template test file for Org-mode tests
  8. ;;; Code:
  9. (let ((load-path (cons (expand-file-name
  10. ".." (file-name-directory
  11. (or load-file-name buffer-file-name)))
  12. load-path)))
  13. (require 'org-test)
  14. (require 'org-test-ob-consts))
  15. ;;; Tests
  16. (ert-deftest test-ob-lob/ingest ()
  17. "Test the ingestion of an org-mode file."
  18. (should (< 0 (org-babel-lob-ingest
  19. (expand-file-name "babel.org" org-test-example-dir)))))
  20. (ert-deftest test-ob-lob/call-with-header-arguments ()
  21. "Test the evaluation of a library of babel #+call: line."
  22. (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
  23. (move-beginning-of-line 1)
  24. (forward-line 6)
  25. (message (buffer-substring (point-at-bol) (point-at-eol)))
  26. (should (string= "testing" (org-babel-lob-execute
  27. (org-babel-lob-get-info))))
  28. (forward-line 1)
  29. (should (string= "testing" (caar (org-babel-lob-execute
  30. (org-babel-lob-get-info)))))
  31. (forward-line 1)
  32. (should (string= "testing" (org-babel-lob-execute
  33. (org-babel-lob-get-info))))
  34. (forward-line 1)
  35. (should (string= "testing" (caar (org-babel-lob-execute
  36. (org-babel-lob-get-info)))))
  37. (forward-line 1)
  38. (should (string= "testing" (org-babel-lob-execute
  39. (org-babel-lob-get-info))))
  40. (forward-line 1)
  41. (should (string= "testing" (caar (org-babel-lob-execute
  42. (org-babel-lob-get-info)))))
  43. (forward-line 1) (beginning-of-line) (forward-char 27)
  44. (should (string= "testing" (org-babel-lob-execute
  45. (org-babel-lob-get-info))))
  46. (forward-line 1) (beginning-of-line) (forward-char 27)
  47. (should (string= "testing" (caar (org-babel-lob-execute
  48. (org-babel-lob-get-info)))))
  49. (forward-line 1) (beginning-of-line)
  50. (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
  51. (forward-line 1)
  52. (should (string= "testing" (org-babel-lob-execute
  53. (org-babel-lob-get-info))))))
  54. (ert-deftest test-ob-lob/export-lob-lines ()
  55. "Test the export of a variety of library babel call lines."
  56. (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
  57. (org-narrow-to-subtree)
  58. (let ((html (org-export-as-html nil nil nil 'string 'body-only)))
  59. ;; check the location of each exported number
  60. (with-temp-buffer
  61. (insert html) (goto-char (point-min))
  62. ;; 0 should be on a line by itself
  63. (should (re-search-forward "0" nil t))
  64. (should (string= "0" (buffer-substring (point-at-bol) (point-at-eol))))
  65. ;; 2 should be in <code> tags
  66. (should (re-search-forward "2" nil t))
  67. (should (re-search-forward (regexp-quote "</code>") (point-at-eol) t))
  68. (should (re-search-backward (regexp-quote "<code>") (point-at-bol) t))
  69. ;; 4 should not be exported
  70. (should (not (re-search-forward "4" nil t)))
  71. ;; 6 should also be inline
  72. (should (re-search-forward "6" nil t))
  73. (should (re-search-forward (regexp-quote "</code>") (point-at-eol) t))
  74. (should (re-search-backward (regexp-quote "<code>") (point-at-bol) t))))))
  75. (provide 'test-ob-lob)
  76. ;;; test-ob-lob.el ends here