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: Tue, 29 Dec 2020 16:22:49 +0100 Message-ID: References: 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="33280"; mail-complaints-to="usenet@ciao.gmane.io" To: 45535@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 29 16:24:30 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 1kuGrO-0008Yb-6T for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 16:24:30 +0100 Original-Received: from localhost ([::1]:49684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuGrN-0007W0-8W for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 10:24:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuGqx-0007VL-7L for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 10:24:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuGqw-00080q-Ob for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 10:24:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kuGqw-00076V-G6 for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 10:24: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: Tue, 29 Dec 2020 15:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45535 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160925539227238 (code B ref -1); Tue, 29 Dec 2020 15:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Dec 2020 15:23:12 +0000 Original-Received: from localhost ([127.0.0.1]:39949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuGq7-00075G-EK for submit@debbugs.gnu.org; Tue, 29 Dec 2020 10:23:11 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:42410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuGq3-000757-UE for submit@debbugs.gnu.org; Tue, 29 Dec 2020 10:23:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuGq3-0006vO-Np for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 10:23:07 -0500 Original-Received: from sonic303-20.consmr.mail.ir2.yahoo.com ([77.238.178.201]:42244) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuGpx-0007eU-PB for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 10:23:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1609255373; bh=QPSwTFJLFpmam0N4lAV1k8Do609vGcQICurHk0DP6Ik=; h=From:To:Subject:Date:References:From:Subject; b=MI4rdmMN/yGZYbBEgDVzUqzkUOENSKzZEBxXVQYrtSbxVxcexHC+oiu3fAUZiSjYox05fV96AY/Wi2+j2aJr4AtlcIdQ33sEKoRCoKvceGh/pgxImY7jqwITrR74s6IjGG+ase4qXWAiBj+oFSQDtCm7VZH6mbW5518m2POGY3imOTD/fBLP4VwCelzMV++tanzMyRfsDHnzqpqIGnWIrw7tJWNmeGvlVKxH3oL5yFmvLuhpcDxHmO4LVldjp+BWFhKIO2/i8zEbA5Oe2GtSDtnk5EOWnmGoXUdPXpUC4A1BC42xUbygJzRmbXtOv3d0z0W8ZX3v3v70GolPOqOIvQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1609255373; bh=MZ7j3uxxRh5HyR/gXMHf3aEjH4/Z1TLpNLXWZq63jrH=; h=From:To:Subject:Date:From:Subject; b=WdS5dgk9jqaI12hSUehCXIP3HxDsILhxVwNkjPTZkWVkLOB2TRabbdB+1dkaCfZilRRZWVqbATf2XjrufYAAbUlQeV1+ymEi3T+FwfSpNOzLb4dRgdWPWdFZUpZCuf1dKNQCZ4L+1VucC2FXLkLTV+c77dHeL3AMSVErIl4HWE5SFjCu2l2oU+HimJrRjwspMfF3KgX9kBemNI0FeHC1t1isPld5jF1iGEeM0u57O4GFpFTACIl+45q51Ut+KWaLZWEl5pLw1enS0jX3dmdYCLwzrpJgkntkKwMfM59T/KD52xh4qB7TUlj3EJy7dCa4mnHjSPQpV7YII9tH5IbbiA== X-YMail-OSG: P6rV9e4VM1kzkBKHJmuugz5YEcCJ0UIYV6CrEFObbAuWlABzeqtMqBGY3BmY0ku 6xoDfPp_OzW.P.cVLny0xHSBmu.Z0POFPUAxbWOIzr64TdIrEMf92ntt8Cf__Iyeyfo9A79vogwH 5S_7cYkmC3lvENfJ6fYxwnN0hu0MKW0WHDttJp_7z4RDtqE7nYpFZj8oP_gGc4PL5TED3YJFTZEj tz6nsJw9bKx.tIChNGLIo2q_Ok2y3mPHHSkEBtNI7uvbnUoWs2wQb8Zv16AZGt_PUHtZ4eYAquRB bWa0D5Y2P2fHQNcT9kOV4LyTZOH2vHBoo6.16Zj1RQ10JBllg3gQEzm4FMaeVG.ENih.4jlSQjP_ 1qYUym6uGaXKoBmAaIfjmiQNmylQnIkLH1zqI1Lq4mmcCJ._sZDpldNKFXxW_JexoPnlroj2Fpn9 2PXEUT7QSPWUfgGKrB1P0QCmFmdyxCGXZ8xA2rWw75Qr7fAAqo6wKcBvYZR0.7P7U3Z8oanilLv7 CGnnA0KIgUU31hNDbgK6_Yl8UmTUz7ooZdrdp8pUC243k.7zo_TErFfODrOskUFd.zEWMDKv8Cin CJT6mvWAGrw_sRhWRVj_PwQnguvdLMKCIYbaWo39C0QmlwKGZbFjtQlmpSIIdSvocDW5uLddOH5U VR4soxFxW0R_cBzkgTXuOnbvlyntoiMJiRir4WdsIsK_n_blX3FQeA3CGLicnQxcBGWJzVuODvqC 6t5rzWULyISLNoqNf3Mpt6iC8w9z4Kio63L0H_9RqFbc9wpkcV8PppoPcf1iKOyC1SaoEDwQbT_J N7O__8XVHfUe4xhtFmPJGV2LJqOm676gnKd65GcObW Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Tue, 29 Dec 2020 15:22:53 +0000 Original-Received: by smtp423.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 28685ee09696340641ddd0fc8d5d6c82; Tue, 29 Dec 2020 15:22:50 +0000 (UTC) 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) Received-SPF: pass client-ip=77.238.178.201; envelope-from=mardani29@yahoo.es; helo=sonic303-20.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:196940 Archived-At: --=-=-= Content-Type: text/plain Here's a patch with some tests that cover interesting bits of functionality in find-func.el. Thanks. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-some-tests-to-find-func.el.patch Content-Transfer-Encoding: quoted-printable >From 21c7c7ab2e4ec8cb262d91585296d43ebaf04ac5 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Daniel=3D20Mart=3DC3=3DADn?=3D 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 | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/lisp/emacs-lisp/find-func-tests.el b/test/lisp/emacs-lisp= /find-func-tests.el index 03df4bb9ff..14ad48fc65 100644 --- a/test/lisp/emacs-lisp/find-func-tests.el +++ b/test/lisp/emacs-lisp/find-func-tests.el @@ -27,6 +27,7 @@ ;;; Code: =20 (require 'ert-x) ;For `ert-run-keys'. +(require 'find-func) =20 (ert-deftest find-func-tests--library-completion () ;bug#43393 ;; FIXME: How can we make this work in batch (see also @@ -43,6 +44,66 @@ find-func-tests--library-completion (concat data-directory (kbd "n x / TAB RET")) (read-library-name))))) =20 +(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-equal + (buffer-substring (line-beginning-position) (point)) + "=E2=80=98join-line=E2=80=99 is an alias for =E2=80=98delet= e-indentation=E2=80=99"))))) + ;; Avoid a byte-compilation warning that may confuse people reading ;; the result of the following test. (declare-function compilation--message->loc nil "compile") --=20 2.28.0 --=-=-=--