1 ;;; test-ob-R.el --- tests for ob-R.el
3 ;; Copyright (c) 2011-2014 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 (org-test-for-executable "R")
23 (unless (featurep 'ess
)
24 (signal 'missing-test-dependency
"ESS"))
25 (unless (featurep 'ob-R
)
26 (signal 'missing-test-dependency
"Support for R code blocks"))
28 (ert-deftest test-ob-R
/simple-session
()
29 (let (ess-ask-for-ess-directory ess-history-file
)
30 (org-test-with-temp-text
31 "#+begin_src R :session R\n paste(\"Yep!\")\n#+end_src\n"
32 (should (string= "Yep!" (org-babel-execute-src-block))))))
34 (ert-deftest test-ob-R
/colnames-yes-header-argument
()
35 (org-test-with-temp-text "#+name: eg
41 #+header: :colnames yes
46 (org-babel-next-src-block)
47 (should (equal '(("col") hline
("a") ("b"))
48 (org-babel-execute-src-block)))))
50 (ert-deftest test-ob-R
/colnames-nil-header-argument
()
51 (org-test-with-temp-text "#+name: eg
57 #+header: :colnames nil
62 (org-babel-next-src-block)
63 (should (equal '(("col") hline
("a") ("b"))
64 (org-babel-execute-src-block)))))
66 (ert-deftest test-ob-R
/colnames-no-header-argument
()
67 (org-test-with-temp-text "#+name: eg
73 #+header: :colnames no
78 (org-babel-next-src-block)
79 (should (equal '(("col") ("a") ("b"))
80 (org-babel-execute-src-block)))))
82 (ert-deftest test-ob-R
/results-file
()
83 (let (ess-ask-for-ess-directory ess-history-file
)
84 (org-test-with-temp-text
86 #+BEGIN_SRC R :results file
87 a <- file.path(\"junk\", \"test.org\")
90 (goto-char (point-min)) (org-babel-execute-maybe)
91 (org-babel-goto-named-result "TESTSRC") (forward-line 1)
92 (should (string= "[[file:junk/test.org]]"
93 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
94 (goto-char (point-min)) (forward-line 1)
95 (insert "#+header: :session\n")
96 (goto-char (point-min)) (org-babel-execute-maybe)
97 (org-babel-goto-named-result "TESTSRC") (forward-line 1)
98 (should (string= "[[file:junk/test.org]]"
99 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
102 ;;; test-ob-R.el ends here