From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jeremy Bryant via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68929: Fwd: Re: bug#68929: which-key tests from GNU ELPA into core Date: Sun, 14 Apr 2024 22:56:48 +0100 Message-ID: <87edb7zjz3.fsf@jeremybryant.net> References: <87zfvl8r4e.fsf@jeremybryant.net> <874jdspsqb.fsf@bernoul.li> <877cio8fzf.fsf@jeremybryant.net> <87o7bkcrnq.fsf@jeremybryant.net> <87r0fugl5o.fsf@jeremybryant.net> <87h6g6jthh.fsf@jeremybryant.net> Reply-To: Jeremy Bryant 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="36312"; mail-complaints-to="usenet@ciao.gmane.io" To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 68929@debbugs.gnu.org, Justin Burkett Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 14 23:58:15 2024 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 1rw7ra-0009Et-QP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Apr 2024 23:58:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rw7rG-0004JP-9P; Sun, 14 Apr 2024 17:57:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rw7rE-0004IF-KF for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 17:57:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rw7rE-0006Lp-CM for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 17:57:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rw7rP-0008UR-4T for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 17:58:03 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <871q9rvqbi.fsf@jeremybryant.net> Resent-From: Jeremy Bryant Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2024 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68929 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68929-submit@debbugs.gnu.org id=B68929.171313183232146 (code B ref 68929); Sun, 14 Apr 2024 21:58:02 +0000 Original-Received: (at 68929) by debbugs.gnu.org; 14 Apr 2024 21:57:12 +0000 Original-Received: from localhost ([127.0.0.1]:36358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rw7qZ-0008MO-Hy for submit@debbugs.gnu.org; Sun, 14 Apr 2024 17:57:11 -0400 Original-Received: from out-181.mta1.migadu.com ([95.215.58.181]:48479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rw7qW-0008LW-Nw for 68929@debbugs.gnu.org; Sun, 14 Apr 2024 17:57:09 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1713131811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: references:references; bh=ZzKHCUAuyBa3E1GnpDg5hmcLGFvpUBcN5E/1ebm3gUU=; b=tVMYnl5GZTQFyCcTbix0fIX76IGoLSP4LLpU1iAkwId1Qk2u9n1//VPajs4Tja1+bv0sYK BTLHsvbOCTNG/Rs/WAuEj8EaeuD8wFTN/pupN/ALKevv/4+wK/Y6dZUDzQJZdTEgbeN6lT GgXMQ7py1gCd4I7ocZsVURXNs79rM2X8tCpPgX188TPEZbBSjzfFPaZZbKFhnHqhN5I19R Obi1gxOeGLUKgxQznZ9HlP+8rQF8MZPO7nvNo89BEA9NtTi455lZCHEG0YOEgw4kLiZwuG f6zirhjK2u3tAgDybfSakc2RwU2u/UPQxKiB3p3vUYrn1pg/GoIzrTJkxnr7Vw== X-Migadu-Flow: FLOW_OUT 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283322 Archived-At: --=-=-= Content-Type: text/plain -------------------- Start of forwarded message -------------------- From: Jeremy Bryant To: Philip Kaludercic Cc: Eli Zaretskii , 68929@debbugs.gnu.org, monnier@iro.umontreal.ca, justin@burkett.cc Subject: Re: bug#68929: which-key tests from GNU ELPA into core Date: Fri, 12 Apr 2024 21:18:59 +0100 --=-=-= Content-Type: multipart/mixed; boundary="==-=-=" --==-=-= Content-Type: text/plain Content-Disposition: inline Philip, Attached is the test file for which-key, are any changes necessary prior to the move to core? Thanks in advance Jeremy --==-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=which-key-tests.el Content-Transfer-Encoding: quoted-printable ;;; which-key-tests.el --- Tests for which-key.el -*- lexical-binding: t; -= *- ;; Copyright (C) 2017-2021 Free Software Foundation, Inc. ;; Author: Justin Burkett ;; Maintainer: Justin Burkett ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Tests for which-key.el ;;; Code: (require 'which-key) (require 'ert) (ert-deftest which-key-test--keymap-based-bindings () (let ((map (make-sparse-keymap)) (prefix-map (make-sparse-keymap))) (define-key prefix-map "x" #'ignore) (define-key map "\C-a" 'complete) (define-key map "\C-b" prefix-map) (which-key-add-keymap-based-replacements map "C-a" '("mycomplete" . complete) "C-b" "mymap" "C-c" "mymap2") (define-key map "\C-ca" 'foo) (should (equal (which-key--get-keymap-bindings map) '(("C-a" . "mycomplete") ("C-b" . "group:mymap") ("C-c" . "group:mymap2")))))) (ert-deftest which-key-test--named-prefix-keymap () (define-prefix-command 'which-key-test--named-map) (let ((map (make-sparse-keymap))) (define-key map "\C-a" 'which-key-test--named-map) (should (equal (which-key--get-keymap-bindings map) '(("C-a" . "which-key-test--named-map")))))) (ert-deftest which-key-test--prefix-declaration () "Test `which-key-declare-prefixes' and `which-key-declare-prefixes-for-mode'. See Bug #109." (let* ((major-mode 'test-mode) which-key-replacement-alist) (which-key-add-key-based-replacements "SPC C-c" '("complete" . "complete title") "SPC C-k" "cancel") (which-key-add-major-mode-key-based-replacements 'test-mode "C-c C-c" '("complete" . "complete title") "C-c C-k" "cancel") (should (equal (which-key--maybe-replace '("SPC C-k" . "")) '("SPC C-k" . "cancel"))) (should (equal (which-key--maybe-replace '("C-c C-c" . "")) '("C-c C-c" . "complete"))))) (ert-deftest which-key-test--maybe-replace () "Test `which-key--maybe-replace'. See #154" (let ((which-key-replacement-alist '((("C-c [a-d]" . nil) . ("C-c a" . "c-c a")) (("C-c .+" . nil) . ("C-c *" . "c-c *")))) (test-mode-1 't) (test-mode-2 'nil) which-key-allow-multiple-replacements) (which-key-add-key-based-replacements "C-c ." "test ." "SPC ." "SPC ." "C-c \\" "regexp quoting" "C-c [" "bad regexp" "SPC t1" (lambda (kb) (cons (car kb) (if test-mode-1 "[x] test mode" "[ ] test mode"))) "SPC t2" (lambda (kb) (cons (car kb) (if test-mode-2 "[x] test mode" "[ ] test mode")))) (should (equal (which-key--maybe-replace '("C-c g" . "test")) '("C-c *" . "c-c *"))) (should (equal (which-key--maybe-replace '("C-c b" . "test")) '("C-c a" . "c-c a"))) (should (equal (which-key--maybe-replace '("C-c ." . "not test .")) '("C-c ." . "test ."))) (should (not (equal (which-key--maybe-replace '("C-c +" . "not test .")) '("C-c ." . "test .")))) (should (equal (which-key--maybe-replace '("C-c [" . "orig bad regexp")) '("C-c [" . "bad regexp"))) (should (equal (which-key--maybe-replace '("C-c \\" . "pre quoting")) '("C-c \\" . "regexp quoting"))) ;; see #155 (should (equal (which-key--maybe-replace '("SPC . ." . "don't replace")) '("SPC . ." . "don't replace"))) (should (equal (which-key--maybe-replace '("SPC t 1" . "test mode")) '("SPC t 1" . "[x] test mode"))) (should (equal (which-key--maybe-replace '("SPC t 2" . "test mode")) '("SPC t 2" . "[ ] test mode"))))) (ert-deftest which-key-test--maybe-replace-multiple () "Test `which-key-allow-multiple-replacements'. See #156." (let ((which-key-replacement-alist '(((nil . "helm") . (nil . "HLM")) ((nil . "projectile") . (nil . "PRJTL")))) (which-key-allow-multiple-replacements t)) (should (equal (which-key--maybe-replace '("C-c C-c" . "helm-x")) '("C-c C-c" . "HLM-x"))) (should (equal (which-key--maybe-replace '("C-c C-c" . "projectile-x")) '("C-c C-c" . "PRJTL-x"))) (should (equal (which-key--maybe-replace '("C-c C-c" . "helm-projectile-x")) '("C-c C-c" . "HLM-PRJTL-x"))))) (ert-deftest which-key-test--key-extraction () "Test `which-key--extract-key'. See #161." (should (equal (which-key--extract-key "SPC a") "a")) (should (equal (which-key--extract-key "C-x a") "a")) (should (equal (which-key--extract-key " b a") "a")) (should (equal (which-key--extract-key " a .. c") "a .. c")) (should (equal (which-key--extract-key "M-a a .. c") "a .. c"))) (ert-deftest which-key-test--get-keymap-bindings () (skip-unless (require 'evil nil t)) (defvar evil-local-mode) (defvar evil-state) (declare-function evil-define-key* "ext:evil") (let ((map (make-sparse-keymap)) (evil-local-mode t) (evil-state 'normal) which-key-replacement-alist) (define-key map [which-key-a] '(which-key "blah")) (define-key map "b" #'ignore) (define-key map "c" "c") (define-key map "dd" "dd") (define-key map "eee" "eee") (define-key map "f" [123 45 6]) (define-key map (kbd "M-g g") "M-gg") (evil-define-key* 'normal map (kbd "C-h") "C-h-normal") (evil-define-key* 'insert map (kbd "C-h") "C-h-insert") (should (equal (sort (which-key--get-keymap-bindings map) (lambda (a b) (string-lessp (car a) (car b)))) '(("M-g" . "prefix") ("c" . "c") ("d" . "prefix") ("e" . "prefix") ("f" . "{ - C-f")))) (should (equal (sort (which-key--get-keymap-bindings map nil nil nil nil t) (lambda (a b) (string-lessp (car a) (car b)))) '(("C-h" . "C-h-normal") ("M-g" . "prefix") ("c" . "c") ("d" . "prefix") ("e" . "prefix") ("f" . "{ - C-f")))) (should (equal (sort (which-key--get-keymap-bindings map nil nil nil t) (lambda (a b) (string-lessp (car a) (car b)))) '(("M-g g" . "M-gg") ("c" . "c") ("d d" . "dd") ("e e e" . "eee") ("f" . "{ - C-f")))))) (ert-deftest which-key-test--nil-replacement () (let ((which-key-replacement-alist '(((nil . "winum-select-window-[1-9]") . t)))) (should (equal (which-key--maybe-replace '("C-c C-c" . "winum-select-window-1= ")) '())))) (ert-deftest which-key-test--key-sorting () (let ((keys '(("a" . "z") ("A" . "Z") ("b" . "y") ("B" . "Y") ("p" . "prefix") ("SPC" . "x") ("C-a" . "w")))) (let ((which-key-sort-uppercase-first t)) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-key-order)) '("SPC" "A" "B" "a" "b" "p" "C-a")))) (let (which-key-sort-uppercase-first) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-key-order)) '("SPC" "a" "b" "p" "A" "B" "C-a")))) (let ((which-key-sort-uppercase-first t)) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-key-order-alph= a)) '("SPC" "A" "a" "B" "b" "p" "C-a")))) (let (which-key-sort-uppercase-first) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-key-order-alph= a)) '("SPC" "a" "A" "b" "B" "p" "C-a")))) (let ((which-key-sort-uppercase-first t)) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-prefix-then-key-order)) '("SPC" "A" "B" "a" "b" "C-a" "p")))) (let (which-key-sort-uppercase-first) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-prefix-then-key-order)) '("SPC" "a" "b" "A" "B" "C-a" "p")))) (let ((which-key-sort-uppercase-first t)) (should (equal (mapcar 'car (sort (copy-sequence keys) #'which-key-prefix-then-key-order-reverse)) '("p" "SPC" "A" "B" "a" "b" "C-a")))) (let (which-key-sort-uppercase-first) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-prefix-then-key-order-reverse)) '("p" "SPC" "a" "b" "A" "B" "C-a")))) (let ((which-key-sort-uppercase-first t)) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-description-order)) '("p" "C-a" "SPC" "b" "B" "a" "A")))) (let (which-key-sort-uppercase-first) (should (equal (mapcar #'car (sort (copy-sequence keys) #'which-key-description-order)) '("p" "C-a" "SPC" "b" "B" "a" "A")))))) (provide 'which-key-tests) ;;; which-key-tests.el ends here --==-=-=-- --=-=-= Content-Type: text/plain -------------------- End of forwarded message -------------------- Mattias, I understand you have expertise on the testing infrastructure, do you have any comments on any work required to change this file or would it be good to go 'as is'? Thanks in advance Jeremy --=-=-=--