test-ob-perl.el 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ;;; test-ob-perl.el --- tests for ob-perl.el
  2. ;; Copyright (c) 2013, 2014 Achim Gratz
  3. ;; Authors: Achim Gratz
  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. ;;; Code:
  16. (org-test-for-executable "perl")
  17. (unless (featurep 'ob-perl)
  18. (signal 'missing-test-dependency "Support for perl code blocks"))
  19. (ert-deftest test-ob-perl/simple-output ()
  20. (org-test-with-temp-text "
  21. #+header: :results output
  22. #+begin_src perl
  23. print qq(Hi Mom!$/I'm home.);
  24. #+end_src"
  25. (org-babel-next-src-block)
  26. (should (equal "Hi Mom!\nI'm home."
  27. (org-babel-execute-src-block)))))
  28. (ert-deftest test-ob-perl/simple-value ()
  29. (org-test-with-temp-text "
  30. #+header: :results value
  31. #+begin_src perl
  32. qq(Hi Mom!$/I'm home.);
  33. #+end_src"
  34. (org-babel-next-src-block)
  35. (should (equal '(("Hi Mom!") ("I'm home."))
  36. (org-babel-execute-src-block)))))
  37. (ert-deftest test-ob-perl/table-passthrough-colnames-nil ()
  38. (org-test-with-temp-text "#+name: eg
  39. | col1 | col2 |
  40. |------+------|
  41. | a | 1 |
  42. | b | 2.0 |
  43. #+header: :colnames nil
  44. #+header: :var x = eg
  45. #+begin_src perl
  46. #+end_src"
  47. (org-babel-next-src-block)
  48. (should (equal '(("col1" "col2") hline ("a" 1) ("b" 2.0))
  49. (org-babel-execute-src-block)))))
  50. (ert-deftest test-ob-perl/table-passthrough-colnames-no ()
  51. (org-test-with-temp-text "#+name: eg
  52. | col1 | col2 |
  53. |------+------|
  54. | a | 1 |
  55. | b | 2.0 |
  56. #+header: :colnames no
  57. #+header: :var x = eg
  58. #+begin_src perl
  59. #+end_src"
  60. (org-babel-next-src-block)
  61. (should (equal '(("col1" "col2") ("a" 1) ("b" 2.0))
  62. (org-babel-execute-src-block)))))
  63. (provide 'test-ob-perl)
  64. ;;; test-ob-perl.el ends here