aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Eggert2019-07-23 01:42:32 -0700
committerPaul Eggert2019-07-23 01:46:41 -0700
commitdfb0ba79b5f41ca6fed25a03d2a5cd6996ec4753 (patch)
tree87426b1fde8da618b4e7657b09bc256f5c011dcc /test
parent56a3e4a5d366a8453608d9a604ebd5ddb4e52245 (diff)
downloademacs-dfb0ba79b5f41ca6fed25a03d2a5cd6996ec4753.tar.gz
emacs-dfb0ba79b5f41ca6fed25a03d2a5cd6996ec4753.zip
Support "%x" etc. formats on more floats
* doc/lispref/strings.texi (Formatting Strings): Document this. * src/editfns.c (styled_format): Support %o, %x, and %X on finite floats less than zero or greater than UINTMAX_MAX. * test/src/editfns-tests.el (format-%x-large-float) (read-large-integer, format-%o-negative-float): Adjust tests to match extended behavior. Rename the latter test from format-%o-invalid-float, since the float is no longer invalid. * test/src/editfns-tests.el (format-%x-large-float) (read-large-integer): Test this.
Diffstat (limited to 'test')
-rw-r--r--test/src/editfns-tests.el23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 69cca5d2bdd..a1060808f66 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -165,13 +165,9 @@
165 (should (string-equal (format "%d" -18446744073709551616.0) 165 (should (string-equal (format "%d" -18446744073709551616.0)
166 "-18446744073709551616"))) 166 "-18446744073709551616")))
167 167
168;; Perhaps Emacs will be improved someday to return the correct
169;; answer for positive numbers instead of overflowing; in
170;; that case these tests will need to be changed. In the meantime make
171;; sure Emacs is reporting the overflow correctly.
172(ert-deftest format-%x-large-float () 168(ert-deftest format-%x-large-float ()
173 (should-error (format "%x" 18446744073709551616.0) 169 (should (string-equal (format "%x" 18446744073709551616.0)
174 :type 'overflow-error)) 170 "10000000000000000")))
175(ert-deftest read-large-integer () 171(ert-deftest read-large-integer ()
176 (should (eq (type-of (read (format "%d0" most-negative-fixnum))) 'integer)) 172 (should (eq (type-of (read (format "%d0" most-negative-fixnum))) 'integer))
177 (should (eq (type-of (read (format "%+d" (* -8.0 most-negative-fixnum)))) 173 (should (eq (type-of (read (format "%+d" (* -8.0 most-negative-fixnum))))
@@ -188,11 +184,16 @@
188 (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum) 184 (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum)
189 -1 0 1 185 -1 0 1
190 (1- most-positive-fixnum) most-positive-fixnum)) 186 (1- most-positive-fixnum) most-positive-fixnum))
191 (should (eq val (read (format fmt val))))))) 187 (should (eq val (read (format fmt val)))))
192 188 (dolist (val (list (1+ most-positive-fixnum)
193(ert-deftest format-%o-invalid-float () 189 (* 2 (1+ most-positive-fixnum))
194 (should-error (format "%o" -1e-37) 190 (* 4 (1+ most-positive-fixnum))
195 :type 'overflow-error)) 191 (* 8 (1+ most-positive-fixnum))
192 18446744073709551616.0))
193 (should (= val (read (format fmt val)))))))
194
195(ert-deftest format-%o-negative-float ()
196 (should (string-equal (format "%o" -1e-37) "0")))
196 197
197;; Bug#31938 198;; Bug#31938
198(ert-deftest format-%d-float () 199(ert-deftest format-%d-float ()