org-table: Improve shrinking on right-aligned and centered columns
[org-mode/org-tableheadings.git] / testing / lisp / test-ob-vala.el
blob920322229a82abf9c71ae3f63e45bb8cb2ea5223
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/>.
21 ;;; Code:
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 ()
28 (should t))
30 (ert-deftest ob-vala/static-output ()
31 "Parse static output to variable."
32 (should (= 42
33 (org-test-with-temp-text
35 #+begin_src vala
36 class Demo.HelloWorld : GLib.Object {
37 public static int main(string[] args) {
38 stdout.printf(\"42\n\");
39 return 0;
42 #+end_src"
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
51 #+begin_src vala
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);
57 return 0;
60 #+end_src"
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) {
72 #if FOO
73 stdout.printf(\"Foo\n\");
74 #else
75 stdout.printf(\"No foo\n\");
76 #endif
77 return 0;
80 #+end_src"
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]);
96 return 0;
99 #+end_src"
100 (org-babel-next-src-block)
101 (org-babel-execute-src-block)))))
104 ;;; test-ob-vala.el ends here