mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Define `equal?' for pointer objects.
* libguile/eq.c (scm_equal_p): Handle pointer objects. * test-suite/tests/foreign.test ("make-pointer")["equal?", "equal? modulo finalizer", "not equal?"]: New tests.
This commit is contained in:
parent
fb5c4dc523
commit
cb2d8076ef
2 changed files with 15 additions and 1 deletions
|
@ -303,6 +303,9 @@ scm_equal_p (SCM x, SCM y)
|
|||
else
|
||||
goto generic_equal;
|
||||
}
|
||||
if (SCM_POINTER_P (x) && SCM_POINTER_P (y))
|
||||
return scm_from_bool (SCM_POINTER_VALUE (x) == SCM_POINTER_VALUE (y));
|
||||
|
||||
/* This ensures that types and scm_length are the same. */
|
||||
if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y))
|
||||
{
|
||||
|
|
|
@ -47,7 +47,18 @@
|
|||
(with-test-prefix "make-pointer"
|
||||
|
||||
(pass-if "address preserved"
|
||||
(= 123 (pointer-address (make-pointer 123)))))
|
||||
(= 123 (pointer-address (make-pointer 123))))
|
||||
|
||||
(pass-if "equal?"
|
||||
(equal? (make-pointer 123) (make-pointer 123)))
|
||||
|
||||
(pass-if "equal? modulo finalizer"
|
||||
(let ((finalizer (dynamic-func "scm_is_pair" (dynamic-link))))
|
||||
(equal? (make-pointer 123)
|
||||
(make-pointer 123 finalizer))))
|
||||
|
||||
(pass-if "not equal?"
|
||||
(not (equal? (make-pointer 123) (make-pointer 456)))))
|
||||
|
||||
|
||||
(with-test-prefix "pointer<->bytevector"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue