test-ob-scheme.el 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ;;; test-ob-scheme.el --- Tests for Babel scheme -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017, 2019 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 <https://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. (unless (featurep 'geiser)
  20. (signal 'missing-test-dependency "geiser"))
  21. (ert-deftest test-ob-scheme/tables ()
  22. "Test table output."
  23. (equal "#+begin_src scheme
  24. '(1 2 3)
  25. #+end_src
  26. #+RESULTS:
  27. | 1 | 2 | 3 |
  28. "
  29. (org-test-with-temp-text "#+begin_src scheme\n'(1 2 3)\n#+end_src"
  30. (org-babel-execute-maybe)
  31. (buffer-string))))
  32. (ert-deftest test-ob-scheme/verbatim ()
  33. "Test verbatim output."
  34. (should
  35. (equal ": (1 2 3)\n"
  36. (org-test-with-temp-text "#+begin_src scheme :results verbatim\n'(1 2 3)\n#+end_src"
  37. (org-babel-execute-src-block)
  38. (let ((case-fold-search t)) (search-forward "#+results"))
  39. (buffer-substring-no-properties (line-beginning-position 2)
  40. (point-max))))))
  41. (ert-deftest test-ob-scheme/list ()
  42. "Test list output."
  43. (should
  44. (equal "- 1\n- 2\n- 3\n"
  45. (org-test-with-temp-text "#+begin_src scheme :results list\n'(1 2 3)\n#+end_src"
  46. (org-babel-execute-maybe)
  47. (let ((case-fold-search t)) (search-forward "#+results"))
  48. (buffer-substring-no-properties (line-beginning-position 2)
  49. (point-max))))))
  50. (ert-deftest test-ob-scheme/prologue ()
  51. "Test :prologue parameter."
  52. (should
  53. (equal "#+begin_src scheme :prologue \"(define x 2)\"
  54. x
  55. #+end_src
  56. #+RESULTS:
  57. : 2
  58. "
  59. (org-test-with-temp-text
  60. "#+begin_src scheme :prologue \"(define x 2)\"\nx\n#+end_src"
  61. (org-babel-execute-maybe)
  62. (buffer-string))))
  63. (should
  64. (equal
  65. "#+begin_src scheme :prologue \"(define x 2)\" :var y=1
  66. x
  67. #+end_src
  68. #+RESULTS:
  69. : 2
  70. "
  71. (org-test-with-temp-text
  72. "#+begin_src scheme :prologue \"(define x 2)\" :var y=1\nx\n#+end_src"
  73. (org-babel-execute-maybe)
  74. (buffer-string)))))
  75. (ert-deftest test-ob-scheme/unspecified ()
  76. "Test <#unspecified> return value."
  77. (should
  78. (equal "#+begin_src scheme
  79. \(define (mysquare x)
  80. (* x x))
  81. #+end_src
  82. #+RESULTS:
  83. : #<unspecified>
  84. "
  85. (org-test-with-temp-text
  86. "#+begin_src scheme
  87. (define (mysquare x)
  88. (* x x))
  89. #+end_src"
  90. (org-babel-execute-maybe)
  91. (buffer-string)))))
  92. (provide 'test-ob-scheme)
  93. ;;; test-ob-scheme.el ends here