diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-06 10:09:13 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-06 10:09:53 -0700 |
commit | 81204b276f849b577a0ccd0b6175353dfa9e2a07 (patch) | |
tree | 0b3c205165739eafbaa5f315caf9f16fe03800aa /test/automated/xref-tests.el | |
parent | 89ce83b20249dfb4e45f09dfdddf4c4b66d82968 (diff) | |
download | emacs-81204b276f849b577a0ccd0b6175353dfa9e2a07.tar.gz emacs-81204b276f849b577a0ccd0b6175353dfa9e2a07.tar.bz2 emacs-81204b276f849b577a0ccd0b6175353dfa9e2a07.zip |
Port xref-tests to master branch
Also, add a test to make this problem less likely in the future.
* test/Makefile.in (check-no-automated-subdir): New rule.
(check, check-expensive, check-maybe): Depend on it.
* test/automated/data/xref/file1.txt: Rename to ...
* test/data/xref/file1.txt: ... here.
* test/automated/data/xref/file2.txt: Rename to ...
* test/data/xref/file2.txt: ... here.
* test/automated/xref-tests.el: Rename to ...
* test/lisp/progmodes/xref-tests.el: ... here.
(xref-tests-data-dir): Use EMACS_TEST_DIRECTORY.
Diffstat (limited to 'test/automated/xref-tests.el')
-rw-r--r-- | test/automated/xref-tests.el | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/test/automated/xref-tests.el b/test/automated/xref-tests.el deleted file mode 100644 index 079b196aa8b..00000000000 --- a/test/automated/xref-tests.el +++ /dev/null @@ -1,91 +0,0 @@ -;;; xref-tests.el --- tests for xref - -;; Copyright (C) 2016 Free Software Foundation, Inc. - -;; Author: Dmitry Gutov <dgutov@yandex.ru> - -;; 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 'xref) -(require 'cl-lib) - -(defvar xref-tests-data-dir - (expand-file-name "data/xref/" - (file-name-directory (or load-file-name (buffer-file-name))))) - -(ert-deftest xref-collect-matches-finds-none-for-some-regexp () - (should (null (xref-collect-matches "zzz" "*" xref-tests-data-dir nil)))) - -(ert-deftest xref-collect-matches-finds-some-for-bar () - (let* ((matches (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) - (locs (cl-sort (mapcar #'xref-item-location matches) - #'string< - :key #'xref-location-group))) - (should (= 2 (length matches))) - (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs)))) - (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs)))))) - -(ert-deftest xref-collect-matches-finds-two-matches-on-the-same-line () - (let* ((matches (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) - (locs (mapcar #'xref-item-location matches))) - (should (= 2 (length matches))) - (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs)))) - (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs)))) - (should (equal 1 (xref-location-line (nth 0 locs)))) - (should (equal 1 (xref-location-line (nth 1 locs)))) - (should (equal 0 (xref-file-location-column (nth 0 locs)))) - (should (equal 4 (xref-file-location-column (nth 1 locs)))))) - -(ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match () - (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil)) - (locs (mapcar #'xref-item-location matches))) - (should (= 1 (length matches))) - (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs)))) - (should (equal 1 (xref-location-line (nth 0 locs)))) - (should (equal 0 (xref-file-location-column (nth 0 locs)))))) - -(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 () - (let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) - (iter (xref--buf-pairs-iterator xrefs)) - (cons (funcall iter :next))) - (should (null (funcall iter :next))) - (should (string-match "file1\\.txt\\'" (buffer-file-name (car cons)))) - (should (= 2 (length (cdr cons)))))) - -(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 () - (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) - (iter (xref--buf-pairs-iterator xrefs)) - (cons1 (funcall iter :next)) - (cons2 (funcall iter :next))) - (should (null (funcall iter :next))) - (should-not (equal (car cons1) (car cons2))) - (should (= 1 (length (cdr cons1)))) - (should (= 1 (length (cdr cons2)))))) - -(ert-deftest xref--buf-pairs-iterator-cleans-up-markers () - (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) - (iter (xref--buf-pairs-iterator xrefs)) - (cons1 (funcall iter :next)) - (cons2 (funcall iter :next))) - (funcall iter :cleanup) - (should (null (marker-position (car (nth 0 (cdr cons1)))))) - (should (null (marker-position (cdr (nth 0 (cdr cons1)))))) - (should (null (marker-position (car (nth 0 (cdr cons2)))))) - (should (null (marker-position (cdr (nth 0 (cdr cons2)))))))) |