tasks/06-test-suite.md done
This commit is contained in:
71
test/test-ob-elixir-org.el
Normal file
71
test/test-ob-elixir-org.el
Normal file
@@ -0,0 +1,71 @@
|
||||
;;; test-ob-elixir-org.el --- Org integration tests -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-mode integration tests for ob-elixir package.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ert)
|
||||
(require 'org)
|
||||
(require 'ob)
|
||||
(require 'ob-elixir)
|
||||
|
||||
;;; Helper Functions
|
||||
|
||||
(defun ob-elixir-test--ensure-org-babel-loaded ()
|
||||
"Ensure org-babel is loaded with Elixir support."
|
||||
(setq org-confirm-babel-evaluate nil)
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((elixir . t))))
|
||||
|
||||
(defun ob-elixir-test--execute-src-block (code &optional header-args)
|
||||
"Execute CODE as an Elixir src block with HEADER-ARGS."
|
||||
(ob-elixir-test--ensure-org-babel-loaded)
|
||||
(let ((org-confirm-babel-evaluate nil))
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert (format "#+BEGIN_SRC elixir%s\n%s\n#+END_SRC"
|
||||
(if header-args (concat " " header-args) "")
|
||||
code))
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(org-babel-execute-src-block))))
|
||||
|
||||
;;; Basic Org Tests
|
||||
|
||||
(ert-deftest ob-elixir-test-org-simple ()
|
||||
"Test simple org block execution."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(should (equal "2" (ob-elixir-test--execute-src-block "1 + 1"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-org-with-var ()
|
||||
"Test org block execution with variable."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(should (equal "20" (ob-elixir-test--execute-src-block "x * 2" ":var x=10"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-org-results-output ()
|
||||
"Test org block with :results output."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(should (equal "hello"
|
||||
(ob-elixir-test--execute-src-block
|
||||
"IO.puts(\"hello\")"
|
||||
":results output"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-org-results-value ()
|
||||
"Test org block with :results value."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(should (equal '(1 2 3)
|
||||
(ob-elixir-test--execute-src-block
|
||||
"[1, 2, 3]"
|
||||
":results value"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-org-table-result ()
|
||||
"Test org block returning table."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(let ((result (ob-elixir-test--execute-src-block "[[1, 2], [3, 4]]")))
|
||||
(should (equal '((1 2) (3 4)) result))))
|
||||
|
||||
(provide 'test-ob-elixir-org)
|
||||
;;; test-ob-elixir-org.el ends here
|
||||
Reference in New Issue
Block a user