From f2c6081a9c39d62d1c65e4c7880094fb8994da54 Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Thu, 28 Dec 2023 18:58:54 +0100 Subject: [PATCH 1/2] Add fast-demo test for outline section with line and column --- ChangeLog | 6 ++++++ FAST-DEMO | 6 +++--- test/demo-tests.el | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d01e670f..ef08cf8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-12-29 Mats Lidell + +* test/demo-tests.el + (fast-demo-outline-section-anchor-and-relative-line-number-test): Add + test for outline section with line and column. + 2023-12-28 Bob Weiner * hypb-ert.el (hypb-ert-def-at-p): Add support for `ert-deftest-async' from the diff --git a/FAST-DEMO b/FAST-DEMO index becac6b5..878b9081 100644 --- a/FAST-DEMO +++ b/FAST-DEMO @@ -135,11 +135,11 @@ ** Pathname Implicit Buttons - "HY-NEWS#ORG MODE:2:6" - outline section anchor & relative line number + "HY-NEWS#ORG MODE:3:6" - outline section anchor & relative line number Display the file, "HY-NEWS", go to the star-outline section 'ORG - MODE', move 2 lines into that section and then move 6 characters - forward. "HY-NEWS#ORG MODE:L2:C6" with the line and column numbers + MODE', move 3 lines into that section and then move 6 characters + forward. "HY-NEWS#ORG MODE:L3:C6" with the line and column numbers labeled works as well. Existing files and pathnames without spaces are also recognized without diff --git a/test/demo-tests.el b/test/demo-tests.el index be116cd8..c0c0260d 100644 --- a/test/demo-tests.el +++ b/test/demo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 25-Dec-23 at 23:30:20 by Mats Lidell +;; Last-Mod: 28-Dec-23 at 18:58:46 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -425,6 +425,21 @@ (hy-test-helpers:should-last-message "Factorial of 5 = 120")) (hy-test-helpers:kill-buffer "DEMO"))) +;;; Fast demo +;; Implicit Buttons +(ert-deftest fast-demo-outline-section-anchor-and-relative-line-number-test () + "Verify star outline section links with line and column works." + (dolist (link '("\"HY-NEWS#ORG MODE:3:6\"" "\"HY-NEWS#ORG MODE:L3:C6\"")) + (unwind-protect + (let ((default-directory hyperb:dir)) + (with-temp-buffer + (insert link) + (goto-char 3) + (action-key) + (should (string= (buffer-name (current-buffer)) "HY-NEWS")) + (should (looking-at-p "M-RET: Reworked")))) + (hy-test-helpers:kill-buffer "HY-NEWS")))) + ;; Fast demo key series (ert-deftest fast-demo-key-series-help-buffer () "Action key on C-hA brings up help buffer for action key." From d4c881007b8d7cd5bca07a7f500f0986fa8bc58a Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Fri, 29 Dec 2023 00:36:49 +0100 Subject: [PATCH 2/2] Add remaining test cases for fast-demo --- ChangeLog | 14 ++++- test/demo-tests.el | 151 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 153 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef08cf8c..f020cc7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,16 @@ 2023-12-29 Mats Lidell -* test/demo-tests.el - (fast-demo-outline-section-anchor-and-relative-line-number-test): Add - test for outline section with line and column. +* test/demo-tests.el (fast-demo-markdown-anchor-with-spaces) + (fast-demo-elisp-or-env-vars, fast-demo-elisp-library-in-load-path) + (fast-demo-info-manual-references, fast-demo-grep) + (fast-demo-python-trace-back, fast-demo-man-k) + (fast-demo-action-button-shell, fast-demo-action-button-fill-column) + (fast-demo-display-demo-using-action-buttons) + (fast-demo-display-kotl-starting-from-cell) + (fast-demo-outline-section-anchor-and-relative-line-number) + (fast-demo-markdown-anchor-with-spaces) + (fast-demo-elisp-library-in-load-path) + (fast-demo-elisp-or-env-vars): Add remaining test cases for fast-demo. 2023-12-28 Bob Weiner diff --git a/test/demo-tests.el b/test/demo-tests.el index c0c0260d..0b1c328d 100644 --- a/test/demo-tests.el +++ b/test/demo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 28-Dec-23 at 18:58:46 by Mats Lidell +;; Last-Mod: 29-Dec-23 at 00:19:28 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -240,13 +240,6 @@ (action-key) (hy-test-helpers:should-last-message "Result = nil; Boolean value = False"))) -(ert-deftest demo-implicit-button-action-button-variable-display-test () - (with-temp-buffer - (insert "") - (goto-char 2) - (action-key) - (hy-test-helpers:should-last-message (format "fill-column = %d" (current-fill-column))))) - (ert-deftest demo-implicit-button-hash-link-test () (unwind-protect (with-temp-buffer @@ -427,7 +420,7 @@ ;;; Fast demo ;; Implicit Buttons -(ert-deftest fast-demo-outline-section-anchor-and-relative-line-number-test () +(ert-deftest fast-demo-outline-section-anchor-and-relative-line-number () "Verify star outline section links with line and column works." (dolist (link '("\"HY-NEWS#ORG MODE:3:6\"" "\"HY-NEWS#ORG MODE:L3:C6\"")) (unwind-protect @@ -440,6 +433,50 @@ (should (looking-at-p "M-RET: Reworked")))) (hy-test-helpers:kill-buffer "HY-NEWS")))) +(ert-deftest fast-demo-markdown-anchor-with-spaces () + "Verify anchor with spaces works." + (unwind-protect + (let ((default-directory hyperb:dir)) + (with-temp-buffer + (insert "\"README.md#Hyperbole Components\"") + (goto-char 3) + (action-key) + (should (string= (buffer-name (current-buffer)) "README.md")) + (should (looking-at-p "## Hyperbole Components")))) + (hy-test-helpers:kill-buffer "README.md"))) + +(ert-deftest fast-demo-elisp-or-env-vars () + "Verify Elisp or env variables work in paths." + (unwind-protect + (with-temp-buffer + (insert "\"${hyperb:dir}/HY-NEWS\"") + (goto-char 3) + (action-key) + (should (string= (buffer-name (current-buffer)) "HY-NEWS"))) + (hy-test-helpers:kill-buffer "HY-NEWS"))) + +(ert-deftest fast-demo-elisp-library-in-load-path () + "Verify ibut to Elisp library works." + (let (bufname) + (unwind-protect + (with-temp-buffer + (insert "\"subr.el\"") + (goto-char 3) + (action-key) + (setq bufname (buffer-name (current-buffer))) + (should (string-prefix-p "subr.el" bufname)))) + (hy-test-helpers:kill-buffer bufname))) + +(ert-deftest fast-demo-info-manual-references () + "Verify info manual references works." + (unwind-protect + (with-temp-buffer + (insert "\"(hyperbole)action-key-modeline-function\"") + (goto-char 3) + (action-key) + (should (string= Info-current-node "Smart Mouse Key Modeline Clicks"))) + (hy-test-helpers:kill-buffer "*info*"))) + ;; Fast demo key series (ert-deftest fast-demo-key-series-help-buffer () "Action key on C-hA brings up help buffer for action key." @@ -696,5 +733,101 @@ enough files with matching mode loaded." ;; no-byte-compile: t ;; End: + +;; Fast Demo Grep Messages, Stack Trace, Man Page Apropos +(ert-deftest fast-demo-grep () + "Verify ibuts from grep searches works." + (unwind-protect + (with-temp-buffer + (insert "hactypes.el:454: (mapcar #'list (gbut:label-list))\nhbut.el:605: (mapcar #'list (gbut:label-list))\n") + (goto-char 3) + (action-key) + (should (string= (buffer-name (current-buffer)) "hactypes.el")) + (should (= (line-number-at-pos) 454))) + (hy-test-helpers:kill-buffer "hactypes.el"))) + +(ert-deftest fast-demo-python-trace-back () + "Verify ibuts from python traceback works." + (unwind-protect + (let ((default-directory hyperb:dir)) + (with-temp-buffer + (insert "Traceback (most recent call last):\n File \"topwin.py\", line 18, in \n import Quartz\n") + (goto-char (point-min)) + (forward-line 1) + (goto-char (+ (point) 3)) + (action-key) + (should (string= (buffer-name (current-buffer)) "topwin.py")) + (should (= (line-number-at-pos) 18)))) + (hy-test-helpers:kill-buffer "topwin.py"))) + +(ert-deftest fast-demo-man-k () + "Verify ibut in man -k output displays the associated man page." + (with-temp-buffer + (insert "aspell(1) - interactive spell checker") + (goto-char 3) + (with-mock + (mock (man "aspell(1)") => t) + (action-key)))) + +;; Fast Demo Action Buttons +(ert-deftest fast-demo-action-button-shell () + "Verify a shell is created when action button for shell is invoked." + (unwind-protect + (with-temp-buffer + (insert "") + (goto-char 3) + (action-key) + (should (string= (buffer-name (current-buffer)) "*shell*"))) + (let (kill-buffer-hook kill-buffer-query-functions) + (hy-test-helpers:kill-buffer "*shell*")))) + +(ert-deftest fast-demo-action-button-fill-column () + "Verify the value of `fill-column' is displayed in the minibuffer." + (with-temp-buffer + (insert "") + (goto-char 2) + (action-key) + (hy-test-helpers:should-last-message (format "fill-column = %d" (current-fill-column))))) + +(ert-deftest fast-demo-display-demo-using-action-buttons () + "Verify the three ways show in the demo works." + (unwind-protect + (with-temp-buffer + (insert "") + (goto-char 5) + (let ((enable-local-variables nil)) + (action-key)) + (should (string= "DEMO" (buffer-name)))) + (hy-test-helpers:kill-buffer "DEMO")) + (unwind-protect + (with-temp-buffer + (insert "") + (goto-char 5) + (let ((enable-local-variables nil)) + (action-key)) + (should (string= "DEMO" (buffer-name)))) + (hy-test-helpers:kill-buffer "DEMO")) + (unwind-protect + (with-temp-buffer + (insert "\"${hyperb:dir}/DEMO\"") ; Need double quotes - Error!? + (goto-char 5) + (let ((enable-local-variables nil)) + (action-key)) + (should (string= "DEMO" (buffer-name)))) + (hy-test-helpers:kill-buffer "DEMO"))) + +(ert-deftest fast-demo-display-kotl-starting-from-cell () + "Verify a kotl file can be displayed from cell ref." + (unwind-protect + (let ((default-directory hyperb:dir)) + (with-temp-buffer + (insert "") + (goto-char 5) + (action-key) + (should (string= "EXAMPLE.kotl" (buffer-name))) + ;; FIXME: Add verification of lines per cell + (should (looking-at-p "Cell Transposition:")))) + (hy-test-helpers:kill-buffer "EXAMPLE.kotl"))) + (provide 'demo-tests) ;;; demo-tests.el ends here