;;; test-ob-elixir-errors.el --- Error handling tests -*- lexical-binding: t; -*- ;;; Commentary: ;; Error handling and detection tests for ob-elixir package. ;;; Code: (require 'ert) (require 'ob-elixir) ;;; Error Detection Tests (ert-deftest ob-elixir-test-detect-runtime-error () "Test runtime error detection." (let ((output "** (RuntimeError) something went wrong")) (let ((error-info (ob-elixir--detect-error output))) (should error-info) (should (eq 'runtime (plist-get error-info :type))) (should (equal "RuntimeError" (plist-get error-info :error-type)))))) (ert-deftest ob-elixir-test-detect-compile-error () "Test compile error detection." (let ((output "** (CompileError) test.exs:1: undefined function foo/0")) (let ((error-info (ob-elixir--detect-error output))) (should error-info) (should (eq 'compile (plist-get error-info :type))) (should (equal "CompileError" (plist-get error-info :error-type)))))) (ert-deftest ob-elixir-test-no-error () "Test that valid output is not detected as error." (should-not (ob-elixir--detect-error "42")) (should-not (ob-elixir--detect-error "[1, 2, 3]")) (should-not (ob-elixir--detect-error "\"hello\""))) (ert-deftest ob-elixir-test-error-execution () "Test that errors are properly handled during execution." (skip-unless (executable-find ob-elixir-command)) (let ((ob-elixir-signal-errors nil)) (let ((result (ob-elixir--execute "raise \"test error\"" 'value))) (should (string-match-p "RuntimeError" result))))) (ert-deftest ob-elixir-test-error-signaling () "Test that errors are signaled when configured." (skip-unless (executable-find ob-elixir-command)) (let ((ob-elixir-signal-errors t)) (should-error (ob-elixir--execute "raise \"test error\"" 'value) :type 'ob-elixir-runtime-error))) (ert-deftest ob-elixir-test-undefined-function () "Test handling of undefined function error." (skip-unless (executable-find ob-elixir-command)) (let ((ob-elixir-signal-errors nil)) (let ((result (ob-elixir--execute "undefined_function()" 'value))) (should (string-match-p "\\(UndefinedFunctionError\\|CompileError\\)" result))))) (provide 'test-ob-elixir-errors) ;;; test-ob-elixir-errors.el ends here