-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
smartparens-cua-selection-test.el
87 lines (74 loc) · 3.18 KB
/
smartparens-cua-selection-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
;; Tests for cua-selection-mode and smartparens integration
(defmacro sp-test-cuasel (initial &rest forms)
(declare (indent 1))
`(unwind-protect
(progn
(cua-selection-mode 1)
(sp-test-with-temp-elisp-buffer ,initial
(smartparens-strict-mode 1)
,@forms))
(cua-selection-mode -1)))
(ert-deftest sp-test-cua-selection-mode-delete-region-strict-valid ()
(sp-test-cuasel "(fo|o bMar)"
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar)")))
(ert-deftest sp-test-cua-selection-mode-delete-region-strict-invalid ()
(sp-test-cuasel "(fo|o) bMar"
(execute-kbd-macro "x")
(sp-buffer-equals "(fo|o) bMar")))
(ert-deftest sp-test-cua-selection-mode-delete-region-nonstrict-valid ()
(sp-test-cuasel "(fo|o bMar)"
(smartparens-strict-mode -1)
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar)")))
(ert-deftest sp-test-cua-selection-mode-delete-region-nonstrict-invalid ()
(sp-test-cuasel "(fo|o) bMar"
(smartparens-strict-mode -1)
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar")))
;; Calling sp-delete-char
(ert-deftest sp-test-cua-selection-mode-delete-char-can-not-kill-invalid-region ()
(sp-test-cuasel "(fo|o) bMar"
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|o) bMar")))
(ert-deftest sp-test-cua-selection-mode-delete-char-can-kill-valid-region ()
(sp-test-cuasel "(fo|o bMar)"
(sp-test-with-temp-binding ("d" 'sp-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar)")))
(ert-deftest sp-test-cua-selection-mode-nonstrict-delete-char-can-kill-invalid-region ()
(sp-test-cuasel "(fo|o) bMar"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar")))
(ert-deftest sp-test-cua-selection-mode-nonstrict-delete-char-can-kill-valid-region ()
(sp-test-cuasel "(fo|o bMar)"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar)")))
;; Calling sp-backward-delete-char
(ert-deftest sp-test-cua-selection-mode-backward-delete-char-can-not-kill-invalid-region ()
(sp-test-cuasel "(fo|o) bMar"
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|o) bMar")))
(ert-deftest sp-test-cua-selection-mode-backward-delete-char-can-kill-valid-region ()
(sp-test-cuasel "(fo|o bMar)"
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar)")))
(ert-deftest sp-test-cua-selection-mode-nonstrict-backward-delete-char-can-kill-invalid-region ()
(sp-test-cuasel "(fo|o) bMar"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar")))
(ert-deftest sp-test-cua-selection-mode-nonstrict-backward-delete-char-can-kill-valid-region ()
(sp-test-cuasel "(fo|o bMar)"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(fo|ar)")))