From 52b7b78e3413e93cb8098e699a0b44c04e94bb37 Mon Sep 17 00:00:00 2001 From: Bruno BARBIER Date: Sat, 29 Apr 2023 11:10:42 +0200 Subject: [PATCH 13/13] * testing/lisp/test-ob-haskell-ghci.el: Update session tests * testing/lisp/test-ob-haskell-ghci.el (ob-haskell/no-session-means-one-shot-sessions): Deleted. (ob-haskell/session-named-none-means-one-shot-sessions): New test. (ob-haskell/sessions-must-not-share-variables): Rewrite tests to match the new meaning of session names. (ob-haskell/may-use-the-*haskell*-session): New test. --- testing/lisp/test-ob-haskell-ghci.el | 36 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el index fcce06365..f49ebcc40 100644 --- a/testing/lisp/test-ob-haskell-ghci.el +++ b/testing/lisp/test-ob-haskell-ghci.el @@ -106,24 +106,38 @@ (ert-deftest ob-haskell/hello-world-output-multilines () (ert-deftest ob-haskell/sessions-must-not-share-variables () "Sessions must not share variables." - (test-ob-haskell-ghci-with-global-session - (test-ob-haskell-ghci ":session s1" "x=2" nil :unprotected) - (should (equal 2 (test-ob-haskell-ghci ":session s1" "x" nil :unprotected))) - (test-ob-haskell-ghci ":session s2" "x=3" nil :unprotected) - (should-not (equal 3 (test-ob-haskell-ghci ":session s1" "x" nil :unprotected))) - )) - -(ert-deftest ob-haskell/no-session-means-one-shot-sessions () + (test-ob-haskell-ghci ":session s1" "x=2" nil) + (should (equal 2 (test-ob-haskell-ghci ":session s1" "x" nil))) + (test-ob-haskell-ghci ":session s2" "x=3" nil) + (should-not (equal 3 (test-ob-haskell-ghci ":session s1" "x" nil))) + ) + +(ert-deftest ob-haskell/session-named-none-means-one-shot-sessions () "When no session, use a new session." - (test-ob-haskell-ghci-with-global-session - (test-ob-haskell-ghci "" "x=2" nil :unprotected) - (should-not (equal 2 (test-ob-haskell-ghci "" "x" nil :unprotected))))) + (test-ob-haskell-ghci ":session none" "x=2" nil) + (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))) + (test-ob-haskell-ghci ":session none" "x=2" nil) + (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) (ert-deftest ob-haskell/reuse-variables-in-same-session () "Reuse variables between blocks using the same session." (test-ob-haskell-ghci ":session s1" "x=2" nil) (should (equal 2 (test-ob-haskell-ghci ":session s1" "x")))) +(ert-deftest ob-haskell/may-use-the-*haskell*-session () + "The user may use the special *haskell* buffer." + (when (get-buffer "*haskell*") + (error "A buffer named '*haskell*' exists. Can't run this test")) + (unwind-protect + (progn + (test-ob-haskell-ghci ":session *haskell*" "x=2" nil :unprotected) + (should (equal 2 (test-ob-haskell-ghci ":session *haskell*" "x" nil :unprotected)))) + (with-current-buffer "*haskell*" + (let ((kill-buffer-query-functions nil) + (kill-buffer-hook nil)) + (kill-buffer "*haskell*"))))) + + ;;;; Values -- 2.39.3