Browse Source

ob-scheme: Fix results error on unspecified and void values

* lisp/ob-scheme.el (org-babel-scheme-execute-with-geiser): Return
  "#<void>" or "#<unspecified>" when the REPL says so.

* testing/lisp/test-ob-scheme.el (test-ob-scheme/unspecified): New
  test.
(test-ob-scheme/prologue): Fix tests.

Reported-by: Lawrence Bottorff <borgauf@gmail.com>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-09/msg00346.html>
Nicolas Goaziou 2 years ago
parent
commit
63f1ffac32
2 changed files with 33 additions and 16 deletions
  1. 1 5
      lisp/ob-scheme.el
  2. 32 11
      testing/lisp/test-ob-scheme.el

+ 1 - 5
lisp/ob-scheme.el

@@ -180,11 +180,7 @@ is true; otherwise returns the last value."
 	    (save-current-buffer (set-buffer repl-buffer)
 				 (geiser-repl-exit))
 	    (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
-	    (kill-buffer repl-buffer))
-	  (setq result (if (or (string= result "#<void>")
-			       (string= result "#<unspecified>"))
-			   nil
-			 result)))))
+	    (kill-buffer repl-buffer)))))
     result))
 
 (defun org-babel-scheme--table-or-string (results)

+ 32 - 11
testing/lisp/test-ob-scheme.el

@@ -41,29 +41,50 @@
 
 (ert-deftest test-ob-scheme/prologue ()
   "Test :prologue parameter."
-  (equal "#+begin_src scheme :prologue \"(define x 2)\"
+  (should
+   (equal "#+begin_src scheme :prologue \"(define x 2)\"
 x
 #+end_src
 
 #+RESULTS:
 : 2
 "
-	 (org-test-with-temp-text
-	     "#+begin_src scheme :prologue \"(define x 2)\"\nx\n#+end_src"
-	   (org-babel-execute-maybe)
-	   (buffer-string)))
-  (equal
-   "#+begin_src scheme :prologue \"(define x 2)\" :var y=1
+	  (org-test-with-temp-text
+	      "#+begin_src scheme :prologue \"(define x 2)\"\nx\n#+end_src"
+	    (org-babel-execute-maybe)
+	    (buffer-string))))
+  (should
+   (equal
+    "#+begin_src scheme :prologue \"(define x 2)\" :var y=1
 x
 #+end_src
 
 #+RESULTS:
 : 2
 "
-   (org-test-with-temp-text
-       "#+begin_src scheme :prologue \"(define x 2)\" :var y=1\nx\n#+end_src"
-     (org-babel-execute-maybe)
-     (buffer-string))))
+    (org-test-with-temp-text
+	"#+begin_src scheme :prologue \"(define x 2)\" :var y=1\nx\n#+end_src"
+      (org-babel-execute-maybe)
+      (buffer-string)))))
+
+(ert-deftest test-ob-scheme/unspecified ()
+  "Test <#unspecified> return value."
+  (should
+   (equal "#+begin_src scheme
+\(define (mysquare x)
+  (* x x))
+#+end_src
+
+#+RESULTS:
+: #<unspecified>
+"
+	  (org-test-with-temp-text
+	      "#+begin_src scheme
+(define (mysquare x)
+  (* x x))
+#+end_src"
+	    (org-babel-execute-maybe)
+	    (buffer-string)))))
 
 
 (provide 'test-ob-scheme)