test-ob-emacs-lisp.el 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; test-ob-emacs-lisp.el
  2. ;; Copyright (c) 2012 Free Software Foundation, Inc.
  3. ;; Authors: Eric Schulte, Martyn Jago
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments:
  7. ;; Org-mode tests for ob-emacs-lisp.el live here
  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 ob-emacs-lisp/commented-last-block-line-no-var ()
  17. (org-test-with-temp-text-in-file "
  18. #+begin_src emacs-lisp
  19. ;;
  20. #+end_src"
  21. (progn
  22. (org-babel-next-src-block)
  23. (org-ctrl-c-ctrl-c)
  24. (should (re-search-forward "results:" nil t))
  25. (forward-line)
  26. (should
  27. (string=
  28. ""
  29. (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
  30. (org-test-with-temp-text-in-file "
  31. #+begin_src emacs-lisp
  32. \"some text\";;
  33. #+end_src"
  34. (progn
  35. (org-babel-next-src-block)
  36. (org-ctrl-c-ctrl-c)
  37. (should (re-search-forward "results:" nil t))
  38. (forward-line)
  39. (should
  40. (string=
  41. ": some text"
  42. (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
  43. (ert-deftest ob-emacs-lisp/commented-last-block-line-with-var ()
  44. (org-test-with-temp-text-in-file "
  45. #+begin_src emacs-lisp :var a=1
  46. ;;
  47. #+end_src"
  48. (progn
  49. (org-babel-next-src-block)
  50. (org-ctrl-c-ctrl-c)
  51. (re-search-forward "results" nil t)
  52. (forward-line)
  53. (should (string=
  54. ""
  55. (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
  56. (org-test-with-temp-text-in-file "
  57. #+begin_src emacs-lisp :var a=2
  58. 2;;
  59. #+end_src"
  60. (progn
  61. (org-babel-next-src-block)
  62. (org-ctrl-c-ctrl-c)
  63. (re-search-forward "results" nil t)
  64. (forward-line)
  65. (should (string=
  66. ": 2"
  67. (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
  68. (provide 'test-ob-emacs-lisp)
  69. ;;; test-ob-emacs-lisp.el ends here