summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2022-07-28 14:38:24 +0200
committerStefan Kangas <stefan@marxist.se>2022-07-28 15:07:34 +0200
commitb8fdef7aa65f5b1d2eeb726ff1627d9e169c2b3a (patch)
treef743b882b3da21c38cafe40eb05634f72f844e96
parent38e7400a8c1feaba4362c3d7ab9d44d360a1fac6 (diff)
downloademacs-b8fdef7aa65f5b1d2eeb726ff1627d9e169c2b3a.tar.gz
Convert ffap comments to tests
* test/lisp/ffap-tests.el (ffap-file-remote-p, ffap-machine-p): New tests.
-rw-r--r--lisp/ffap.el12
-rw-r--r--test/lisp/ffap-tests.el19
2 files changed, 20 insertions, 11 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el
index dc286db130d..ffed9f9759d 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -427,13 +427,6 @@ Returned values:
t means that HOST answered.
`accept' means the relevant variable told us to accept.
\"mesg\" means HOST exists, but does not respond for some reason."
- ;; Try some (Emory local):
- ;; (ffap-machine-p "ftp" nil nil 'ping)
- ;; (ffap-machine-p "nonesuch" nil nil 'ping)
- ;; (ffap-machine-p "ftp.mathcs.emory.edu" nil nil 'ping)
- ;; (ffap-machine-p "mathcs" 5678 nil 'ping)
- ;; (ffap-machine-p "foo.bonk" nil nil 'ping)
- ;; (ffap-machine-p "foo.bonk.com" nil nil 'ping)
(if (or (string-match "[^-[:alnum:].]" host) ; Invalid chars (?)
(not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject
nil
@@ -530,9 +523,6 @@ The optional NOMODIFY argument suppresses the extra search."
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
- ;; (ffap-file-remote-p "/user@foo.bar.com:/pub")
- ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
- ;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
;; Convert "/host.com://dir" to "/host:/dir", to handle a dying
@@ -573,7 +563,7 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
;; www.ncsa.uiuc.edu
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
- ;; More cases? Maybe "telnet:" for archie?
+ ;; More cases?
(ffap-ftp-regexp (ffap-host-to-filename mach))
))
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index a11af9507ef..076d8256421 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -33,6 +33,25 @@
(ffap-replace-file-component "/ftp:who@foo.com:/whatever" "/new")
"/ftp:who@foo.com:/new")))
+(ert-deftest ffap-file-remote-p ()
+ (dolist (test '(("/user@foo.bar.com:/pub" .
+ "/user@foo.bar.com:/pub")
+ ("/cssun.mathcs.emory.edu://dir" .
+ "/cssun.mathcs.emory.edu:/dir")
+ ("/ffap.el:80" .
+ "/ffap.el:80")))
+ (let ((A (car test))
+ (B (cdr test)))
+ (should (equal (ffap-file-remote-p A) B)))))
+
+(ert-deftest ffap-machine-p ()
+ (should-not (ffap-machine-p "ftp"))
+ (should-not (ffap-machine-p "nonesuch"))
+ (should (eq (ffap-machine-p "ftp.mathcs.emory.edu") 'accept))
+ (should-not (ffap-machine-p "mathcs" 5678))
+ (should-not (ffap-machine-p "foo.bonk"))
+ (should (eq (ffap-machine-p "foo.bonk.com") 'accept)))
+
(ert-deftest ffap-tests-25243 ()
"Test for https://debbugs.gnu.org/25243 ."
(ert-with-temp-file file