Give '$' punctuation syntax in make-mode (Bug#24477)
[emacs.git] / test / lisp / ffap-tests.el
blob479d8c66939555f3969acea5e3694d7852b5c23c
1 ;;; ffap-tests.el --- Test suite for ffap.el -*- lexical-binding: t -*-
3 ;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
5 ;; Author: Tino Calancha <tino.calancha@gmail.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;;; Code:
26 (require 'cl-lib)
27 (require 'ert)
28 (require 'ffap)
30 (ert-deftest ffap-tests-25243 ()
31 "Test for https://debbugs.gnu.org/25243 ."
32 (let ((file (make-temp-file "test-Bug#25243")))
33 (unwind-protect
34 (with-temp-file file
35 (let ((str "diff --git b/lisp/ffap.el a/lisp/ffap.el
36 index 3d7cebadcf..ad4b70d737 100644
37 --- b/lisp/ffap.el
38 +++ a/lisp/ffap.el
39 @@ -203,6 +203,9 @@ ffap-foo-at-bar-prefix
40 "))
41 (transient-mark-mode 1)
42 (when (natnump ffap-max-region-length)
43 (insert
44 (concat
45 str
46 (make-string ffap-max-region-length #xa)
47 (format "%s ENDS HERE" file)))
48 (call-interactively 'mark-whole-buffer)
49 (should (equal "" (ffap-string-at-point)))
50 (should (equal '(1 1) ffap-string-at-point-region)))))
51 (and (file-exists-p file) (delete-file file)))))
53 (ert-deftest ffap-gopher-at-point ()
54 (with-temp-buffer
55 (insert "\
56 Type = 1
57 Name = foo
58 Path = /the/path
59 Port = 7070
60 Host = example.com\n")
61 (should-not (ffap-gopher-at-point))
62 (goto-char (point-min))
63 (should (equal (ffap-gopher-at-point)
64 "gopher://example.com:7070/1/the/path"))
65 (should (equal ffap-string-at-point-region
66 (list (point-min) (point-max))))
67 (let ((ffap-gopher-regexp nil))
68 (should-not (ffap-gopher-at-point)))))
70 (ert-deftest ffap-other-window--bug-25352 ()
71 "Test for Bug#25352. Checks that the window configuration is
72 left alone when opening a URL in an external browser."
73 (cl-letf* ((old (current-window-configuration))
74 ((symbol-function 'ffap-prompter)
75 (lambda () "https://www.gnu.org"))
76 (urls nil)
77 (ffap-url-fetcher (lambda (url) (push url urls) nil)))
78 (should-not (ffap-other-window))
79 (should (equal (current-window-configuration) old))
80 (should (equal urls '("https://www.gnu.org")))))
82 (provide 'ffap-tests)
84 ;;; ffap-tests.el ends here