test-ob-scheme.el 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;;; test-ob-scheme.el --- Tests for Babel scheme -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017 Nicolas Goaziou
  3. ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ;;; Commentary:
  15. ;; Unit tests for Org Babel Scheme.
  16. ;;; Code:
  17. (unless (featurep 'ob-scheme)
  18. (signal 'missing-test-dependency "Support for Scheme code blocks"))
  19. (ert-deftest test-ob-scheme/tables ()
  20. "Test table output."
  21. (equal "#+begin_src scheme
  22. '(1 2 3)
  23. #+end_src
  24. #+RESULTS:
  25. | 1 | 2 | 3 |
  26. "
  27. (org-test-with-temp-text "#+begin_src scheme\n'(1 2 3)\n#+end_src"
  28. (org-babel-execute-maybe)
  29. (buffer-string))))
  30. (ert-deftest test-ob-scheme/prologue ()
  31. "Test :prologue parameter."
  32. (should
  33. (equal "#+begin_src scheme :prologue \"(define x 2)\"
  34. x
  35. #+end_src
  36. #+RESULTS:
  37. : 2
  38. "
  39. (org-test-with-temp-text
  40. "#+begin_src scheme :prologue \"(define x 2)\"\nx\n#+end_src"
  41. (org-babel-execute-maybe)
  42. (buffer-string))))
  43. (should
  44. (equal
  45. "#+begin_src scheme :prologue \"(define x 2)\" :var y=1
  46. x
  47. #+end_src
  48. #+RESULTS:
  49. : 2
  50. "
  51. (org-test-with-temp-text
  52. "#+begin_src scheme :prologue \"(define x 2)\" :var y=1\nx\n#+end_src"
  53. (org-babel-execute-maybe)
  54. (buffer-string)))))
  55. (ert-deftest test-ob-scheme/unspecified ()
  56. "Test <#unspecified> return value."
  57. (should
  58. (equal "#+begin_src scheme
  59. \(define (mysquare x)
  60. (* x x))
  61. #+end_src
  62. #+RESULTS:
  63. : #<unspecified>
  64. "
  65. (org-test-with-temp-text
  66. "#+begin_src scheme
  67. (define (mysquare x)
  68. (* x x))
  69. #+end_src"
  70. (org-babel-execute-maybe)
  71. (buffer-string)))))
  72. (provide 'test-ob-scheme)
  73. ;;; test-ob-scheme.el ends here