63 lines
2.0 KiB
EmacsLisp
63 lines
2.0 KiB
EmacsLisp
;;; test-ob-elixir-core.el --- Core execution tests -*- lexical-binding: t; -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;; Core execution tests for ob-elixir package.
|
|
|
|
;;; Code:
|
|
|
|
(require 'ert)
|
|
(require 'ob-elixir)
|
|
|
|
;;; Command Tests
|
|
|
|
(ert-deftest ob-elixir-test-elixir-available ()
|
|
"Test that Elixir is available."
|
|
(should (executable-find ob-elixir-command)))
|
|
|
|
;;; Basic Execution Tests
|
|
|
|
(ert-deftest ob-elixir-test-simple-value ()
|
|
"Test simple value evaluation."
|
|
(skip-unless (executable-find ob-elixir-command))
|
|
(let ((result (ob-elixir--execute "1 + 1" 'value)))
|
|
(should (equal "2" result))))
|
|
|
|
(ert-deftest ob-elixir-test-simple-output ()
|
|
"Test simple output evaluation."
|
|
(skip-unless (executable-find ob-elixir-command))
|
|
(let ((result (ob-elixir--execute "IO.puts(\"hello\")" 'output)))
|
|
(should (equal "hello" result))))
|
|
|
|
(ert-deftest ob-elixir-test-multiline-value ()
|
|
"Test multiline code value evaluation."
|
|
(skip-unless (executable-find ob-elixir-command))
|
|
(let ((result (ob-elixir--execute "x = 10\ny = 20\nx + y" 'value)))
|
|
(should (equal "30" result))))
|
|
|
|
(ert-deftest ob-elixir-test-list-result ()
|
|
"Test list result."
|
|
(skip-unless (executable-find ob-elixir-command))
|
|
(let ((result (ob-elixir--execute "[1, 2, 3]" 'value)))
|
|
(should (equal "[1, 2, 3]" result))))
|
|
|
|
(ert-deftest ob-elixir-test-map-result ()
|
|
"Test map result."
|
|
(skip-unless (executable-find ob-elixir-command))
|
|
(let ((result (ob-elixir--execute "%{a: 1, b: 2}" 'value)))
|
|
;; Maps are unordered in Elixir, so accept either order
|
|
(should (or (string-match-p "%{a: 1, b: 2}" result)
|
|
(string-match-p "%{b: 2, a: 1}" result)))))
|
|
|
|
;;; Wrapper Tests
|
|
|
|
(ert-deftest ob-elixir-test-wrap-for-value ()
|
|
"Test value wrapper generation."
|
|
(let ((wrapped (ob-elixir--wrap-for-value "1 + 1")))
|
|
(should (string-match-p "result = " wrapped))
|
|
(should (string-match-p "IO\\.puts" wrapped))
|
|
(should (string-match-p "inspect" wrapped))))
|
|
|
|
(provide 'test-ob-elixir-core)
|
|
;;; test-ob-elixir-core.el ends here
|