unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Barry OReilly <gundaetiapo@gmail.com>
To: emacs-devel@gnu.org
Subject: Simple lisp-tests.el and commit privs
Date: Sun, 21 Jul 2013 00:12:44 -0400	[thread overview]
Message-ID: <CAFM41H3j0meDBk3ZDNUMyFbjiVC8REYCT6ApRh=hTaXWLaVEfg@mail.gmail.com> (raw)

[-- 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)))))


             reply	other threads:[~2013-07-21  4:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-21  4:12 Barry OReilly [this message]
2013-07-21 23:08 ` Simple lisp-tests.el and commit privs 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFM41H3j0meDBk3ZDNUMyFbjiVC8REYCT6ApRh=hTaXWLaVEfg@mail.gmail.com' \
    --to=gundaetiapo@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).