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

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

[nongnu] elpa/multiple-cursors 50851e7 060/434: Add more core tests.


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 50851e7 060/434: Add more core tests.
Date: Sat, 7 Aug 2021 09:19:55 -0400 (EDT)

branch: elpa/multiple-cursors
commit 50851e7ac2eccf1e40284ce0265b5943ca7ebc5a
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Add more core tests.
---
 features/mark-multiple-integration.feature         | 24 +++---
 features/multiple-cursors-core.feature             | 86 +++++++++++++++++-----
 .../step-definitions/multiple-cursors-steps.el     | 33 ++++++++-
 multiple-cursors-core.el                           |  2 +
 4 files changed, 111 insertions(+), 34 deletions(-)

diff --git a/features/mark-multiple-integration.feature 
b/features/mark-multiple-integration.feature
index 80d5b16..e3b2864 100644
--- a/features/mark-multiple-integration.feature
+++ b/features/mark-multiple-integration.feature
@@ -3,23 +3,23 @@ Feature: Mark multiple integration
   As an Emacs user with mark-multiple
   I want to mark multiple regions and then go to multiple-cursors-mode
 
-  Scenario: Mark two words and change them
+  Scenario: Two cursors
     Given there is no region selected
-    And delete-selection-mode is active
     When I insert "This text contains the word text twice"
     And I select "text"
     And I press "C->"
-    And I type "sentence"
-    Then I should see "This sentence contains the word sentence twice"
+    And I press "C-g"
+    Then I should have 2 cursors
 
-  Scenario: Mark two words and go to multiple cursors
+  Scenario: Three cursors
     Given there is no region selected
-    When I insert "This text contains the word text twice"
+    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 switch to multiple-cursors mode
-    And I type "("
-    And I press "M-f"
-    And I press "M-f"
-    And I type ")"
-    Then I should see "This (text contains) the word (text twice)"
+    And I press "C->"
+    And I press "C-g"
+    Then I should have 3 cursors
diff --git a/features/multiple-cursors-core.feature 
b/features/multiple-cursors-core.feature
index b62de30..8852961 100644
--- a/features/multiple-cursors-core.feature
+++ b/features/multiple-cursors-core.feature
@@ -3,32 +3,80 @@ Feature: Multiple cursors core
   As an Emacs user with multiple-cursors
   I want to change multiple parts of the buffer at once
 
-  Scenario: Two 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
-    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 switch to multiple-cursors mode
-    Then I should have 3 cursors
+    And I press "C-g"
+    And I press "<return>"
+    Then I should have one cursor
 
-  Scenario: Exiting multiple-cursors mode with return
+  Scenario: Exiting multiple-cursors mode with C-g
     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>"
+    And I press "C-g"
+    And I press "C-g"
     Then I should have one cursor
+
+  Scenario: Separate kill-rings
+    Given I have cursors at "text" in "This text contains the word text twice"
+    When I press "M-f"
+    And I press "M-d"
+    And I press "M-b"
+    And I press "C-y"
+    Then I should see "This  containstext the word  twicetext"
+
+  Scenario: Separate kill-rings, yank-pop
+    Given I have cursors at "text" in "This text contains the word text twice"
+    When I press "M-d"
+    And I press "C-f"
+    And I press "M-d"
+    And I press "C-y M-y"
+    Then I should see "This  text the word  text"
+
+  Scenario: Interprogram paste
+    Given I have cursors at "text" in "This text contains the word text twice"
+    When I copy "external" in another program
+    And I press "C-y"
+    Then I should see "This externaltext contains the word externaltext twice"
+
+  Scenario: Multiple lambdas
+    Given I have bound C-! to a lambda that inserts "a"
+    And I have cursors at "text" in "This text contains the word text twice"
+    When I press "C-!"
+    Then I should see "This atext contains the word atext twice"
+
+  Scenario: Multiple supported command (forward-word in this case)
+    Given I have cursors at "text" in "This text contains the word text twice"
+    And I type "("
+    And I press "M-f"
+    And I press "M-f"
+    And I type ")"
+    Then I should see "This (text contains) the word (text twice)"
+
+  Scenario: Setting and popping mark
+    Given I have cursors at "text" in "This text contains the word text twice"
+    And I press "C-SPC"
+    And I press "M-f"
+    And I press "C-u C-SPC"
+    And I type "!"
+    Then I should see "This !text contains the word !text twice"
+
+  Scenario: delete-selection-mode (self-insert-command)
+    Given I turn on delete-selection-mode
+    And I have cursors at "text" in "This text contains the word text twice"
+    And I press "C-SPC"
+    And I press "M-f"
+    And I type "!"
+    Then I should see "This ! contains the word ! twice"
+
+  Scenario: delete-selection-mode (delete-char)
+    Given I turn on delete-selection-mode
+    And I have cursors at "text" in "This text contains the word text twice"
+    And I press "C-SPC"
+    And I press "M-f"
+    And I press "C-d"
+    Then I should see "This  contains the word  twice"
diff --git a/features/step-definitions/multiple-cursors-steps.el 
b/features/step-definitions/multiple-cursors-steps.el
index 35349f7..0ade5ec 100644
--- a/features/step-definitions/multiple-cursors-steps.el
+++ b/features/step-definitions/multiple-cursors-steps.el
@@ -22,6 +22,33 @@
         (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)))
+(When "^I press \"\\(.+\\)\"$"
+      (lambda (keybinding)
+        (let ((macro (edmacro-parse-keys keybinding)))
+          (if espuds-chain-active
+              (setq espuds-action-chain (vconcat espuds-action-chain macro))
+            (if (and (equal keybinding "C-g")
+                     (eq (key-binding (kbd "C-g")) 'keyboard-quit))
+                (espuds-quit)
+              (execute-kbd-macro macro))))))
+
+(Given "^I have cursors at \"\\(.+\\)\" in \"\\(.+\\)\"$"
+       (lambda (needle haystack)
+         (insert haystack)
+         (goto-char (point-min))
+         (search-forward needle)
+         (set-mark (point))
+         (goto-char (match-beginning 0))
+         (mark-all-like-this)
+         (mc/switch-from-mark-multiple-to-cursors)))
+
+(When "^I copy \"\\(.+\\)\" in another program$"
+       (lambda (text)
+         (lexical-let ((text text))
+           (setq interprogram-paste-function
+                 #'(lambda () (let ((r text)) (setq text nil) r))))))
+
+(Given "^I have bound C-! to a lambda that inserts \"\\(.+\\)\"$"
+       (lambda (ins)
+         (lexical-let ((ins ins))
+           (global-set-key (kbd "C-!") #'(lambda () (interactive) (insert 
ins))))))
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index ab9b568..e3309dc 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -228,6 +228,8 @@ from being executed if in multiple-cursors-mode."
                           undo
                           undo-tree-undo
                           undo-tree-redo
+                          universal-argument
+                          universal-argument-other-key
                           mc/switch-from-mark-multiple-to-cursors))
 
 ;; Commands that should be mirrored by all cursors



reply via email to

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