Skip to content

Commit

Permalink
Add test case for symbol coercion in C Babel blocks
Browse files Browse the repository at this point in the history
The ORG-NEWS entry for version 9.1 suggests that this coercion was
always intended, though AFAICT there was no test case for it.

* testing/lisp/test-ob-C.el (ob-C/symbol-include): Check explicitly
that :includes <iostream> (with no double-quotes around <iostream>)
will be parsed correctly.
(ob-D/simple-program, ob-C/integer-var, ob-D/integer-var,
ob-C/two-integer-var, ob-D/two-integer-var, ob-C/string-var,
ob-D/string-var, ob-C/preprocessor): Adjust block indices.

* testing/examples/ob-C-test.org (Simple tests): Add input for the new
test.
  • Loading branch information
peniblec authored and kyleam committed May 29, 2020
1 parent 6506ea1 commit e916359
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions testing/examples/ob-C-test.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
return 0;
#+end_src

#+source: simple
#+begin_src cpp :includes <iostream> :results silent
std::cout << 42;
return 0;
#+end_src

#+source: simple
#+begin_src D :results silent
writefln ("%s", 42);
Expand Down
23 changes: 15 additions & 8 deletions testing/lisp/test-ob-C.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,67 @@
(org-babel-next-src-block 1)
(should (= 42 (org-babel-execute-src-block))))))

(ert-deftest ob-C/symbol-include ()
"Hello world program with unquoted :includes."
(if (executable-find org-babel-C++-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 2)
(should (= 42 (org-babel-execute-src-block))))))

(ert-deftest ob-D/simple-program ()
"Hello world program."
(if (executable-find org-babel-D-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 2)
(org-babel-next-src-block 3)
(should (= 42 (org-babel-execute-src-block))))))

(ert-deftest ob-C/integer-var ()
"Test of an integer variable."
(if (executable-find org-babel-C++-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 3)
(org-babel-next-src-block 4)
(should (= 12 (org-babel-execute-src-block))))))

(ert-deftest ob-D/integer-var ()
"Test of an integer variable."
(if (executable-find org-babel-D-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 4)
(org-babel-next-src-block 5)
(should (= 12 (org-babel-execute-src-block))))))

(ert-deftest ob-C/two-integer-var ()
"Test of two input variables"
(if (executable-find org-babel-C++-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 5)
(org-babel-next-src-block 6)
(should (= 22 (org-babel-execute-src-block))))))

(ert-deftest ob-D/two-integer-var ()
"Test of two input variables"
(if (executable-find org-babel-D-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 6)
(org-babel-next-src-block 7)
(should (= 22 (org-babel-execute-src-block))))))

(ert-deftest ob-C/string-var ()
"Test of a string input variable"
(if (executable-find org-babel-C++-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 7)
(org-babel-next-src-block 8)
(should (equal "word 4" (org-babel-execute-src-block))))))

(ert-deftest ob-D/string-var ()
"Test of a string input variable"
(if (executable-find org-babel-D-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 8)
(org-babel-next-src-block 9)
(should (equal "word 4" (org-babel-execute-src-block))))))

(ert-deftest ob-C/preprocessor ()
"Test of a string variable"
(if (executable-find org-babel-C++-compiler)
(org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
(org-babel-next-src-block 9)
(org-babel-next-src-block 10)
(should (= 42 (org-babel-execute-src-block))))))

(ert-deftest ob-C/table ()
Expand Down

0 comments on commit e916359

Please sign in to comment.