From 9a36f4bb061fd0a6bb3f8e848c50fbe5f75f68f3 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sun, 15 Jan 2023 06:12:52 +0100 Subject: compat-27: Add fixnump and bignump --- compat-27.el | 3 +++ compat-tests.el | 12 ++++++++++++ compat.texi | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/compat-27.el b/compat-27.el index 0210b73..ec19a59 100644 --- a/compat-27.el +++ b/compat-27.el @@ -164,6 +164,9 @@ where USER is a valid login name." ;;;; Defined in subr.el +(compat-defalias fixnump integerp) ;; +(compat-defalias bignump ignore) ;; + (compat-defmacro setq-local (&rest pairs) ;; "Handle multiple assignments." :explicit t diff --git a/compat-tests.el b/compat-tests.el index 7e0ee18..f4b9933 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -64,6 +64,18 @@ (setq list (funcall sym list "first" 1 #'string=)) (should (eq (compat-call plist-get list "first" #'string=) 1)))) +(ert-deftest fixnump () + (should (fixnump 0)) + (should (fixnump most-negative-fixnum)) + (should (fixnump most-positive-fixnum))) + +(ert-deftest bignump () + (should-not (bignump 0)) + (should-not (bignump most-negative-fixnum)) + (should-not (bignump most-positive-fixnum)) + (should-equal (bignump (1+ most-positive-fixnum)) (> emacs-major-version 26)) + (should-equal (bignump (1- most-negative-fixnum)) (> emacs-major-version 26))) + (ert-deftest buttonize () (let ((b (buttonize "button" 'c 'd 'h))) (should-equal b "button") diff --git a/compat.texi b/compat.texi index 2e3e9fb..1948cda 100644 --- a/compat.texi +++ b/compat.texi @@ -859,6 +859,20 @@ The function @code{window-swap-states}. The following functions and macros implemented in 27.1, and are provided by Compat: +@c copied from lispref/numbers.texi +@defun bignump object +This predicate tests whether its argument is a large integer, and +returns @code{t} if so, @code{nil} otherwise. Unlike small integers, +large integers can be @code{=} or @code{eql} even if they are not @code{eq}. +@end defun + +@c copied from lispref/numbers.texi +@defun fixnump object +This predicate tests whether its argument is a small integer, and +returns @code{t} if so, @code{nil} otherwise. Small integers can be +compared with @code{eq}. +@end defun + @c copied from lispref/lists.texi @defun proper-list-p object This function returns the length of @var{object} if it is a proper list, -- cgit v1.0