From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70093: Remove unnecessary `image-tests--map-equal' Date: Sat, 30 Mar 2024 22:32:26 -0700 Message-ID: <8734s7c6cv.fsf@breatheoutbreathe.in> References: <877chjcxfg.fsf@breatheoutbreathe.in> <86y19zaswg.fsf@gnu.org> Reply-To: Joseph Turner 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="40893"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70093@debbugs.gnu.org, da_vid@orange.fr To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 31 07:35:26 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 1rqnqn-000ARH-UG for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Mar 2024 07:35:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqnqP-000569-Dc; Sun, 31 Mar 2024 01:35:01 -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 1rqnqO-00055h-8r for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 01:35:00 -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 1rqnqO-0001aE-0H for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 01:35:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqnqP-0007uK-SF for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 01:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Mar 2024 05:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70093 X-GNU-PR-Package: emacs Original-Received: via spool by 70093-submit@debbugs.gnu.org id=B70093.171186326630292 (code B ref 70093); Sun, 31 Mar 2024 05:35:01 +0000 Original-Received: (at 70093) by debbugs.gnu.org; 31 Mar 2024 05:34:26 +0000 Original-Received: from localhost ([127.0.0.1]:46456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqnpp-0007sV-LU for submit@debbugs.gnu.org; Sun, 31 Mar 2024 01:34:26 -0400 Original-Received: from out-178.mta0.migadu.com ([91.218.175.178]:50613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqnpl-0007re-QH for 70093@debbugs.gnu.org; Sun, 31 Mar 2024 01:34:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1711863253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hxYqH5J/FVnsw3upy44OisHka3X4yORqr9eG96WT794=; b=WvLbZD6LJQm75CcqsqxD1X2sw9UgMbyLHFsdV4ir5/WB1fG3FSRc5bt+uhVIIJUKtmqXoO uHGOVY1gxX9KNtmvgR5izIk6qary/2X+RCJPhyT+5ye0snEfRJrRu/ZCQY+VMKIMwH9JZ9 H4T/oOK6HJ1VL3INcfJSfxmz81VkV4c= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: <86y19zaswg.fsf@gnu.org> 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:282410 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Cc: Eli Zaretskii , David Ponce >> From: Joseph Turner >> Date: Sat, 30 Mar 2024 12:44:14 -0700 >> >> With the resolution of bug#69992, it may be possible to remove the >> `image-tests--map-equal' equality predicate from lisp/image-tests.el. > > Why is it a good idea to remove tests? If the test tests some of our > code which should work as the test assumes, we should not remove it. Not removing tests, but rather making the tests more strict (if possible). >> Eli and David, would you please apply the attached patch and then run >> the tests to see if we still need to allow for tolerances in >> `image--compute-map-and-original-map'? > > ENOPATCH Sorry about that. Please check if the tests still pass on your machine when we use `equal' to compare image maps. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Compare-image-maps-with-equal-in-tests.patch >From e85fd88a2943fa95d2d7eea3a542308adaa81582 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 30 Mar 2024 12:38:52 -0700 Subject: [PATCH] Compare image maps with `equal' in tests With the fixes to image map transformation introduced in cc212ea314d, the tests should now exactly predict calculated image maps. * test/lisp/image-tests.el (image-tests--map-equal): Remove function. (image--compute-map-and-original-map): Use equal to compare image maps. --- test/lisp/image-tests.el | 46 +++++----------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el index 020781eff50..41b87b8d337 100644 --- a/test/lisp/image-tests.el +++ b/test/lisp/image-tests.el @@ -178,37 +178,6 @@ image-create-image-with-map (got-original-map (image-property image :original-map))) (should (equal got-original-map original-map-other))))) -(defun image-tests--map-equal (a b &optional tolerance) - "Return t if maps A and B have the same coordinates within TOLERANCE. -Since image sizes calculations vary on different machines, this function -allows for each image map coordinate in A to be within TOLERANCE to the -corresponding coordinate in B. When nil, TOLERANCE defaults to 5." - (unless tolerance (setq tolerance 5)) - (catch 'different - (cl-labels ((check-tolerance - (coord-a coord-b) - (unless (>= tolerance (abs (- coord-a coord-b))) - (throw 'different nil)))) - (dotimes (i (length a)) - (pcase-let ((`((,type-a . ,coords-a) ,_id ,_plist) (nth i a)) - (`((,type-b . ,coords-b) ,_id ,_plist) (nth i b))) - (unless (eq type-a type-b) - (throw 'different nil)) - (pcase-exhaustive type-a - ('rect - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cadr coords-a) (cadr coords-b)) - (check-tolerance (cddr coords-a) (cddr coords-b))) - ('circle - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b))) - ('poly - (dotimes (i (length coords-a)) - (check-tolerance (aref coords-a i) (aref coords-b i)))))))) - t)) - (ert-deftest image--compute-map-and-original-map () "Test `image--compute-map' and `image--compute-original-map'." (skip-unless (display-images-p)) @@ -237,25 +206,20 @@ image--compute-map-and-original-map :scale 2 :rotation 90 :flip t))) ;; Test that `image--compute-original-map' correctly generates ;; original-map when creating an already transformed image. - (should (image-tests--map-equal (image-property image :original-map) - original-map)) + (should (equal (image-property image :original-map) original-map)) (setf (image-property image :flip) nil) (setf (image-property image :rotation) 0) (setf (image-property image :scale) 2) - (should (image-tests--map-equal (image--compute-map image) - scaled-map)) + (should (equal (image--compute-map image) scaled-map)) (setf (image-property image :scale) 1) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - rotated-map)) + (should (equal (image--compute-map image) rotated-map)) (setf (image-property image :rotation) 0) (setf (image-property image :flip) t) - (should (image-tests--map-equal (image--compute-map image) - flipped-map)) + (should (equal (image--compute-map image) flipped-map)) (setf (image-property image :scale) 2) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - scaled-rotated-flipped-map)) + (should (equal (image--compute-map image) scaled-rotated-flipped-map)) ;; Uncomment to test manually by interactively transforming the ;; image and checking the map boundaries by hovering them. -- 2.41.0 --=-=-=--