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

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

[elpa] externals/hyperbole 1e8ea851ae 1/2: Add hui-select delimited-thin


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 1e8ea851ae 1/2: Add hui-select delimited-thing tests (#185)
Date: Sat, 16 Apr 2022 16:57:34 -0400 (EDT)

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

    Add hui-select delimited-thing tests (#185)
    
    * Add hui-select delimited-thing tests
    
    * Use -- for separation from prefix
    
    * Add hui-select-thing tests
---
 ChangeLog                |   9 +++
 test/MANIFEST            |   1 +
 test/hui-select-tests.el | 147 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 157 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 3599ed4bcb..e0745ff6a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-04-15  Mats Lidell  <matsl@gnu.org>
+
+* test/MANIFEST: Add hui-select.el
+
+* test/hui-select-tests.el (hui-select--thing)
+    (hui-select--thing-interactive-prints-type-of-match)
+    (hui-select--at-delimited-thing-p) (hui-select--delimited-thing)
+    (hui-select--delimited-thing-ending-in-newline): Add hui-select tests.
+
 2022-04-12  Bob Weiner  <rsw@gnu.org>
 
 * hypb.el (hypb:selectable-thing): Add and use in hypb:kill-ring-save, 
kotl-mode:kill-region,
diff --git a/test/MANIFEST b/test/MANIFEST
index 1812781f54..2700c67646 100644
--- a/test/MANIFEST
+++ b/test/MANIFEST
@@ -9,6 +9,7 @@ hmouse-drv-tests.el     - hmouse-drv unit tests
 hmouse-info-tests.el    - hmouse-info unit tests
 hpath-tests.el          - unit tests for hpath
 hsys-org-tests.el       - hsys-org tests
+hui-select-tests.el     - hui-select tests
 hui-tests.el            - Tests for hui.el
 hypb-tests.el           - test for hypb.el
 hyperbole-tests.el      - Tests for hyperbole.el
diff --git a/test/hui-select-tests.el b/test/hui-select-tests.el
new file mode 100644
index 0000000000..c8e76cfc8f
--- /dev/null
+++ b/test/hui-select-tests.el
@@ -0,0 +1,147 @@
+;;; hui-select-tests.el --- Unit tests        -*- lexical-binding: t; -*-
+
+;; Author:       Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date:    14-Apr-22 at 23:45:52
+;; Last-Mod:     15-Apr-22 at 23:53:52 by Mats Lidell
+;;
+;; Copyright (C) 2021  Free Software Foundation, Inc.
+;; See the "../HY-COPY" file for license information.
+;;
+;; This file is part of Hyperbole.
+;;
+;;; Commentary:
+;;
+;; Unit tests for "../hui-select.el"
+
+;;; Code:
+
+;;
+;;; ************************************************************************
+;;; Tests
+;;; ************************************************************************
+
+(require 'ert)
+(require 'hui-select)
+(require 'hy-test-helpers "test/hy-test-helpers")
+
+(declare-function hy-test-helpers:should-last-message "hy-test-helpers")
+
+(ert-deftest hui-select--at-delimited-thing-p ()
+  "At delimited thing p returns type of thing."
+  (with-temp-buffer
+    (insert "(\"x\") ")
+
+    ;; hui-select-sexp-start
+    (goto-char 1)
+    (should (equal (hui-select-at-delimited-thing-p) 'hui-select-sexp-start))
+
+    ;; hui-select-string
+    (goto-char 2)
+    (should (equal (hui-select-at-delimited-thing-p) 'hui-select-string))
+
+    ;; nil
+    (goto-char 3)
+    (should-not (hui-select-at-delimited-thing-p))
+
+    ;; hui-select-string
+    (goto-char 4)
+    (should (equal (hui-select-at-delimited-thing-p) 'hui-select-string))
+
+    ;; hui-select-sexp-end
+    (goto-char 5)
+    (should (equal (hui-select-at-delimited-thing-p) 'hui-select-sexp-end))))
+
+(ert-deftest hui-select--delimited-thing ()
+  "Delimited thing marks region of thing."
+  (with-temp-buffer
+    (insert "(\"x\") ")
+
+    ;; hui-select-sexp-start
+    (goto-char 1)
+    (should (hui-select-delimited-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "(\"x\")"))
+
+    ;; hui-select-string
+    (goto-char 2)
+    (should (hui-select-delimited-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "\"x\""))))
+
+
+(ert-deftest hui-select--delimited-thing-ending-in-newline ()
+  "Delimited thing marks region of thing when next char after things is a 
newline."
+  (with-temp-buffer
+    (insert "(\"x\")\n")
+
+    ;; hui-select-sexp-start
+    (goto-char 1)
+    (should (hui-select-delimited-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "(\"x\")\n"))))
+
+(ert-deftest hui-select--thing ()
+  "`hui-select-thing' selects bigger sections of text when called repeatedly."
+  (hui-select-reset)
+  (with-temp-buffer
+    (insert "Buffer\n\nParagraph\nline.  One word.\n")
+    (forward-char -3)
+
+    (should (hui-select-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "word"))
+
+    (should (hui-select-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "One word."))
+
+    (should (hui-select-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                     "line.  One word.\n"))
+
+    (should (hui-select-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                     "\nParagraph\nline.  One word.\n"))
+
+    (should (hui-select-thing))
+    (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                     "Buffer\n\nParagraph\nline.  One word.\n"))
+
+    (should-not (hui-select-thing))
+    (hy-test-helpers:should-last-message
+     "(hui-select-boundaries): ‘buffer’ is the largest selectable region")))
+
+(ert-deftest hui-select--thing-interactive-prints-type-of-match ()
+  "`hui-select-thing' selects bigger sections of text when called repeatedly.
+Verifies right type of match is printed when `hui-select-display-type' is set 
to t."
+  (skip-unless (not noninteractive))
+  (let ((hui-select-display-type t))
+    (hui-select-reset)
+    (with-temp-buffer
+      (insert "Buffer\n\nParagraph\nline.  One word.\n")
+      (forward-char -3)
+      (should (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message "word")
+      (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "word"))
+
+      (should (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message "sentence")
+      (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end)) "One word."))
+
+      (should (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message "line")
+      (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                       "line.  One word.\n"))
+
+      (should (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message "paragraph")
+      (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                       "\nParagraph\nline.  One word.\n"))
+
+      (should (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message "Buffer")
+      (should (string= (buffer-substring-no-properties (region-beginning) 
(region-end))
+                       "Buffer\n\nParagraph\nline.  One word.\n"))
+
+      (should-not (call-interactively 'hui-select-thing))
+      (hy-test-helpers:should-last-message
+       "(hui-select-boundaries): ‘buffer’ is the largest selectable region"))))
+
+(provide 'hui-select-tests)
+;;; hui-select-tests.el ends here



reply via email to

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