From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30408@debbugs.gnu.org
Subject: bug#30408: Checking for loss of information on integer conversion
Date: Wed, 21 Mar 2018 12:13:49 -0700 [thread overview]
Message-ID: <9186c001-13d8-6d8d-9298-ce4615e1324f@cs.ucla.edu> (raw)
In-Reply-To: <83o9jxody5.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
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.
[-- Attachment #2: 0001-Add-tests-for-Bug-30408.patch --]
[-- Type: text/x-patch, Size: 1766 bytes --]
From 84dbd740c440b4c048f675486af7292cdf251c9f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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
next prev parent reply other threads:[~2018-03-21 19:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-18 1:27 Checking for loss of information on integer conversion Paul Eggert
2018-02-18 22:31 ` Juliusz Chroboczek
2018-02-18 22:41 ` Stefan Monnier
2018-02-18 23:46 ` Juliusz Chroboczek
2018-02-19 1:47 ` Stefan Monnier
2018-02-19 2:22 ` Paul Eggert
2018-02-19 3:20 ` Drew Adams
2018-02-19 15:05 ` Richard Stallman
2018-02-22 16:31 ` Juliusz Chroboczek
2018-02-22 17:01 ` Eli Zaretskii
2018-02-22 19:31 ` Stefan Monnier
2018-02-23 9:49 ` Richard Stallman
2018-02-19 6:03 ` John Wiegley
[not found] ` <83y3jq9q4m.fsf@gnu.org>
2018-02-18 20:04 ` Paul Eggert
2018-02-18 20:24 ` Eli Zaretskii
2018-03-09 5:00 ` bug#30408: " Paul Eggert
2018-03-09 8:22 ` Eli Zaretskii
2018-03-21 19:13 ` Paul Eggert [this message]
2018-03-21 19:29 ` Eli Zaretskii
2018-02-18 20:24 ` Eli Zaretskii
2018-02-18 21:52 ` Drew Adams
2018-02-18 20:04 ` Paul Eggert
2018-03-27 23:19 ` Paul Eggert
2018-03-29 11:11 ` Eli Zaretskii
2018-03-29 18:09 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9186c001-13d8-6d8d-9298-ce4615e1324f@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=30408@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.