diff options
author | Daniel Kraft <d@domob.eu> | 2009-07-18 17:21:55 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2009-07-18 17:21:55 +0200 |
commit | e905e490fae68bd87ec66b35235b02c61cdace40 (patch) | |
tree | fcadff521e0f31df67a9bb7d397608f1812dcfdd | |
parent | 74c009dadc1e8f580727d2c85bf72ec90e82d15a (diff) | |
download | guile-e905e490fae68bd87ec66b35235b02c61cdace40.tar.gz |
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.
-rw-r--r-- | module/language/elisp/runtime/function-slot.scm | 9 | ||||
-rw-r--r-- | test-suite/tests/elisp-compiler.test | 17 |
2 files changed, 26 insertions, 0 deletions
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" |