unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Simple lisp-tests.el and commit privs
@ 2013-07-21  4:12 Barry OReilly
  2013-07-21 23:08 ` Xue Fuqiao
  2013-07-25 19:09 ` Stefan Monnier
  0 siblings, 2 replies; 13+ messages in thread
From: Barry OReilly @ 2013-07-21  4:12 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hi, I created some simple tests of the current Lisp indentation
behavior, attached.

I found the Emacs project on Savannah, but found no obvious way to
formally become a member through the website. I have a Savannah
account, public key registered, and the CA squared away.

[-- Attachment #2: lisp-tests.el --]
[-- Type: application/octet-stream, Size: 2209 bytes --]

;;; lisp-tests.el --- Test suite for lisp.el

;; Copyright (C) 2013 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;;; Code:

(require 'ert)

(defmacro lisp-tests-with-temp-buffer (contents &rest body)
  "Create a `lisp-mode' enabled temp buffer with CONTENTS.
BODY is code to be executed within the temp buffer.  Point is
always located at the beginning of buffer."
  (declare (indent 1) (debug t))
  `(with-temp-buffer
     (emacs-lisp-mode)
     (insert ,contents)
     (goto-char (point-min))
     ,@body))

(defun lisp-tests-look-at (search-string)
  (re-search-forward search-string)
  (forward-char (- (length (match-string-no-properties 0)))))

(ert-deftest lisp-test-indent-line ()
  (lisp-tests-with-temp-buffer
   "
  (defun func ()
    (let ((x 10)
          ;; Next line at wrong indentation
    (y (some-func 10 20)))))
"
   (lisp-tests-look-at "(y ")
   (indent-for-tab-command)
   (should (eq 10 (current-indentation)))))

(ert-deftest lisp-test-indent-region ()
  (lisp-tests-with-temp-buffer
   "(defun func ()
  (let ((x 10)
        ;; Next line at wrong indentation
  (y (some-func 10
          20)))))
"
   (indent-region (point-min) (point-max))
   (lisp-tests-look-at "(defun func")
   (should (eq 0 (current-indentation)))
   (lisp-tests-look-at "(let ")
   (should (eq 2 (current-indentation)))
   (lisp-tests-look-at ";; ")
   (should (eq 8 (current-indentation)))
   (lisp-tests-look-at "(y ")
   (should (eq 8 (current-indentation)))
   (lisp-tests-look-at "20)")
   (should (eq 22 (current-indentation)))))


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-08-21 23:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-21  4:12 Simple lisp-tests.el and commit privs Barry OReilly
2013-07-21 23:08 ` Xue Fuqiao
2013-07-25 19:09 ` Stefan Monnier
2013-08-14 17:49   ` Barry OReilly
2013-08-14 21:23     ` Dmitry Gutov
2013-08-18 22:05       ` Barry OReilly
2013-08-19  3:06         ` Stefan Monnier
2013-08-19  3:09         ` Stefan Monnier
2013-08-19 16:41           ` Barry OReilly
2013-08-20  5:23             ` Stefan Monnier
2013-08-20 16:04               ` Barry OReilly
2013-08-20 20:54                 ` Stefan Monnier
2013-08-21 23:06                   ` Barry OReilly

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).