1 ;;; test-ob-lua.el --- tests for ob-lua.el
3 ;; Copyright (c) 2016 Thibault Marin
4 ;; Authors: Thibault Marin
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 (unless (featurep 'ob-lua
)
23 (signal 'missing-test-dependency
"Support for Lua code blocks"))
25 (ert-deftest test-ob-lua
/simple-value
()
26 "Test associative array return by value."
29 (org-test-with-temp-text
34 #+header: :results value
39 (org-babel-next-src-block)
40 (org-babel-execute-src-block)))))
42 (ert-deftest test-ob-lua
/simple-output
()
43 "Test text output from table."
46 (org-test-with-temp-text
50 #+header: :results output
53 print('result: ' .. x[1][3])
55 (org-babel-next-src-block)
56 (org-babel-execute-src-block)))))
59 (ert-deftest test-ob-lua
/colnames-yes-header-argument
()
60 "Test table passing with `colnames' header."
63 (org-test-with-temp-text
70 #+header: :colnames yes
75 (org-babel-next-src-block)
76 (org-babel-execute-src-block)))))
79 (ert-deftest test-ob-lua
/colnames-yes-header-argument-pp
()
80 "Test table passing with `colnames' header and pp option."
82 (equal "a = 12\nb = 13\n"
83 (org-test-with-temp-text
90 #+header: :results value pp
91 #+header: :colnames yes
96 (org-babel-next-src-block)
97 (org-babel-execute-src-block)))))
99 (ert-deftest test-ob-lua
/colnames-nil-header-argument
()
100 "Test table with `colnames' set to `nil'."
102 (equal "1 = a\n2 = b\n"
103 (org-test-with-temp-text
110 #+header: :colnames nil
111 #+header: :var x = eg
112 #+header: :results value pp
116 (org-babel-next-src-block)
117 (org-babel-execute-src-block)))))
119 (ert-deftest test-ob-lua
/colnames-no-header-argument
()
120 "Test table passing without `colnames'."
122 (equal "1 = col\n2 = a\n3 = b\n"
123 (org-test-with-temp-text
130 #+header: :colnames no
131 #+header: :var x = eg
132 #+header: :results value pp
136 (org-babel-next-src-block)
137 (org-babel-execute-src-block)))))
139 (provide 'test-ob-lua
)
141 ;;; test-ob-lua.el ends here