emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole fdac2af: Add pathname test cases (#64)


From: ELPA Syncer
Subject: [elpa] externals/hyperbole fdac2af: Add pathname test cases (#64)
Date: Fri, 16 Apr 2021 01:57:07 -0400 (EDT)

branch: externals/hyperbole
commit fdac2afb96980d1c380d6234b5c919a5d220f78f
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>

    Add pathname test cases (#64)
---
 Changes                | 10 ++++++
 test/hibtypes-tests.el | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)

diff --git a/Changes b/Changes
index 4e8514e..e94b237 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,13 @@
+2021-04-15  Mats Lidell  <matsl@gnu.org>
+
+* test/hibtypes-tests.el (ibtypes::pathname-anchor-test)
+    (ibtypes::pathname-anchor-line-test, ibtypes::pathname-line-column-test)
+    (ibtypes::pathname-load-path-line-column-test)
+    (ibtypes::pathname-with-dash-loads-file-test)
+    (ibtypes::pathname-directory-test)
+    (ibtypes::pathname-dot-slash-in-other-folder-test)
+    (ibtypes::pathname-dot-slash-in-same-folder-test): Pathname test cases.
+
 2021-04-11  Mats Lidell  <matsl@gnu.org>
 
 * test/hibtypes-tests.el (ibtypes::ctags-vgrind-test)
diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el
index 498b611..cacdc6c 100644
--- a/test/hibtypes-tests.el
+++ b/test/hibtypes-tests.el
@@ -89,6 +89,95 @@
         (should (string= "hyperbole.el" (buffer-name)))))
   (kill-buffer "hyperbole.el"))
 
+(ert-deftest ibtypes::pathname-anchor-test ()
+  "Pathname with anchor."
+  (unwind-protect
+      (with-temp-buffer
+        (insert "\"${hyperb:dir}/DEMO#Smart Keys\"")
+        (goto-char 2)
+        (ibtypes::pathname)
+        (should (string= "DEMO" (buffer-name)))
+        (should (looking-at "\* Smart Keys")))
+    (kill-buffer "DEMO")))
+
+(ert-deftest ibtypes::pathname-anchor-line-test ()
+  "Pathname with anchor and line specification."
+  (unwind-protect
+      (with-temp-buffer
+        (insert "\"${hyperb:dir}/DEMO#Smart Keys:2\"")
+        (goto-char 2)
+        (ibtypes::pathname)
+        (should (string= "DEMO" (buffer-name)))
+        (forward-line -2)
+        (should (looking-at "\* Smart Keys")))
+    (kill-buffer "DEMO")))
+
+(ert-deftest ibtypes::pathname-line-column-test ()
+  "Pathname with line and position specification."
+  (unwind-protect
+      (with-temp-buffer
+        (insert "\"${hyperb:dir}/DEMO:3:45\"")
+        (goto-char 2)
+        (ibtypes::pathname-line-and-column)
+        (should (string= "DEMO" (buffer-name)))
+        (should (= (line-number-at-pos) 3))
+        (should (= (current-column) 45)))
+    (kill-buffer "DEMO")))
+
+(ert-deftest ibtypes::pathname-load-path-line-column-test ()
+  "Pathname with line and position specification."
+  (unwind-protect
+      (with-temp-buffer
+        (insert "\"${load-path}/hypb.el:10:5\"")
+        (goto-char 2)
+        (ibtypes::pathname-line-and-column)
+        (should (string= "hypb.el" (buffer-name)))
+        (should (= (line-number-at-pos) 10))
+        (should (= (current-column) 5)))
+    (kill-buffer "hypb.el")))
+
+(ert-deftest ibtypes::pathname-with-dash-loads-file-test ()
+  "Pathname with dash loads file.
+Bug: Fails with 'Invalid function: hact'."
+  :expected-result :failed
+  (with-temp-buffer
+    (insert "\"-${hyperb:dir}/test/hy-test-dependencies.el\"")
+    (goto-char 2)
+    (ibtypes::pathname)))
+
+(ert-deftest ibtypes::pathname-directory-test ()
+  "Pathname with directory opens dired."
+  (unwind-protect
+      (with-temp-buffer
+        (insert "\"/tmp\"")
+        (goto-char 2)
+        (ibtypes::pathname)
+        (should (string= "tmp" (buffer-name)))
+        (should (eq major-mode 'dired-mode)))
+    (kill-buffer "tmp")))
+
+(ert-deftest ibtypes::pathname-dot-slash-in-other-folder-test ()
+  "Pathname that starts with ./ only works if in same folder."
+  (with-temp-buffer
+    (insert "\"./hypb.el\"")
+    (goto-char 2)
+    (let ((help-buffer "*Help: Hyperbole Action Key*")
+          (default-directory (expand-file-name "test" hyperb:dir)))
+      (hkey-help)
+      (set-buffer help-buffer)
+      (should (string-match "no matching context" (buffer-string))))))
+
+(ert-deftest ibtypes::pathname-dot-slash-in-same-folder-test ()
+  "Pathname that starts with ./ only works if in same folder."
+  (with-temp-buffer
+    (insert "\"./hypb.el\"")
+    (goto-char 2)
+    (let ((help-buffer "*Help: Hyperbole Action Key*")
+          (default-directory hyperb:dir))
+      (hkey-help)
+      (set-buffer help-buffer)
+      (should (string-match "actype:.*link-to-file" (buffer-string))))))
+
 ;; Function in buffer XEmac functionality. Is there somethign similar in Emacs?
 
 ;; ibtypes::annot-bib



reply via email to

[Prev in Thread] Current Thread [Next in Thread]