summaryrefslogtreecommitdiff
path: root/test/src/floatfns-tests.el
AgeCommit message (Collapse)Author
2026-05-07; Revert Eric's commits from February.Sean Whitton
These will be resubmitted as patches for review. Revert "Repair another test bollixed by aggressive optimization." This reverts commit 47735e0243ba15a485e1a6f25be53f6e42dafa24. Revert "Repair ab ecal test by making a variable kexical," This reverts commit ca42055b0ca3bba1b635e314f084239f5a205534. Revert "Complete the test set for floatfns,c." This reverts commit 1b0c8d6b95f0704936e4449270a815abb8865c3d. Revert "Tesrts for the portable primitives in fileio.c." This reverts commit a339c6827c0bb1e80de1cfb9c51b4c4b764046bc. Revert "Tests for primitives in coding.c and charset.c." This reverts commit 5749b2e4f4d11dd646892e70f520700e4f0f16f5. Revert "Tests for primitives from the character.c module." This reverts commit b09f8df206aae1e4b70d8961e6693d574aea6a30. Revert "Tests for the lreaf.c amd print.c primitives." This reverts commit d7a3d442b4cdfd88447eec49339dfa5d69342de9. Revert "Tests for remaining functions iun eval.c." This reverts commit cd038e5617ff940ead880fbc9c1df95e61453246. Revert "Completing test coverage for dataa.c orimitives." This reverts commit a6e19d6179ad608688c6edcc2b1f7368c05dff69. Revert "More correctness tesrs for orinitives from fns.c." This reverts commit 40ff4512ad12fd29a5bea887fe77c3bddfa4caec. Revert "More tests for edit functions, buffers, and markers." This reverts commit 67e8f875627e38450a6c713e810dcea2106c6d9c. Revert "Added more buffer/marker/editing test coverage." This reverts commit 3dda4b85e8a66a0c5592197dcc2895d65c04bc51. Revert "Category/charset/coding + char-table tests." This reverts commit 7a93a7b3345f7ae4e8f487b562b19a4b5fed8496. Revert "More test coverage improvements." This reverts commit fc7339c46dc87d5d7051f976206bb5c4d9efdfb8. Revert "More test coverage improvements." This reverts commit 95329bf445841a763bafa4ea5e853fc1c6f6bf0a. Revert "More test coverage improvements for ERT." This reverts commit e42c579a544d3d254e55db2f6b70e55205987d36. Revert "Crrections to tedt coverrage extensuion after bootstrap build." This reverts commit 90af3295c7fa705381bf680ec8559503ea875683. Revert "Improve test coverage of builtin predicates." This reverts commit 6eb170b007a4ad63fe5666033df191f52d480739. Revert "Tests for 2 marker primitives previously not covered." This reverts commit 6d7f0acf9cc15b388f90363d012aaba3d95be6c8. Revert "Tests for 7 editor primitives previously not covered." This reverts commit bb403e70aec25677393d4f37d544487a9aebab9e.
2026-02-25Complete the test set for floatfns,c.Eric S. Raymond
2026-02-25More test coverage improvements.Eric S. Raymond
2026-01-01; Add 2026 to copyright years.Sean Whitton
2025-02-17Prefer oddp/evenp to free-coding them in testsStefan Kangas
* test/lisp/emacs-lisp/bindat-tests.el (bindat-test--sint): * test/lisp/emacs-lisp/seq-tests.el (test-seq-drop-while) (test-seq-take-while, test-seq-filter, test-seq-remove) (test-seq-count, test-seq-some, test-seq-find, test-seq-every-p) (test-seq-group-by): * test/lisp/eshell/em-pred-tests.el (eshell-with-file-attributes-from-name): * test/lisp/filenotify-tests.el (file-notify-test07-many-events) (file-notify-test09-watched-file-in-watched-dir): * test/src/floatfns-tests.el (bignum-expt, bignum-round): * test/src/undo-tests.el (undo-test4): Prefer oddp/evenp to free-coding them.
2025-01-01Update copyright year to 2025Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2024-01-02; Add 2024 to copyright yearsPo Lu
2023-01-01; Add 2023 to copyright years.Eli Zaretskii
2022-01-01Merge from origin/emacs-28Eli Zaretskii
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year. 86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year ebe8772f65 ; Minor fixes related to copyright years 23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye... 8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t. 19dcb237b5 ; Add 2022 to copyright years. # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex # lib/cdefs.h # lisp/erc/erc-dcc.el # lisp/erc/erc-imenu.el # lisp/erc/erc-replace.el # lisp/image-dired.el # lisp/progmodes/xref.el # m4/alloca.m4 # m4/byteswap.m4 # m4/errno_h.m4 # m4/getopt.m4 # m4/gnulib-common.m4 # m4/inttypes.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/sys_socket_h.m4
2022-01-01; Add 2022 to copyright years.Eli Zaretskii
2021-10-20Add some tests for floatfns.cStefan Kangas
* test/src/floatfns-tests.el (floatfns-tests-cos) (floatfns-tests-sin, floatfns-tests-tan, floatfns-tests-isnan) (floatfns-tests-exp, floatfns-tests-expt, floatfns-tests-log) (floatfns-tests-sqrt, floatfns-tests-abs, floatfns-tests-logb) (floatfns-tests-ceiling, floatfns-tests-floor) (floatfns-tests-round, floatfns-tests-truncate) (floatfns-tests-fceiling, floatfns-tests-ffloor) (floatfns-tests-fround, floatfns-tests-ftruncate) (divide-extreme-sign): New tests.
2021-09-26; Minor stylistic checkdoc fixes in test/**/*.elStefan Kangas
2021-01-01Update copyright year to 2021Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2020-04-24Use lexical-binding in most src testsStefan Kangas
* test/src/charset-tests.el: * test/src/chartab-tests.el: * test/src/cmds-tests.el: * test/src/coding-tests.el (top-level) (generate-ascii-file, generate-mostly-nonascii-file): * test/src/doc-tests.el: * test/src/floatfns-tests.el: * test/src/font-tests.el: * test/src/keymap-tests.el: * test/src/process-tests.el (top-level) (process-test-sentinel-wait-function-working-p) (process-test-stderr-buffer, process-test-stderr-filter): * test/src/textprop-tests.el: * test/src/thread-tests.el: * test/src/timefns-tests.el: * test/src/undo-tests.el: * test/src/xml-tests.el: Use lexical-binding.
2020-01-01Update copyright year to 2020Paul Eggert
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2019-11-14Handle weird cases like (ceil 0 0.0)Paul Eggert
* src/floatfns.c (double_integer_scale): Distinguish Inf from NaN. (rounding_driver): Handle (ceil 0 0.0) and (ceil 0 1.0e+INF). * test/src/floatfns-tests.el (special-round): Add tests for weird cases like this. Avoid crash with (floor 0 0.0) * src/floatfns.c (rounding_driver): Signal an arithmetic error if divisor is 0.0 or -0.0, instead of crashing.
2019-11-13Fix double-rounding bug in ceiling etc.Paul Eggert
This is doable now that we have bignums. * src/floatfns.c (integer_value): Remove; no longer used. (rescale_for_division): New function. (rounding_driver): Use it to divide properly (by using bignums) even when arguments are float, fixing a double-rounding FIXME. * src/lisp.h (LOG2_FLT_RADIX): Move here ... * src/timefns.c (frac_to_double): ... from here. * test/src/floatfns-tests.el (big-round): Add a test to catch the double-rounding bug.
2019-11-04Don’t signal overflow for (expt 1 bignum)Paul Eggert
Similarly for (expt 0 bignum) and (expt -1 bignum). The result is always a -1, 0 or 1, so do not signal overflow. * src/data.c (expt_integer): Do not signal an overflow if -1 <= X <= 1. Be clearer about when overflow is signaled. * test/src/floatfns-tests.el (bignum-expt): Test this.
2018-12-31Merge from origin/emacs-26Paul Eggert
2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
2019-01-01Update copyright year to 2019Paul Eggert
Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
2018-09-22Round bignums consistently with other integersPaul Eggert
* src/bignum.c (mpz_bufsize): New function. (bignum_bufsize): Use it. (mpz_get_d_rounded): New function. (bignum_to_double): Use it. * src/bignum.c (bignum_to_double): * src/data.c (bignum_arith_driver): When converting bignums to double, round instead of truncating, to be consistent with what happens with fixnums. * test/src/floatfns-tests.el (bignum-to-float): Test rounding.
2018-09-13Fix (floor 54043195528445955 3.0) bugPaul Eggert
* src/floatfns.c (rounding_driver): Fix rounding error that can occur when both args have values exactly representable as integers but at least one arg is a float. * test/src/floatfns-tests.el (big-round): New test.
2018-09-11Fix (round 1e+INF) core dumpPaul Eggert
* src/bignum.c (double_to_integer): Signal an error if D cannot be converted, instead of dumping core. * test/src/floatfns-tests.el (special-round): New test.
2018-09-04Fix (round FLOAT BIGNUM) bugPaul Eggert
* src/floatfns.c (rounding_driver): Fix bug when one argument is a float and the other is a bignum. * test/src/floatfns-tests.el (bignum-round): Test for the bug.
2018-08-22Fix bugs when rounding to bignumsPaul Eggert
Also, since Emacs historically reported a range error when rounding operations overflowed, do that consistently for all bignum overflows. * doc/lispref/errors.texi (Standard Errors): * doc/lispref/numbers.texi (Integer Basics): Document range errors. * src/alloc.c (range_error): Rename from integer_overflow. All uses changed. * src/floatfns.c (rounding_driver): When the result of a floating point rounding operation does not fit into a fixnum, put it into a bignum instead of always signaling an range error. * test/src/floatfns-tests.el (divide-extreme-sign): These tests now return the mathematically-correct answer instead of signaling an error. (bignum-round): Check that integers round to themselves.
2018-08-21Add bignum support to floor, ceiling, etc.Paul Eggert
Problem reported by Andy Moreton (Bug#32463#35 (d)). * src/floatfns.c (rounding_driver): Change the signature of the integer rounder to use mpz_t rather than EMACS_INT. All uses changed. Support bignums. (ceiling2, floor2, truncate2, round2): Remove. All uses changed to rounddiv_q or to a GMP library function. (rounddiv_q): New function. * test/src/floatfns-tests.el (bignum-round): New test.
2018-08-19Add bignum support to exptPaul Eggert
Problem and initial solution reported by Andy Moreton in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00503.html * doc/lispref/numbers.texi (Math Functions): expt integer overflow no longer causes truncation; it now signals an error since bignum overflow is a big deal. * src/floatfns.c (Fexpt): Support bignum arguments. * test/src/floatfns-tests.el (bignum-expt): New test.
2018-08-18Fix bug with ‘mod’ and float+bignumPaul Eggert
Problem reported by Andy Moreton in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00442.html * src/floatfns.c (fmod_float): Work even if an arg is a bignum. * test/src/floatfns-tests.el (bignum-mod): New test.
2018-07-12Make logb handle bignumsTom Tromey
* src/floatfns.c (Flogb): Handle bignums. * test/src/floatfns-tests.el (bignum-logb): New test.
2018-07-12Make abs handle bignumsTom Tromey
* src/floatfns.c (Fabs): Handle bignums. * test/src/floatfns-tests.el (bignum-abs): New test.
2018-07-12Allow conversion of bignums to floatsTom Tromey
* src/floatfns.c (extract_float, Ffloat): Handle bignums. * src/lisp.h (XFLOATINT): Handle bignums. * test/src/floatfns-tests.el (bignum-to-float): New test.
2018-01-01Update copyright year to 2018Paul Eggert
Run admin/update-copyright.
2017-09-13Prefer HTTPS to FTP and HTTP in documentationPaul Eggert
Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
2017-03-05ffloor etc. now accept only floatsPaul Eggert
* etc/NEWS: Say why. * src/floatfns.c (Ffceiling, Fffloor, Ffround, Fftruncate): Require arg to be float. * test/src/floatfns-tests.el (fround-fixnum): Check this.
2017-03-05; Spelling fixesPaul Eggert
2017-03-03logb now works correctly on large integersPaul Eggert
* admin/merge-gnulib (GNULIB_MODULES): Add count-leading-zeros. * etc/NEWS: Document the change. * lib/count-leading-zeros.c, lib/count-leading-zeros.h: * m4/count-leading-zeros.m4: New files, copied from Gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * src/floatfns.c: Include count-leading-zeros.h. (Flogb): Do not convert fixnum to float before taking the log, as the rounding error can cause the answer to be off by 1. * src/lisp.h (EMACS_UINT_WIDTH): New constant. * test/src/floatfns-tests.el (logb-extreme-fixnum): New test.
2017-03-01Fix rounding error in ‘ceiling’ etc.Paul Eggert
Without this fix, (ceiling most-negative-fixnum -1.0) returns most-negative-fixnum instead of correctly signaling range-error, and similarly for floor, round, and truncate. * configure.ac (trunc): Add a check, since Gnulib’s doc says ‘trunc’ is missing from MSVC 9. The Gnulib doc says ‘trunc’ is also missing from some other older operating systems like Solaris 9 which I know we don’t care about any more, so MSVC is the only reason to worry about ‘trunc’ here. * src/editfns.c (styled_format): Formatting a float with %c is now an error. The old code did not work in general, because FIXNUM_OVERFLOW_P had rounding errors. Besides, the "if (FLOATP (...))" was in there only as a result of my misunderstanding old code that I introduced 2011. Although %d etc. is sometimes used on floats that represent huge UIDs or PIDs etc. that do not fit in fixnums, this cannot happen with characters. * src/floatfns.c (rounding_driver): Rework to do the right thing when the intermediate result equals 2.305843009213694e+18, i.e., is exactly 1 greater than MOST_POSITIVE_FIXNUM on a 64-bit host. Simplify so that only one section of code checks for overflow, rather than two. (double_identity): Remove. All uses changed to ... (emacs_trunc): ... this new function. Add replacement for platforms that lack ‘trunc’. * src/lisp.h (FIXNUM_OVERFLOW_P, make_fixnum_or_float): Make it clear that the arg cannot be floating point. * test/src/editfns-tests.el (format-c-float): New test. * test/src/floatfns-tests.el: New file, to test for this bug.