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

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

[nongnu] elpa/with-simulated-input 9a2ba67eba 009/134: Switch to using b


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input 9a2ba67eba 009/134: Switch to using buttercup as the test suite
Date: Mon, 10 Jan 2022 22:59:59 -0500 (EST)

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

    Switch to using buttercup as the test suite
---
 .travis.yml                        |  2 +-
 Cask                               |  7 ++--
 test/test-helper.el                | 40 -----------------------
 test/with-simulated-input-test.el  | 65 -------------------------------------
 tests/test-with-simulated-input.el | 66 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 108 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index ef9d93cea6..261debf042 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,4 +30,4 @@ before_script:
   - cask install
 
 script:
-  cask exec ert-runner
+  cask exec buttercup -L .
diff --git a/Cask b/Cask
index 67c25d8267..e40b72a0d5 100644
--- a/Cask
+++ b/Cask
@@ -9,5 +9,8 @@
 (depends-on "seq")
 
 (development
- (depends-on "f")
- (depends-on "ert-runner"))
+ (depends-on "buttercup"
+             :git "https://github.com/DarwinAwardWinner/emacs-buttercup.git";
+             :branch "show-exprs"
+             :files ("*.el"
+                     ("bin" "bin/*"))))
diff --git a/test/test-helper.el b/test/test-helper.el
deleted file mode 100644
index 2cb7a30ccd..0000000000
--- a/test/test-helper.el
+++ /dev/null
@@ -1,40 +0,0 @@
-;;; test-helper.el ---  -*- lexical-binding: t -*- 
-
-;; Copyright (C) 2015 Ryan C. Thompson
-
-;; Filename: test-helper.el
-;; Author: Ryan C. Thompson
-;; Created: Sat Nov 21 15:27:00 2015 (-0800)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 
-;; This program is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at
-;; your option) any later version.
-;; 
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-;; 
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;; 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 
-;;; Code:
-
-(require 'f)
-
-(defvar test-path
-  (f-dirname (f-this-file)))
-
-(defvar code-path
-  (f-parent test-path))
-
-(add-to-list 'load-path code-path)
-
-(require 'with-simulated-input)
-
-;;; test-helper.el ends here
diff --git a/test/with-simulated-input-test.el 
b/test/with-simulated-input-test.el
deleted file mode 100644
index 43acc0979e..0000000000
--- a/test/with-simulated-input-test.el
+++ /dev/null
@@ -1,65 +0,0 @@
-;;; -*- lexical-binding: t -*-
-
-(require 'with-simulated-input)
-(require 'ert)
-(require 'cl-lib)
-
-(ert-deftest read-simulated-input ()
-  :tags '(with-simulated-input)
-  "Tests for the basic functionality of the `with-simulated-input' macro."
-  ;; Basic string input
-  (should
-   (string=
-    "hello"
-    (with-simulated-input "hello RET"
-      (read-string "Enter a string: "))))
-  ;; Error if RET is not pressed to finish the input
-  (should-error
-   (with-simulated-input "hello"
-     (read-string "Enter a string: ")))
-  ;; Can throw an error manually
-  (should-error
-   (with-simulated-input
-       "(error SPC \"Manually SPC throwing SPC an SPC error\") RET"
-     (command-execute 'eval-expression)))
-  ;; Extra keys should not cause errors
-  (should
-   (string=
-    "hello"
-    (with-simulated-input
-        "hello RET M-x eval-expression (error SPC \"Manually SPC throwing SPC 
an SPC error\") RET"
-              (read-string "Enter a string: "))))
-  ;; A single input sequence can feed multiple functions
-  (should
-   (equal
-    '("hello" "world")
-    (with-simulated-input "hello RET world RET"
-      (list (read-string "First word: ")
-            (read-string "Second word: "))))))
-
-(ert-deftest complete-with-simulated-input ()
-  :tags '(with-simulated-input)
-  "Tests for `with-simulated-input' with `completing-read'."
-  (let ((collection '("bluebird" "blueberry" "bluebell" "bluegrass" 
"baseball"))
-        (completing-read-function #'completing-read-default))
-    ;; Unambiguous completion
-    (should
-     (string=
-      "bluebird"
-      ;; First TAB completes "blue", 2nd completes "bird"
-      (with-simulated-input "bl TAB bi TAB RET"
-        (completing-read "Choose: " collection))))
-    ;; Ambiguous completion
-    (should
-     (string=
-      "blue"
-      (with-simulated-input "bl TAB C-j"
-        (completing-read "Choose: " collection))))
-    ;; Ambiguous completion with require-match
-    (should-error
-     (with-simulated-input "bl TAB C-j"
-       (completing-read "Choose: " collection nil t)))))
-
-(provide 'with-simulated-input-test)
-
-;;; ido-ubiquitous-test.el ends here
diff --git a/tests/test-with-simulated-input.el 
b/tests/test-with-simulated-input.el
new file mode 100644
index 0000000000..b47e25c070
--- /dev/null
+++ b/tests/test-with-simulated-input.el
@@ -0,0 +1,66 @@
+;;; -*- lexical-binding: t -*-
+
+(require 'with-simulated-input)
+(require 'cl-lib)
+(require 'buttercup)
+
+(describe "Basic functionality of `with-simulated-input'"
+  (it "should work for basic string input"
+    (expect
+     (with-simulated-input "hello RET"
+       (read-string "Enter a string: "))
+     :to-equal "hello"))
+  (it "should throw an error if the input is incomplete"
+    (expect
+     (lambda ()
+       (with-simulated-input "hello"
+         (read-string "Enter a string: ")))
+     :to-throw))
+  (it "should allow the input to trigger errors"
+    (expect
+     (lambda ()
+       (with-simulated-input
+           "(error SPC \"Manually SPC throwing SPC an SPC error\") RET"
+         (command-execute 'eval-expression)))
+     :to-throw))
+  (it "should ignore extra input after BODY has completed"
+    (expect
+     (with-simulated-input
+         "hello RET M-x eval-expression (error SPC \"Manually SPC throwing SPC 
an SPC error\") RET"
+       (read-string "Enter a string: "))
+     :to-equal "hello"))
+  (it "should allow multiple functions in BODY to read input"
+    (expect
+     (with-simulated-input "hello RET world RET"
+       (list (read-string "First word: ")
+             (read-string "Second word: ")))
+     :to-equal '("hello" "world")))
+  (it "should not allow `C-g' in the input"
+    (expect
+     (lambda ()
+       (with-simulated-input "C-g" (ignore)))
+     :to-throw)))
+
+(describe "Using `with-simulated-input' with `completing-read'"
+  :var ((collection '("bluebird" "blueberry" "bluebell" "bluegrass" 
"baseball"))
+        (completing-read-function #'completing-read-default))
+  ;; Unambiguous completion
+  (it "should work with unambiguous tab completion"
+    (expect
+     ;; First TAB completes "blue", 2nd completes "bird"
+     (with-simulated-input "bl TAB bi TAB RET"
+       (completing-read "Choose: " collection))
+     :to-equal "bluebird"))
+  (it "should work with ambiguous tab completion"
+    (expect
+     (with-simulated-input "bl TAB C-j"
+       (completing-read "Choose: " collection))
+     :to-equal "blue"))
+  (it "should fail to exit with ambiguous completion and `require-match'"
+    (expect
+     (lambda ()
+       (with-simulated-input "bl TAB C-j"
+         (completing-read "Choose: " collection nil t)))
+     :to-throw)))
+
+;;; test-with-simulated-input.el ends here



reply via email to

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