mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-07 15:21:46 +00:00
Convert ffap comments to tests
* test/lisp/ffap-tests.el (ffap-file-remote-p, ffap-machine-p): New tests.
This commit is contained in:
parent
38e7400a8c
commit
b8fdef7aa6
12
lisp/ffap.el
12
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))
|
||||
))
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user