1 ;;; test-ob-vala.el --- tests for ob-vala.el
3 ;; Copyright (C) 2017 Christian Garbs
4 ;; Authors: Christian Garbs
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-vala
)
23 (signal 'missing-test-dependency
"Support for Vala code blocks"))
25 (org-test-for-executable org-babel-vala-compiler
)
27 (ert-deftest ob-vala
/assert
()
30 (ert-deftest ob-vala
/static-output
()
31 "Parse static output to variable."
33 (org-test-with-temp-text
36 class Demo.HelloWorld : GLib.Object {
37 public static int main(string[] args) {
38 stdout.printf(\"42\n\");
43 (org-babel-next-src-block)
44 (org-babel-execute-src-block)))))
46 (ert-deftest ob-vala
/return-numerics
()
47 "Return multiple numeric values."
48 (should (equal '((0) (1) (2))
49 (org-test-with-temp-text
52 class Demo.HelloWorld : GLib.Object {
53 public static int main(string[] args) {
54 for (int i=0; i<3; i++) {
55 stdout.printf(\"%d\n\", i);
61 (org-babel-next-src-block)
62 (org-babel-execute-src-block)))))
64 (ert-deftest ob-vala
/compiler-args
()
65 "Pass compiler arguments."
66 (should (string= "Foo"
67 (org-test-with-temp-text
69 #+begin_src vala :flags -D FOO
70 class Demo.HelloWorld : GLib.Object {
71 public static int main(string[] args) {
73 stdout.printf(\"Foo\n\");
75 stdout.printf(\"No foo\n\");
81 (org-babel-next-src-block)
82 (org-babel-execute-src-block)))))
84 (ert-deftest ob-vala
/comdline-args
()
85 "Pass commandline arguments."
86 (should (equal '(("foo") ("bar"))
87 (org-test-with-temp-text
89 #+begin_src vala :cmdline foo bar
90 class Demo.HelloWorld : GLib.Object {
91 public static int main(string[] args) {
92 // skip args[0], it is the binary name
93 for (int i=1; i < args.length; i++) {
94 stdout.printf(\"%s\n\" , args[i]);
100 (org-babel-next-src-block)
101 (org-babel-execute-src-block)))))
104 ;;; test-ob-vala.el ends here