test-ob-scheme.el 2.9 KB

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