From e905e490fae68bd87ec66b35235b02c61cdace40 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Sat, 18 Jul 2009 17:21:55 +0200 Subject: [PATCH] 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. --- module/language/elisp/runtime/function-slot.scm | 9 +++++++++ test-suite/tests/elisp-compiler.test | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/module/language/elisp/runtime/function-slot.scm b/module/language/elisp/runtime/function-slot.scm index 235341989..db751d2e7 100644 --- a/module/language/elisp/runtime/function-slot.scm +++ b/module/language/elisp/runtime/function-slot.scm @@ -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) diff --git a/test-suite/tests/elisp-compiler.test b/test-suite/tests/elisp-compiler.test index 677f14dc0..af928c5df 100644 --- a/test-suite/tests/elisp-compiler.test +++ b/test-suite/tests/elisp-compiler.test @@ -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"