mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
Implemented eq and equal built-in predicates.
* module/language/elisp/runtime/function-slot.scm: Implement eq and equal. * test-suite/tests/elisp-compiler.test: Test them.
This commit is contained in:
parent
74c009dadc
commit
e905e490fa
2 changed files with 26 additions and 0 deletions
|
@ -26,6 +26,15 @@
|
|||
; functions are implemented as predefined function bindings here.
|
||||
|
||||
|
||||
; Equivalence and equalness predicates.
|
||||
|
||||
(built-in-func eq (lambda (a b)
|
||||
(elisp-bool (eq? a b))))
|
||||
|
||||
(built-in-func equal (lambda (a b)
|
||||
(elisp-bool (equal? a b))))
|
||||
|
||||
|
||||
; Number predicates.
|
||||
|
||||
(built-in-func floatp (lambda (num)
|
||||
|
|
|
@ -227,6 +227,23 @@
|
|||
; Test the built-ins.
|
||||
; ===================
|
||||
|
||||
(with-test-prefix/compile "Equivalence Predicates"
|
||||
|
||||
(pass-if "equal"
|
||||
(and (equal 2 2) (not (equal 1 2))
|
||||
(equal "abc" "abc") (not (equal "abc" "ABC"))
|
||||
(equal 'abc 'abc) (not (equal 'abc 'def))
|
||||
(equal '(1 2 (3 4) 5) '(1 2 (3 4) 5))
|
||||
(not (equal '(1 2 3 4 5) '(1 2 (3 4) 5)))))
|
||||
|
||||
(pass-if "eq"
|
||||
(progn (setq some-list '(1 2))
|
||||
(setq some-string "abc")
|
||||
(and (eq 2 2) (not (eq 1 2))
|
||||
(eq 'abc 'abc) (not (eq 'abc 'def))
|
||||
(eq some-string some-string) (not (eq some-string "abc"))
|
||||
(eq some-list some-list) (not (eq some-list '(1 2)))))))
|
||||
|
||||
(with-test-prefix/compile "Number Built-Ins"
|
||||
|
||||
(pass-if "floatp"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue