Skip to content

Commit

Permalink
Remove conditional tests for 24.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Sep 18, 2016
1 parent 971a2be commit de5d4f3
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 95 deletions.
3 changes: 1 addition & 2 deletions test/smartparens-commands-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ be."
"Run the test for COMMAND."
;; TODO: get rid of this
(unless (and (boundp 'mode)
(eq mode 'racket)
(version<= "24.3" emacs-version))
(eq mode 'racket))
(shut-up
(cl-dolist (example examples)
(let ((before (car example)))
Expand Down
133 changes: 65 additions & 68 deletions test/smartparens-delayed-hook-test.el
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
;; TODO: no idea why cl-letf doesn't work on 24.3. The error is:
;; (void-function sp-test-insert-space)
(when (version<= "24.4" emacs-version)
(ert-deftest sp-test-delayed-hook-should-trigger-on-RET ()
(cl-letf (((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space "RET")))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(execute-kbd-macro (kbd "RET"))
(insert "|")
(should (equal (buffer-string) "(
(ert-deftest sp-test-delayed-hook-should-trigger-on-RET ()
(cl-letf (((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space "RET")))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(execute-kbd-macro (kbd "RET"))
(insert "|")
(should (equal (buffer-string) "(
|)"))))))

(ert-deftest sp-test-delayed-hook-should-not-trigger-on-a ()
(cl-letf (((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space "RET")))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(execute-kbd-macro (kbd "a"))
(insert "|")
(should (equal (buffer-string) "(a|)"))))))
(ert-deftest sp-test-delayed-hook-should-not-trigger-on-a ()
(cl-letf (((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space "RET")))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(execute-kbd-macro (kbd "a"))
(insert "|")
(should (equal (buffer-string) "(a|)"))))))

(ert-deftest sp-test-delayed-hook-should-trigger-on-my/newline ()
(cl-letf (((symbol-function 'my/test-newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space my/test-newline)))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(setq this-command 'my/test-newline)
(call-interactively 'my/test-newline)
(run-hooks 'post-command-hook)
(insert "|")
(should (equal (buffer-string) "(
(ert-deftest sp-test-delayed-hook-should-trigger-on-my/newline ()
(cl-letf (((symbol-function 'my/test-newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space my/test-newline)))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(setq this-command 'my/test-newline)
(call-interactively 'my/test-newline)
(run-hooks 'post-command-hook)
(insert "|")
(should (equal (buffer-string) "(
|)"))))))

(ert-deftest sp-test-delayed-hook-should-not-trigger-on-newline ()
(cl-letf (((symbol-function 'my/test-newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space my/test-newline)))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(setq this-command 'newline)
(call-interactively 'newline)
(run-hooks 'post-command-hook)
(insert "|")
(should (equal (buffer-string) "(
|)")))))))
(ert-deftest sp-test-delayed-hook-should-not-trigger-on-newline ()
(cl-letf (((symbol-function 'my/test-newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'newline)
(lambda (&rest _)
(interactive)
(insert "\n")))
((symbol-function 'sp-test-insert-space)
(lambda (&rest _)
(insert " "))))
(let ((sp-pairs '((emacs-lisp-mode
(:open "(" :close ")" :actions (insert wrap autoskip navigate)
:post-handlers ((sp-test-insert-space my/test-newline)))))))
(sp-test-with-temp-elisp-buffer ""
(execute-kbd-macro "(")
(setq this-command 'newline)
(call-interactively 'newline)
(run-hooks 'post-command-hook)
(insert "|")
(should (equal (buffer-string) "(
|)"))))))
22 changes: 10 additions & 12 deletions test/smartparens-get-thing-test.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
;; Get thing tests
(when (version< "24.3" emacs-version)
(shut-up (load "auctex-autoloads")))
(shut-up (load "auctex-autoloads"))

(defun sp-test-thing-parse-in-latex (initial result)
(sp-test-with-temp-buffer initial
Expand All @@ -18,15 +17,14 @@
(sp-test-thing-parse-in-latex "foo | \\bar {baz} qux" '(:beg 7 :end 10 :op "" :cl "" :prefix "\\" :suffix ""))
))

(when (version<= "24.3" emacs-version)
(require 'racket-mode)
(require 'racket-mode)

(defun sp-test-thing-parse-in-racket (initial result)
(sp-test-with-temp-buffer initial
(racket-mode)
(should (equal (sp-get-thing) result))))
(defun sp-test-thing-parse-in-racket (initial result)
(sp-test-with-temp-buffer initial
(racket-mode)
(should (equal (sp-get-thing) result))))

(ert-deftest sp-test-get-thing-racket nil
(let ((sp-sexp-prefix '((racket-mode regexp "#?['`,]@?")))
(sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate)))))))
(sp-test-thing-parse-in-racket "foo | #'(foo) qux" '(:beg 8 :end 13 :op "(" :cl ")" :prefix "#'" :suffix "")))))
(ert-deftest sp-test-get-thing-racket nil
(let ((sp-sexp-prefix '((racket-mode regexp "#?['`,]@?")))
(sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate)))))))
(sp-test-thing-parse-in-racket "foo | #'(foo) qux" '(:beg 8 :end 13 :op "(" :cl ")" :prefix "#'" :suffix ""))))
9 changes: 3 additions & 6 deletions test/smartparens-insertion-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
;; and 24.2 but it's a waste of time. If some users are on those
;; versions, they are welcome to figure it out for us :)
(ert-deftest sp-test-insertion-latex nil
(when (version< "24.3" emacs-version)
(shut-up (load "auctex-autoloads")))
(shut-up (load "auctex-autoloads"))
(let ((sp-undo-pairs-separately nil)
(sp-pairs '((latex-mode
(:open "$" :close "$" :actions (insert wrap autoskip navigate))
Expand All @@ -58,17 +57,15 @@
(:open "`" :close "'" :actions (insert wrap autoskip navigate))))))
(sp-test-latex-insertion "|" "$" "$$")
(sp-test-latex-insertion "|" "`" "`'")
(when (version< "24.3" emacs-version)
(sp-test-latex-insertion "|" "$$" "$$"))
(sp-test-latex-insertion "|" "$$" "$$")
(sp-test-latex-insertion "|" "$foo$$foo" "$foo$$foo$")
(sp-test-latex-insertion "foo |" "$" "foo $$")
(sp-test-latex-insertion "|" "\\[" "\\[\\]")
(sp-test-latex-insertion "\\|" "[" "\\[\\]")
(sp-test-latex-insertion "|" "[" "[]")
(sp-test-latex-insertion "foo | bar" "\\bigl(" "foo \\bigl(\\bigr) bar")
(sp-test-latex-insertion "foo | bar" "``" "foo ``'' bar")
(when (version< "24.3" emacs-version)
(sp-test-latex-insertion "foo | bar" "\"" "foo ``'' bar"))
(sp-test-latex-insertion "foo | bar" "\"" "foo ``'' bar")
))

(defun sp-test--pair-to-insert (initial expected)
Expand Down
13 changes: 6 additions & 7 deletions test/smartparens-ruby-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
(replace-regexp-in-string "^ *" "" b)))


(when (version< "24.3" emacs-version)
(ert-deftest sp-test-ruby-delete-pair ()
(sp-test-with-temp-buffer "class Foo
(ert-deftest sp-test-ruby-delete-pair ()
(sp-test-with-temp-buffer "class Foo
def foo_for|
end
end"
(ruby-mode)
(execute-kbd-macro (kbd "<backspace>|"))
(should (equal (buffer-string) "class Foo
(ruby-mode)
(execute-kbd-macro (kbd "<backspace>|"))
(should (equal (buffer-string) "class Foo
def foo_fo|
end
end")))))
end"))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; basic pairs
Expand Down

0 comments on commit de5d4f3

Please sign in to comment.