From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#30408: Checking for loss of information on integer conversion Date: Wed, 21 Mar 2018 12:13:49 -0700 Organization: UCLA Computer Science Department Message-ID: <9186c001-13d8-6d8d-9298-ce4615e1324f@cs.ucla.edu> References: <7432641a-cedc-942c-d75c-0320fce5ba39@cs.ucla.edu> <83y3jq9q4m.fsf@gnu.org> <74ac7b77-a756-95a9-b490-6952cf106f21@cs.ucla.edu> <83fu5y9hbx.fsf@gnu.org> <66f719bf-2527-a213-5b8e-18044963f30e@cs.ucla.edu> <83o9jxody5.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5C6A4D4459BA98196AD7685E" X-Trace: blaine.gmane.org 1521659587 17824 195.159.176.226 (21 Mar 2018 19:13:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Mar 2018 19:13:07 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Cc: 30408@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 21 20:13:03 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eyjAU-0004XE-S8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Mar 2018 20:13:03 +0100 Original-Received: from localhost ([::1]:56913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyjCY-0000cc-6Z for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Mar 2018 15:15:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyjBZ-000064-0H for bug-gnu-emacs@gnu.org; Wed, 21 Mar 2018 15:14:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyjBU-0000hB-1R for bug-gnu-emacs@gnu.org; Wed, 21 Mar 2018 15:14:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eyjBT-0000h2-SJ for bug-gnu-emacs@gnu.org; Wed, 21 Mar 2018 15:14:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eyjBR-0007Xa-Pg for bug-gnu-emacs@gnu.org; Wed, 21 Mar 2018 15:14:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Mar 2018 19:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30408 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30408-submit@debbugs.gnu.org id=B30408.152165963828970 (code B ref 30408); Wed, 21 Mar 2018 19:14:01 +0000 Original-Received: (at 30408) by debbugs.gnu.org; 21 Mar 2018 19:13:58 +0000 Original-Received: from localhost ([127.0.0.1]:46241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eyjBO-0007XC-4G for submit@debbugs.gnu.org; Wed, 21 Mar 2018 15:13:58 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eyjBM-0007Wz-Rs for 30408@debbugs.gnu.org; Wed, 21 Mar 2018 15:13:57 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BEF2B1616ED; Wed, 21 Mar 2018 12:13:50 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id UIL0ptLzjJoL; Wed, 21 Mar 2018 12:13:50 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EFA3B1616F4; Wed, 21 Mar 2018 12:13:49 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3MPaQZomcQTx; Wed, 21 Mar 2018 12:13:49 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D68361616ED; Wed, 21 Mar 2018 12:13:49 -0700 (PDT) In-Reply-To: <83o9jxody5.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144502 Archived-At: This is a multi-part message in MIME format. --------------5C6A4D4459BA98196AD7685E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 03/09/2018 12:22 AM, Eli Zaretskii wrote: > May I suggest to add a couple of tests for this feature? Sure, I installed the attached. --------------5C6A4D4459BA98196AD7685E Content-Type: text/x-patch; name="0001-Add-tests-for-Bug-30408.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Add-tests-for-Bug-30408.patch" >From 84dbd740c440b4c048f675486af7292cdf251c9f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 21 Mar 2018 12:10:11 -0700 Subject: [PATCH] Add tests for Bug#30408 * test/src/editfns-tests.el (format-%d-large-float) (format-%x-large-float, format-%o-invalid-float): New tests. --- test/src/editfns-tests.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 69ea6f5cc8..6e1f730166 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -142,6 +142,27 @@ transpose-test-get-byte-positions (should (string-equal (format "%#05X" #x10) "0X010")) (should (string-equal (format "%#04x" 0) "0000"))) +;;; Test Bug#30408. +(ert-deftest format-%d-large-float () + (should (string-equal (format "%d" 18446744073709551616.0) + "18446744073709551616")) + (should (string-equal (format "%d" -18446744073709551616.0) + "-18446744073709551616"))) + +;;; Another test for Bug#30408. +;;; Perhaps Emacs will be improved someday to return the correct +;;; answer for positive numbers instead of overflowing; in +;;; that case this test will need to be changed. In the meantime make +;;; sure Emacs is reporting the overflow correctly. +(ert-deftest format-%x-large-float () + (should-error (format "%x" 18446744073709551616.0) + :type 'overflow-error)) + +;;; Another test for Bug#30408. +(ert-deftest format-%o-invalid-float () + (should-error (format "%o" -1e-37) + :type 'overflow-error)) + ;;; Check format-time-string with various TZ settings. ;;; Use only POSIX-compatible TZ values, since the tests should work ;;; even if tzdb is not in use. -- 2.14.3 --------------5C6A4D4459BA98196AD7685E--