branch: externals/hyperbole commit fc6df9d652b577ac6060c8a94576f270d318ff75 Merge: f098816abd 564c147587 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Merge remote branch 'rsw' into rsw --- ChangeLog | 5 ++++ test/hypb-ert-tests.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5bf51c6255..311ab9df5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,11 @@ for the Assist Key when on a Hyperbole button. hmouse-drv.el (hkey-help): Update to display proper Assist Key help. +2024-01-02 Mats Lidell <ma...@gnu.org> + +* test/hypb-ert-tests.el (hypb-ert-tests--def-at-p) + (hypb-ert-tests--edebug-is-called): Add tests for hypb-ert. + 2024-01-01 Bob Weiner <r...@gnu.org> * hypb-ert.el (hypb-ert-def-at-p): Update doc. Fix grouping ref that was diff --git a/test/hypb-ert-tests.el b/test/hypb-ert-tests.el new file mode 100644 index 0000000000..cdc39118f9 --- /dev/null +++ b/test/hypb-ert-tests.el @@ -0,0 +1,63 @@ +;;; hypb-ert-tests.el --- tests for hypb-ert -*- lexical-binding: t; -*- +;; +;; Author: Mats Lidell +;; +;; Orig-Date: 1-Jan-24 at 23:11:54 +;; Last-Mod: 2-Jan-24 at 00:28:42 by Mats Lidell +;; +;; SPDX-License-Identifier: GPL-3.0-or-later +;; +;; Copyright (C) 2024 Free Software Foundation, Inc. +;; See the "HY-COPY" file for license information. +;; +;; This file is part of GNU Hyperbole. + +;;; Commentary: +;; + +;;; Code: + +(require 'ert) +(require 'el-mock) +(require 'hypb-ert) + +(ert-deftest hypb-ert-tests--def-at-p () + "Verify an `ert-deftest' name is identified." + (let ((test-name "hypb-ert-tests--test")) + (with-temp-buffer + (insert "(ert-deftest " test-name " ()\n\"Docstring.\"\nt\n)\n") + + (goto-char (point-min)) + (should-not (hypb-ert-def-at-p)) + + (goto-char (1+ (point-min))) + (should (string= (hypb-ert-def-at-p) test-name)) + + (goto-char (- (line-end-position) 3)) + (should (string= (hypb-ert-def-at-p) test-name)) + + (goto-char (- (line-end-position) 2)) + (should-not (hypb-ert-def-at-p)) + + (end-of-line) + (should-not (hypb-ert-def-at-p)) + + (goto-char (1+ (point-min))) + (pcase-let ((`(,name ,start ,end) + (hypb-ert-def-at-p t))) + (should (string= name test-name)) + (should (string= (buffer-substring start end) test-name)))))) + +(ert-deftest hypb-ert-tests--edebug-is-called () + "Verify `edebug-defun' is called when debug-it argument is set." + (let ((test-name "hypb-ert-tests--test")) + (with-temp-buffer + (insert "(ert-deftest " test-name " ()\n\"Docstring.\"\nt\n)\n") + (emacs-lisp-mode) + (goto-char (1+ (point-min))) + (mocklet (((edebug-defun) => t) + ((hypb-ert *) => t)) + (hypb-ert-run-test-at-definition test-name t))))) + +(provide 'hypb-ert-tests) +;;; hypb-ert-tests.el ends here