]> code.delx.au - gnu-emacs-elpa/blob - packages/adjust-parens/adjust-parens-tests.el
Merge remote-tracking branch 'js2-mode/master'
[gnu-emacs-elpa] / packages / adjust-parens / adjust-parens-tests.el
1 ;;; adjust-parens-tests.el --- Tests of adjust-parens package
2
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5 ;; Author: Barry O'Reilly <gundaetiapo@gmail.com>
6
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Commentary:
21
22 ;;; Code:
23
24 (require 'ert)
25 (require 'adjust-parens)
26
27 (defun apt-check-buffer (text-before-point text-after-point)
28 (should (string= text-before-point
29 (buffer-substring-no-properties (point-min)
30 (point))))
31 (should (string= text-after-point
32 (buffer-substring-no-properties (point)
33 (point-max)))))
34
35 (ert-deftest apt-near-bob-test ()
36 (with-temp-buffer
37 (emacs-lisp-mode)
38 (insert "(foo)\n")
39 (lisp-indent-adjust-parens)
40 (apt-check-buffer "(foo\n " ")")))
41
42 (ert-deftest apt-indent-dedent-test ()
43 (with-temp-buffer
44 (emacs-lisp-mode)
45 (setq indent-tabs-mode nil)
46 (insert ";;\n"
47 "(let ((x 10) (y (some-func 20))))\n"
48 "; Comment")
49 (beginning-of-line)
50 (lisp-indent-adjust-parens)
51 (apt-check-buffer (concat ";;\n"
52 "(let ((x 10) (y (some-func 20)))\n"
53 " ")
54 "); Comment")
55 (lisp-indent-adjust-parens 3)
56 (apt-check-buffer (concat ";;\n"
57 "(let ((x 10) (y (some-func 20\n"
58 " ")
59 ")))); Comment")
60 (lisp-dedent-adjust-parens 2)
61 (apt-check-buffer (concat ";;\n"
62 "(let ((x 10) (y (some-func 20))\n"
63 " ")
64 ")); Comment")))
65
66 ;;; adjust-parens-tests.el ends here