From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Occur multi-line matches Date: Tue, 23 Mar 2010 09:42:47 +0200 Organization: JURTA Message-ID: <87fx3rlc1w.fsf@mail.jurta.org> References: <87fx3rmrie.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1269331583 2541 80.91.229.12 (23 Mar 2010 08:06:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 23 Mar 2010 08:06:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 23 09:06:17 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ntz7d-0003hI-DG for ged-emacs-devel@m.gmane.org; Tue, 23 Mar 2010 09:06:07 +0100 Original-Received: from localhost ([127.0.0.1]:36228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ntz7X-00032Z-71 for ged-emacs-devel@m.gmane.org; Tue, 23 Mar 2010 04:05:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ntylz-0005cL-1L for emacs-devel@gnu.org; Tue, 23 Mar 2010 03:43:35 -0400 Original-Received: from [140.186.70.92] (port=50673 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ntylw-0005aT-GT for emacs-devel@gnu.org; Tue, 23 Mar 2010 03:43:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ntylv-0004Gb-6P for emacs-devel@gnu.org; Tue, 23 Mar 2010 03:43:32 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:44089 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ntylu-0004GW-Qc for emacs-devel@gnu.org; Tue, 23 Mar 2010 03:43:31 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.30.14.cable.starman.ee [82.131.30.14]) by mx1.starman.ee (Postfix) with ESMTP id 204713F4093 for ; Tue, 23 Mar 2010 09:43:23 +0200 (EET) In-Reply-To: <87fx3rmrie.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 23 Mar 2010 09:27:33 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:122534 Archived-At: --=-=-= There is a new file occur-testsuite.el for the `test' subdir to test regressions in occur functionality. I could port tests to unit test frameworks when they will be added to Emacs. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=occur-testsuite.el Content-Transfer-Encoding: quoted-printable ;;; occur-testsuite.el --- Test suite for occur. ;; Copyright (C) 2010 Free Software Foundation, Inc. ;; Author: Juri Linkov ;; Keywords: matching, internal ;; 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 . ;;; Commentary: ;; Type M-x test-occur RET to test the functionality of `occur'. ;;; Code: (defconst occur-tests '( ;; * Test one-line matches (at bob, eob, bol, eol). ("x" 0 "\ xa b cx xd xex fx " "\ 5 matches for \"x\" in buffer: *temp* 1:xa 3:cx 4:xd 5:xex 6:fx ") ;; * Test multi-line matches, this is the first test from ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html ;; where numbers are replaced with letters. ("a\na" 0 "\ a a a a a " "\ 2 matches for \"a^Ja\" in buffer: *temp* 1:a :a 3:a :a ") ;; * Test multi-line matches, this is the second test from ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html ;; where numbers are replaced with letters. ("a\nb" 0 "\ a b c a b " "\ 2 matches for \"a^Jb\" in buffer: *temp* 1:a :b 4:a :b ") ;; * Test line numbers for multi-line matches with empty last match lin= e. ("a\n" 0 "\ a c a " "\ 2 matches for \"a^J\" in buffer: *temp* 1:a : 4:a : ") ;; * Test multi-line matches with 3 match lines. ("x\n.x\n" 0 "\ ax bx c d ex fx " "\ 2 matches for \"x^J.x^J\" in buffer: *temp* 1:ax :bx :c 5:ex :fx : ") ) "List of tests for `occur'. Each element has the format: \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") (defun test-occur () (interactive) (let ((count 1) failed (occur-hook nil)) (dolist (test occur-tests) (let ((regexp (nth 0 test)) (nlines (nth 1 test)) (input-buffer-string (nth 2 test)) (output-buffer-string (nth 3 test))) (save-excursion (with-temp-buffer (insert input-buffer-string) (occur regexp nlines) (unless (equal output-buffer-string (with-current-buffer "*Occur*" (buffer-string))) (setq failed (cons count failed)))))) (setq count (1+ count))) (if failed (message "FAILED TESTS: %S" (reverse failed)) (message "SUCCESS")))) (provide 'occur-testsuite) ;;; occur-testsuite.el ends here --=-=-= -- Juri Linkov http://www.jurta.org/emacs/ --=-=-=--