-
-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathsmartparens-delete-selection-test.el
120 lines (99 loc) · 4.21 KB
/
smartparens-delete-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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
;; Tests for delete-selection-mode and strict mode integration
(defmacro sp-test-delsel (initial &rest forms)
(declare (indent 1))
`(sp-test-with-delete-selection-mode
(sp-test-with-temp-elisp-buffer ,initial
(smartparens-strict-mode 1)
,@forms)))
;; Overwriting with letters
(ert-deftest sp-test-delete-selection-mode-self-insert-can-not-kill-invalid-region ()
(sp-test-delsel "(fo|o) bMar"
(execute-kbd-macro "x")
(sp-buffer-equals "(fo|o) bMar")))
(ert-deftest sp-test-delete-selection-mode-self-insert-can-kill-valid-region ()
(sp-test-delsel "(fo|o bMar)"
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar)")))
(ert-deftest sp-test-delete-selection-mode-nonstrict-self-insert-can-kill-invalid-region ()
(sp-test-delsel "(fo|o) bMar"
(smartparens-strict-mode -1)
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar")))
(ert-deftest sp-test-delete-selection-mode-nonstrict-self-insert-can-kill-valid-region ()
(sp-test-delsel "(fo|o bMar)"
(smartparens-strict-mode -1)
(execute-kbd-macro "x")
(sp-buffer-equals "(fox|ar)")))
;; Calling sp-delete-char
(ert-deftest sp-test-delete-selection-mode-delete-char-can-not-kill-invalid-region ()
(sp-test-delsel "(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-delete-selection-mode-delete-char-can-kill-valid-region ()
(sp-test-delsel "(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-delete-selection-mode-nonstrict-delete-char-can-kill-invalid-region ()
(sp-test-delsel "(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-delete-selection-mode-nonstrict-delete-char-can-kill-valid-region ()
(sp-test-delsel "(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-delete-selection-mode-backward-delete-char-can-not-kill-invalid-region ()
(sp-test-delsel "(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-delete-selection-mode-backward-delete-char-can-kill-valid-region ()
(sp-test-delsel "(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-delete-selection-mode-nonstrict-backward-delete-char-can-kill-invalid-region ()
(sp-test-delsel "(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-delete-selection-mode-nonstrict-backward-delete-char-can-kill-valid-region ()
(sp-test-delsel "(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)")))
;; #703
(ert-deftest sp-test-delete-selection-mode/empty-sexp/point-before-mark ()
(sp-test-delsel "(|
M)"
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(|M)")))
(ert-deftest sp-test-delete-selection-mode/empty-sexp/point-after-mark ()
(sp-test-delsel "(M
|)"
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(M|)")))
(ert-deftest sp-test-delete-selection-mode/nonstrict/empty-sexp/point-before-mark ()
(sp-test-delsel "(|
M)"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(|M)")))
(ert-deftest sp-test-delete-selection-mode/nonstrict/empty-sexp/point-after-mark ()
(sp-test-delsel "(M
|)"
(smartparens-strict-mode -1)
(sp-test-with-temp-binding ("d" 'sp-backward-delete-char)
(execute-kbd-macro "d"))
(sp-buffer-equals "(M|)")))