Finally got the tests running. :-)

This commit is contained in:
Magnar Sveen 2012-07-18 15:32:56 +02:00
parent de0519e0f0
commit eda9952fc0
5 changed files with 50 additions and 15 deletions

View File

@ -17,8 +17,9 @@ Feature: Mark multiple integration
When I insert "This text contains the word text twice"
And I select "text"
And I press "C->"
And I press "C-g"
And I type "'"
And I switch to multiple-cursors mode
And I type "("
And I press "M-f"
And I type "'"
Then I should see "This 'text' contains the word 'text' twice"
And I press "M-f"
And I type ")"
Then I should see "This (text contains) the word (text twice)"

View File

@ -5,9 +5,30 @@ Feature: Multiple cursors core
Scenario: Two cursors
Given there is no region selected
When I insert "This text contains the word text thrice (text)"
When I insert "This text contains the word text twice"
And I select "text"
And I press "C->"
And I switch to multiple-cursors mode
Then I should have 2 cursors
Scenario: Three cursors
Given there is no region selected
When I insert:
"""
This text contains the word text thrice, and
one of the instances of the word text is on the second line.
"""
And I select "text"
And I press "C->"
And I press "C->"
And I press "C-g"
And I switch to multiple-cursors mode
Then I should have 3 cursors
Scenario: Exiting multiple-cursors mode with return
Given there is no region selected
When I insert "This text contains the word text twice"
And I select "text"
And I press "C->"
And I switch to multiple-cursors mode
And I press "<return>"
Then I should have one cursor

View File

@ -3,7 +3,6 @@
(delete-selection-mode 1)))
(defun is-extra-cursor-p (o)
(message "overlay-type: %S" (overlay-get o 'type))
(eq (overlay-get o 'type) 'additional-cursor))
(defun num-cursors ()
@ -12,5 +11,17 @@
(Then "^I should have \\([0-9]+\\) cursors$"
(lambda (num)
(assert (eq (string-to-number num) (num-cursors)) nil
"Expected to have %s cursors, but was %d." num (num-cursors))))
(let ((actual (num-cursors)))
(assert (eq (string-to-number num) actual) nil
"Expected to have %s cursors, but was %d." num actual))))
(Then "^I should have one cursor$"
(lambda ()
(assert (not multiple-cursors-mode) nil
"Expected to have one cursor, but multiple-cursors-mode is still active.")
(assert (eq 1 (num-cursors)) nil
"Expected to have one cursor, but there are still fake cursor overlays.")))
(And "^I switch to multiple-cursors mode$"
(lambda ()
(mc/switch-from-mark-multiple-to-cursors)))

View File

@ -14,6 +14,7 @@
(require 'ert)
(Before
(multiple-cursors-mode 0)
(mm/clear-all)
(global-set-key (kbd "C->") 'mark-next-like-this)
(switch-to-buffer

View File

@ -144,7 +144,7 @@ cursors."
original-command
(get original-command 'mc--unsupported))
(if (not (memq original-command mc--cmds))
(when (not (memq original-command mc--cmds-run-once))
(when (and original-command (not (memq original-command mc--cmds-run-once)))
(message "Skipping %S" original-command))
(mc/execute-command-for-all-fake-cursors original-command))))))
@ -222,12 +222,13 @@ from being executed if in multiple-cursors-mode."
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
;;----------------------------------------------------------------------------------------
;; Commands to run only once (not yet in use)
;; Commands to run only once (don't need to message about skipping it)
(setq mc--cmds-run-once '(mark-next-like-this
save-buffer
undo
undo-tree-undo
undo-tree-redo))
undo-tree-redo
mc/switch-from-mark-multiple-to-cursors))
;; Commands that should be mirrored by all cursors
(setq mc--cmds '(mc/keyboard-quit