Skip to content

Commit

Permalink
Unbreak tests by properly simulating commands
Browse files Browse the repository at this point in the history
* test/sly-mrepl-tests.el (repl-values-and-button-navigation): Use
ert-simulate-command.

* test/sly-stickers-tests.el (stickers-basic-navigation)
(stickers-should-stick, stickers-when-invalid-dont-stick)
(stickers-in-a-file, stickers-record-stuff): Use
ert-simulate-command.
  • Loading branch information
joaotavora committed Jul 11, 2018
1 parent 8c2067e commit 20c98f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions test/sly-mrepl-tests.el
Expand Up @@ -59,11 +59,11 @@
(insert "(values (list 1 2 3) #(1 2 3))")
(sly-mrepl-return)
(sly-mrepl-tests--assert-prompt)
(call-interactively 'sly-button-backward)
(call-interactively 'sly-button-backward)
(ert-simulate-command '(sly-button-backward 1))
(ert-simulate-command '(sly-button-backward 1))
(should-error
(call-interactively 'sly-button-backward))
(call-interactively 'sly-button-forward)))
(ert-simulate-command '(sly-button-backward 1)))
(ert-simulate-command '(sly-button-forward 1))))

(when (>= emacs-major-version 25)
(define-sly-ert-test repl-completion-pop-up-window ()
Expand Down
29 changes: 15 additions & 14 deletions test/sly-stickers-tests.el
@@ -1,6 +1,7 @@
(require 'sly-stickers)
(require 'sly-tests "lib/sly-tests")
(require 'cl-lib)
(require 'ert-x)

(defvar sly-stickers--test-debug nil)

Expand Down Expand Up @@ -60,13 +61,13 @@
(defun quux () (coiso (cena))))
'("(bar" "(baz" "(coiso"))
(goto-char (point-min))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(save-excursion
(should (equal (read (current-buffer)) '(bar (baz)))))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(save-excursion
(should (equal (read (current-buffer)) '(baz))))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(save-excursion
(should (equal (read (current-buffer)) '(coiso (cena)))))
(should (eq 'sly-stickers-placed-face
Expand All @@ -81,14 +82,14 @@
(sly-sync-to-top-level 1)
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected QUUX stickers to be armed"))
(call-interactively 'sly-stickers-prev-sticker)
(ert-simulate-command '(sly-stickers-prev-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Compiled just the QUUX defun, didn't expect FOO stickers to arm."))
(call-interactively 'sly-compile-defun)
(sly-sync-to-top-level 1)
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected innermost FOO sticker to be armed by now."))
(call-interactively 'sly-stickers-prev-sticker)
(ert-simulate-command '(sly-stickers-prev-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected outermost FOO sticker to also be armed by now."))))

Expand All @@ -97,17 +98,17 @@
(sly-stickers--with-fixture ('((defun foo () (bar (baz))))
'("(bar" "(baz" "foo"))
(goto-char (point-min))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Expected FOO sticker to be unarmed"))
(call-interactively 'sly-compile-defun)
(sly-sync-to-top-level 1)
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Expected invalid FOO sticker to remain unarmed"))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Expected valid FOO sticker to remain unarmed"))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Expected valid FOO sticker to remain unarmed"))))

Expand All @@ -122,13 +123,13 @@
(goto-char (point-min))
(call-interactively 'sly-compile-and-load-file)
(sly-sync-to-top-level 1)
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected BAR sticker to be armed"))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected BAZ sticker to be armed"))
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-placed-face)
(ert-fail "Didn't expect COISO sticker to be armed"))))

Expand All @@ -142,7 +143,7 @@
(goto-char (point-min))
(call-interactively 'sly-compile-and-load-file)
(sly-sync-to-top-level 1)
(call-interactively 'sly-stickers-next-sticker)
(ert-simulate-command '(sly-stickers-next-sticker 1))
(unless (sly-stickers--face-p 'sly-stickers-armed-face)
(ert-fail "Expected BAR sticker to be armed by now"))
(sly-eval-async '(slynk-stickers-fixture::foo))
Expand All @@ -154,8 +155,8 @@

;; This part still needs work
;;
;; (call-interactively 'sly-stickers-next-sticker)
;; (call-interactively 'sly-stickers-next-sticker)
;; (ert-simulate-command '(sly-stickers-next-sticker 1))
;; (ert-simulate-command '(sly-stickers-next-sticker 1))
;; (call-interactively 'sly-compile-defun)
;; (sly-sync-to-top-level 1)
;; (unless (sly-stickers--face-p 'sly-stickers-armed-face)
Expand Down

0 comments on commit 20c98f6

Please sign in to comment.