-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
smartparens-delete-pair-test.el
90 lines (77 loc) · 3.25 KB
/
smartparens-delete-pair-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
(require 'python)
(ert-deftest sp-test-delete-pair ()
(sp-test-with-temp-elisp-buffer "(|)"
(smartparens-strict-mode -1)
(delete-backward-char 1)
(should (equal (buffer-string) ""))))
(ert-deftest sp-test-delete-pair-closing ()
(let ((sp-pairs sp--test-basic-pairs))
(sp-test-with-temp-elisp-buffer "\\{\\}|"
(smartparens-strict-mode -1)
(delete-backward-char 1)
(should (equal (buffer-string) "\\{")))))
(ert-deftest sp-test-delete-pair-opening ()
(let ((sp-pairs sp--test-basic-pairs))
(sp-test-with-temp-elisp-buffer "\\{|"
(smartparens-strict-mode -1)
(delete-backward-char 1)
(should (equal (buffer-string) "")))))
(ert-deftest sp-test-delete-pair-in-org-mode-according-to-syntax ()
(sp-test-with-temp-buffer "\"asdasd\"| \"asdad\""
(org-mode)
(smartparens-strict-mode -1)
(delete-backward-char 1)
(should (equal (buffer-string) "\"asdasd \"asdad\""))))
(ert-deftest sp-test-delete-pair-in-org-mode-truly-empty ()
(let ((sp-pairs '((t (:open "\"" :close "\"" :actions (insert wrap autoskip navigate))
(:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-test-with-temp-buffer "\"asdasd\" \"|\" \"asdad\""
(org-mode)
(smartparens-strict-mode -1)
(delete-backward-char 1)
(should (equal (buffer-string) "\"asdasd\" \"asdad\"")))))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-no-strict-mode-no-spaces ()
"This is a test for #731."
(sp-test-with-temp-elisp-buffer "\"\\\"|\""
(smartparens-strict-mode -1)
(backward-delete-char 1)
(sp-buffer-equals "\"|\"")))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-no-strict-mode-spaces ()
"This is a test for #731."
(sp-test-with-temp-elisp-buffer "\" \\\"| \""
(smartparens-strict-mode -1)
(backward-delete-char 1)
(sp-buffer-equals "\" \\| \"")))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-no-strict-mode-no-spaces-python ()
"This is a test for #731."
(sp-test-with-temp-buffer "\"\\\"|\""
(shut-up (python-mode))
(smartparens-strict-mode -1)
(python-indent-dedent-line-backspace 1)
(sp-buffer-equals "\"|\"")))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-no-strict-mode-spaces-python ()
"This is a test for #731."
(sp-test-with-temp-buffer "\" \\\"| \""
(shut-up (python-mode))
(smartparens-strict-mode -1)
(python-indent-dedent-line-backspace 1)
(sp-buffer-equals "\" \\| \"")))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-strict-mode-no-spaces ()
"This is a test for #731."
(sp-test-with-temp-elisp-buffer "\"\\\"|\""
(smartparens-strict-mode 1)
(sp-backward-delete-char)
(sp-buffer-equals "\"|\"")))
(ert-deftest sp-test-delete-pair-escaped-double-quote-in-quotes-strict-mode-spaces ()
"This is a test for #731."
(sp-test-with-temp-elisp-buffer "\" \\\"| \""
(smartparens-strict-mode 1)
(sp-backward-delete-char)
(sp-buffer-equals "\" | \"")))
(ert-deftest sp-test-delete-pair-dont-delete-with-active-region ()
"Fixes #703"
(sp-test-with-temp-elisp-buffer "(|
M)"
(smartparens-strict-mode -1)
(call-interactively 'backward-delete-char)
(should (equal (buffer-string) "()"))))