From 1a87ed651199ed1a9eeb8603b6f99007d99a3003 Mon Sep 17 00:00:00 2001 From: pfdietz <pfdietz@localhost> Date: Thu, 16 Jan 2003 14:11:33 +0000 Subject: [PATCH] Added keyword processing tests for FIND, FIND-IF, and FIND-IF-NOT. --- ansi-tests/find-if-not.lsp | 27 +++++++++++++++++++++++++++ ansi-tests/find-if.lsp | 27 +++++++++++++++++++++++++++ ansi-tests/find.lsp | 29 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/ansi-tests/find-if-not.lsp b/ansi-tests/find-if-not.lsp index defe5940..8322503d 100644 --- a/ansi-tests/find-if-not.lsp +++ b/ansi-tests/find-if-not.lsp @@ -484,6 +484,33 @@ (nil #\6) (#\6))) + +;;; Keyword tests + +(deftest find-if-not.allow-other-keys.1 + (find-if-not #'oddp '(1 2 3 4 5) :bad t :allow-other-keys t) + 2) + +(deftest find-if-not.allow-other-keys.2 + (find-if-not #'oddp '(1 2 3 4 5) :allow-other-keys t :also-bad t) + 2) + +;;; The leftmost of two :allow-other-keys arguments is the one that matters. +(deftest find-if-not.allow-other-keys.3 + (find-if-not #'oddp '(1 2 3 4 5) + :allow-other-keys t + :allow-other-keys nil + :bad t) + 2) + +(deftest find-if-not.keywords.4 + (find-if-not #'oddp '(1 2 3 4 5) :key #'identity :key #'1+) + 2) + +(deftest find-if-not.allow-other-keys.5 + (find-if-not #'null '(nil a b c nil) :allow-other-keys nil) + a) + ;;; Error tests (deftest find-if-not.error.1 diff --git a/ansi-tests/find-if.lsp b/ansi-tests/find-if.lsp index d9f52e47..6754f7b4 100644 --- a/ansi-tests/find-if.lsp +++ b/ansi-tests/find-if.lsp @@ -507,6 +507,33 @@ )) #\2 #\4 #\1 #\5) +;;; Keyword tests + +(deftest find-if.allow-other-keys.1 + (find-if #'evenp '(1 2 3 4 5) :bad t :allow-other-keys t) + 2) + +(deftest find-if.allow-other-keys.2 + (find-if #'evenp '(1 2 3 4 5) :allow-other-keys t :also-bad t) + 2) + +;;; The leftmost of two :allow-other-keys arguments is the one that matters. +(deftest find-if.allow-other-keys.3 + (find-if #'evenp '(1 2 3 4 5) + :allow-other-keys t + :allow-other-keys nil + :bad t) + 2) + +(deftest find-if.keywords.4 + (find-if #'evenp '(1 2 3 4 5) :key #'identity :key #'1+) + 2) + +(deftest find-if.allow-other-keys.5 + (find-if #'identity '(nil a b c nil) :allow-other-keys nil) + a) + + ;;; Error tests (deftest find-if.error.1 diff --git a/ansi-tests/find.lsp b/ansi-tests/find.lsp index 1fc804a7..026cc3bf 100644 --- a/ansi-tests/find.lsp +++ b/ansi-tests/find.lsp @@ -741,6 +741,35 @@ (#\a #\b #\c #\d #\e nil nil nil nil nil) (#\a #\b #\c #\d #\e nil nil nil nil nil)) +;;; Keyword tests + +(deftest find.allow-other-keys.1 + (find 0 '(1 2 3 4 5) :key #'(lambda (x) (mod x 2)) + :bad t :allow-other-keys t) + 2) + +(deftest find.allow-other-keys.2 + (find 0 '(1 2 3 4 5) :key #'(lambda (x) (mod x 2)) + :allow-other-keys t :also-bad t) + 2) + +;;; The leftmost of two :allow-other-keys arguments is the one that matters. +(deftest find.allow-other-keys.3 + (find 0 '(1 2 3 4 5) :key #'(lambda (x) (mod x 2)) + :allow-other-keys t + :allow-other-keys nil + :bad t) + 2) + +(deftest find.keywords.4 + (find 2 '(1 2 3 4 5) :key #'identity :key #'1+) + 2) + +(deftest find.allow-other-keys.5 + (find 'b '(nil a b c nil) :allow-other-keys nil) + b) + + ;;; Error tests (deftest find.error.1 -- GitLab