removed elixir result parsing
This commit is contained in:
@@ -2,57 +2,62 @@
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Result formatting and table support tests for ob-elixir package.
|
||||
;; Result formatting tests for ob-elixir package.
|
||||
;; Results are returned as plain strings without parsing into elisp structures.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ert)
|
||||
(require 'ob-elixir)
|
||||
|
||||
;;; Parsing Tests
|
||||
;;; Result String Tests
|
||||
|
||||
(ert-deftest ob-elixir-test-parse-simple-list ()
|
||||
"Test parsing simple list result."
|
||||
(should (equal '(1 2 3) (ob-elixir--table-or-string "[1, 2, 3]"))))
|
||||
(ert-deftest ob-elixir-test-result-list-as-string ()
|
||||
"Test that list results are returned as strings."
|
||||
(should (equal "[1, 2, 3]" (ob-elixir--table-or-string "[1, 2, 3]"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-parse-nested-list ()
|
||||
"Test parsing nested list (table) result."
|
||||
(should (equal '((1 2) (3 4))
|
||||
(ert-deftest ob-elixir-test-result-nested-list-as-string ()
|
||||
"Test that nested list results are returned as strings."
|
||||
(should (equal "[[1, 2], [3, 4]]"
|
||||
(ob-elixir--table-or-string "[[1, 2], [3, 4]]"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-parse-tuple ()
|
||||
"Test parsing tuple result."
|
||||
(should (equal '(1 2 3) (ob-elixir--table-or-string "{1, 2, 3}"))))
|
||||
(ert-deftest ob-elixir-test-result-tuple-as-string ()
|
||||
"Test that tuple results are returned as strings."
|
||||
(should (equal "{1, 2, 3}" (ob-elixir--table-or-string "{1, 2, 3}"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-parse-scalar ()
|
||||
(ert-deftest ob-elixir-test-result-scalar ()
|
||||
"Test that scalars are returned as strings."
|
||||
(should (equal "42" (ob-elixir--table-or-string "42")))
|
||||
(should (equal ":ok" (ob-elixir--table-or-string ":ok"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-parse-string ()
|
||||
"Test parsing string result."
|
||||
(ert-deftest ob-elixir-test-result-string ()
|
||||
"Test that string results are returned as-is."
|
||||
(should (equal "\"hello\"" (ob-elixir--table-or-string "\"hello\""))))
|
||||
|
||||
(ert-deftest ob-elixir-test-sanitize-table-nil ()
|
||||
"Test that nil values are sanitized in tables."
|
||||
(let ((ob-elixir-nil-to 'hline))
|
||||
(should (equal '((1 hline) (hline 2))
|
||||
(ob-elixir--sanitize-table '((1 nil) (nil 2)))))))
|
||||
(ert-deftest ob-elixir-test-result-empty ()
|
||||
"Test that empty results return nil."
|
||||
(should (null (ob-elixir--table-or-string "")))
|
||||
(should (null (ob-elixir--table-or-string " "))))
|
||||
|
||||
(ert-deftest ob-elixir-test-execution-returns-table ()
|
||||
"Test that list results become tables."
|
||||
(ert-deftest ob-elixir-test-result-whitespace-trimmed ()
|
||||
"Test that whitespace is trimmed from results."
|
||||
(should (equal "42" (ob-elixir--table-or-string " 42 ")))
|
||||
(should (equal "[1, 2]" (ob-elixir--table-or-string "\n[1, 2]\n"))))
|
||||
|
||||
(ert-deftest ob-elixir-test-execution-returns-string ()
|
||||
"Test that execution results are returned as strings."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(let ((result (ob-elixir--table-or-string
|
||||
(ob-elixir--execute "[[1, 2], [3, 4]]" 'value))))
|
||||
(should (equal '((1 2) (3 4)) result))))
|
||||
(should (stringp result))
|
||||
(should (string-match-p "\\[\\[1, 2\\], \\[3, 4\\]\\]" result))))
|
||||
|
||||
(ert-deftest ob-elixir-test-mixed-list ()
|
||||
"Test parsing mixed-type list."
|
||||
(ert-deftest ob-elixir-test-mixed-list-as-string ()
|
||||
"Test that mixed-type list results are returned as strings."
|
||||
(skip-unless (executable-find ob-elixir-command))
|
||||
(let ((result (ob-elixir--table-or-string
|
||||
(ob-elixir--execute "[1, \"two\", :three]" 'value))))
|
||||
(should (listp result))
|
||||
(should (= 3 (length result)))))
|
||||
(should (stringp result))))
|
||||
|
||||
(provide 'test-ob-elixir-results)
|
||||
;;; test-ob-elixir-results.el ends here
|
||||
|
||||
Reference in New Issue
Block a user