test-ob-emacs-lisp.el 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; test-ob-emacs-lisp.el
  2. ;; Copyright (c) 2012-2018 Free Software Foundation, Inc.
  3. ;; Authors: Eric Schulte, Martyn Jago
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Comments:
  16. ;; Org tests for ob-emacs-lisp.el live here
  17. ;;; Code:
  18. (ert-deftest ob-emacs-lisp/commented-last-block-line-no-var ()
  19. (org-test-with-temp-text-in-file "
  20. #+begin_src emacs-lisp
  21. ;;
  22. #+end_src"
  23. (org-babel-next-src-block)
  24. (org-babel-execute-maybe)
  25. (should (re-search-forward "results:" nil t))
  26. (forward-line)
  27. (should
  28. (string=
  29. ""
  30. (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
  31. (org-test-with-temp-text-in-file "
  32. #+begin_src emacs-lisp
  33. \"some text\";;
  34. #+end_src"
  35. (org-babel-next-src-block)
  36. (org-babel-execute-maybe)
  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. (org-babel-next-src-block)
  49. (org-babel-execute-maybe)
  50. (re-search-forward "results" nil t)
  51. (forward-line)
  52. (should (string=
  53. ""
  54. (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
  55. (ert-deftest ob-emacs-lisp/commented-last-block-line ()
  56. (should
  57. (string= ": 2"
  58. (org-test-with-temp-text-in-file "
  59. #+begin_src emacs-lisp :var a=2
  60. 2;;
  61. #+end_src"
  62. (org-babel-next-src-block)
  63. (org-babel-execute-maybe)
  64. (re-search-forward "results" nil t)
  65. (buffer-substring-no-properties (line-beginning-position 2)
  66. (line-end-position 2))))))
  67. (provide 'test-ob-emacs-lisp)
  68. ;;; test-ob-emacs-lisp.el ends here