From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Unknown Newsgroups: gmane.emacs.bugs Subject: bug#45535: 28.0.50; [PATCH] Add some tests to find-func.el Date: Wed, 30 Dec 2020 12:04:32 +0100 Message-ID: References: <87o8icose4.fsf@gnus.org> Reply-To: =?UTF-8?Q?Reply-to=3A_Daniel_Mart=C3=83=C2=ADn_=3Cmardani29=40yahoo=2Ees?= =?UTF-8?Q?=3E=0A?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11779"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cc: 45535@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 30 12:05:39 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuZIQ-0002sn-J0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Dec 2020 12:05:38 +0100 Original-Received: from localhost ([::1]:41028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuZIP-00026G-Jr for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Dec 2020 06:05:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuZHw-00025W-BN for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 06:05:13 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuZHq-0002M8-Dx for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 06:05:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kuZHq-0007QT-94 for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 06:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Dec 2020 11:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45535 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45535-submit@debbugs.gnu.org id=B45535.160932629128525 (code B ref 45535); Wed, 30 Dec 2020 11:05:02 +0000 Original-Received: (at 45535) by debbugs.gnu.org; 30 Dec 2020 11:04:51 +0000 Original-Received: from localhost ([127.0.0.1]:42014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuZHe-0007Q0-Gi for submit@debbugs.gnu.org; Wed, 30 Dec 2020 06:04:50 -0500 Original-Received: from sonic312-25.consmr.mail.ir2.yahoo.com ([77.238.178.96]:38796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuZHZ-0007Pg-7b for 45535@debbugs.gnu.org; Wed, 30 Dec 2020 06:04:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1609326275; bh=9L5+BVySihDv9hrFfUakwf9Np7tvtEQdf5BEKgteOnc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject; b=W37p0oL4/1CjXwsZAjNeBQaP77gAhgfTFuVI0FjqSJ1BQJ3HO8mvCko6l20bswr1UFbttOSESiiCv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r65RfKKX4xJ.HKEnwcuKrZptU6L8PnrRs5F9RRPioUZlQVlW5zc1 DOfemij1eHR6kBQ.0wleH8S.lPYaIVkzC8bRHRWwxQ.b0MXgtgtAysAzbcG_WTYltQsGr3QibA.t abVjvSWaNz5FAnkoUBBXETxCve4xEPXKeu3fYWSRFbcICNHW3tGgMv1C753fHLNVttOREIWzcqWE kC9FdoHO5icmKzXXAryxULy9tuzFguiWrMz18eJ9fj1EJ0aZkCGLyBDa6ihfj6hKvTQMhCRuF.JI HixWNaHDY9eHumFruF6Y_aRLkgLVmJ4Cwzy6LL.M89LY_J9CZWc037abuOurmOQHkgiJlGbM3Ihu aYQJ8JUr.fe5pF75qf7AqHptuGXPbyxKXQc50Ci6B6vYE9.dL3.HS5Cz5_slNxUWJiozdEmg7kXS L0xoEtyF1ACP5rBJp5CZ7mJLmX4vXvbfc3T.PgrRM4eCovbaNmztgpr.j8JCd4JL2csESqXQ2ovR kJcqOv.fBrvUIPjuKTiMZc3LVxMNT_HQbG6p9Wn9aS Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ir2.yahoo.com with HTTP; Wed, 30 Dec 2020 11:04:35 +0000 Original-Received: by smtp418.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 7c11219b6d37ab4b891f643dcd68d019; Wed, 30 Dec 2020 11:04:33 +0000 (UTC) In-Reply-To: <87o8icose4.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 30 Dec 2020 05:00:03 +0100") X-Mailer: WebService/1.1.17278 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Original-From: Xref: news.gmane.io gmane.emacs.bugs:197019 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Lars Ingebrigtsen writes: > > find-func-tests--find-library-verbose fails with: > > (string-equal "`join-line' is an alias for `delete-indentation'" "= =E2=80=98join-line=E2=80=99 is an alias for =E2=80=98delete-indentation=E2= =80=99") > > So the `' didn't turn into =E2=80=98=E2=80=99 here (Debian bullseye). Oh, thanks for catching this. I've edited the assertion to make it more general. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-some-tests-to-find-func.el.patch >From a2290150f92689055b5f44dbda29cf28e6380a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Tue, 29 Dec 2020 16:12:58 +0100 Subject: [PATCH] Add some tests to find-func.el --- test/lisp/emacs-lisp/find-func-tests.el | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/lisp/emacs-lisp/find-func-tests.el b/test/lisp/emacs-lisp/find-func-tests.el index 03df4bb9ff..3960aff2a5 100644 --- a/test/lisp/emacs-lisp/find-func-tests.el +++ b/test/lisp/emacs-lisp/find-func-tests.el @@ -27,6 +27,7 @@ ;;; Code: (require 'ert-x) ;For `ert-run-keys'. +(require 'find-func) (ert-deftest find-func-tests--library-completion () ;bug#43393 ;; FIXME: How can we make this work in batch (see also @@ -43,6 +44,68 @@ find-func-tests--library-completion (concat data-directory (kbd "n x / TAB RET")) (read-library-name))))) +(ert-deftest find-func-tests--locate-symbols () + (should (cdr + (find-function-search-for-symbol + #'goto-line nil "simple"))) + (should (cdr + (find-function-search-for-symbol + 'minibuffer-history 'defvar "simple"))) + (should (cdr + (find-function-search-for-symbol + 'with-current-buffer nil "subr"))) + (should (cdr + (find-function-search-for-symbol + 'font-lock-warning-face 'defface "font-lock"))) + (should-not (cdr + (find-function-search-for-symbol + 'wrong-variable 'defvar "simple"))) + (should-not (cdr + (find-function-search-for-symbol + 'wrong-function nil "simple"))) + (should (cdr (find-function-noselect #'goto-line))) + (should (cdr (find-function-noselect #'goto-char))) + ;; Setting LISP-ONLY and passing a primitive should error. + (should-error (find-function-noselect #'goto-char t)) + (should-error (find-function-noselect 'wrong-function))) + +(defun test-locate-helper (func &optional expected-result) + "Assert on the result of `find-function-library' for FUNC. +EXPECTED-RESULT is an alist (FUNC . LIBRARY) with the +expected function symbol and function library, respectively." + (cl-destructuring-bind (orig-function . library) + (find-function-library func) + (cl-destructuring-bind (expected-func . expected-library) + expected-result + (should (eq orig-function expected-func)) + (should (and + (not (string-empty-p expected-library)) + (string-match-p expected-library library)))))) + +(ert-deftest find-func-tests--locate-library () + (test-locate-helper #'goto-line '(goto-line . "simple")) + (test-locate-helper #'forward-char '(forward-char . "cmds.c")) + (should-error (test-locate-helper 'wrong-function))) + +(ert-deftest find-func-tests--locate-adviced-symbols () + (defun my-message () + (message "Hello!")) + (advice-add #'mark-sexp :around 'my-message) + (test-locate-helper #'mark-sexp '(mark-sexp . "lisp")) + (advice-remove #'mark-sexp 'my-message)) + +(ert-deftest find-func-tests--find-library-verbose () + (find-function-library #'join-line nil t) + (with-current-buffer "*Messages*" + (save-excursion + (goto-char (point-max)) + (skip-chars-backward "\n") + (should (string-match-p + ".join-line. is an alias for .delete-indentation." + (buffer-substring + (line-beginning-position) + (point))))))) + ;; Avoid a byte-compilation warning that may confuse people reading ;; the result of the following test. (declare-function compilation--message->loc nil "compile") -- 2.28.0 --=-=-=--