emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/with-simulated-input c5b3f7ac70 097/134: Add tests for nil


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input c5b3f7ac70 097/134: Add tests for nil input
Date: Mon, 10 Jan 2022 23:00:09 -0500 (EST)

branch: elpa/with-simulated-input
commit c5b3f7ac702e7b8a11382b0a1243b0c458a9bbb0
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>

    Add tests for nil input
---
 tests/test-with-simulated-input.el | 46 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/tests/test-with-simulated-input.el 
b/tests/test-with-simulated-input.el
index b3a9655bb1..fc999af8e7 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -184,6 +184,52 @@
        (read-string "Enter a string: "))
      :to-throw))
 
+  (it "should throw an error if the input is empty and BODY reads input"
+    (expect
+     (with-simulated-input nil
+       (read-string "Enter a string: "))
+     :to-throw 'error '("Reached end of simulated input while evaluating 
body"))
+    (expect
+     (with-simulated-input '()
+       (read-string "Enter a string: "))
+     :to-throw 'error '("Reached end of simulated input while evaluating 
body"))
+    (expect
+     (with-simulated-input ()
+       (read-string "Enter a string: "))
+     :to-throw 'error '("Reached end of simulated input while evaluating 
body"))
+    (expect
+     (with-simulated-input '(nil)
+       (read-string "Enter a string: "))
+     :to-throw 'error '("Reached end of simulated input while evaluating 
body"))
+    (let ((my-input nil))
+      (expect
+       (with-simulated-input my-input
+         (read-string "Enter a string: "))
+       :to-throw 'error '("Reached end of simulated input while evaluating 
body"))))
+
+  (it "should not throw an error if the input is empty unless BODY reads input"
+    (expect
+     (with-simulated-input nil
+       (+ 1 2))
+     :not :to-throw)
+    (expect
+     (with-simulated-input '()
+       (+ 1 2))
+     :not :to-throw)
+    (expect
+     (with-simulated-input ()
+       (+ 1 2))
+     :not :to-throw)
+    (expect
+     (with-simulated-input '(nil)
+       (+ 1 2))
+     :not :to-throw)
+    (let ((my-input nil))
+      (expect
+       (with-simulated-input my-input
+         (+ 1 2))
+       :not :to-throw)))
+
   (it "should discard any extra input after BODY has completed"
     (expect
      (with-simulated-input



reply via email to

[Prev in Thread] Current Thread [Next in Thread]