Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Karsten Poeck
ansi-test
Commits
ce9d2a25
Commit
ce9d2a25
authored
Jan 17, 2003
by
pfdietz
Browse files
Added more keyword argument handling tests.
parent
1a87ed65
Changes
26
Hide whitespace changes
Inline
Side-by-side
ansi-tests/cons-test-02.lsp
View file @
ce9d2a25
...
...
@@ -95,10 +95,34 @@
:key nil)
(2 2 b b))
(deftest sublis-9
(sublis nil 'a :bad-keyword t :allow-other-keys t)
;;; Keyword tests
(deftest sublis.allow-other-keys.1
(sublis nil 'a :bad t :allow-other-keys t)
a)
(deftest sublis.allow-other-keys.2
(sublis nil 'a :allow-other-keys t :bad t)
a)
(deftest sublis.allow-other-keys.3
(sublis nil 'a :allow-other-keys t)
a)
(deftest sublis.allow-other-keys.4
(sublis nil 'a :allow-other-keys nil)
a)
(deftest sublis.allow-other-keys.5
(sublis nil 'a :allow-other-keys t :allow-other-keys t :bad t)
a)
(deftest sublis.keywords.6
(sublis '((1 . a)) (list 0 1 2) :key #'(lambda (x) (if (numberp x) (1+ x) x))
:key #'identity)
(a 1 2))
;; Argument error cases
(deftest sublis.error.1
...
...
@@ -181,6 +205,34 @@
:key nil)
(2 2 b b))
;;; Keyword tests
(deftest nsublis.allow-other-keys.1
(nsublis nil 'a :bad t :allow-other-keys t)
a)
(deftest nsublis.allow-other-keys.2
(nsublis nil 'a :allow-other-keys t :bad t)
a)
(deftest nsublis.allow-other-keys.3
(nsublis nil 'a :allow-other-keys t)
a)
(deftest nsublis.allow-other-keys.4
(nsublis nil 'a :allow-other-keys nil)
a)
(deftest nsublis.allow-other-keys.5
(nsublis nil 'a :allow-other-keys t :allow-other-keys t :bad t)
a)
(deftest nsublis.keywords.6
(nsublis '((1 . a)) (list 0 1 2)
:key #'(lambda (x) (if (numberp x) (1+ x) x))
:key #'identity)
(a 1 2))
;; Argument error cases
(deftest nsublis.error.1
...
...
@@ -262,9 +314,35 @@
:key nil)
(a a c d a a))
(deftest subst-10
(subst 'a 'b nil :bad t :allow-other-keys t)
nil)
;;; Keyword tests for subst
(deftest subst.allow-other-keys.1
(subst 'a 'b (list 'a 'b 'c) :bad t :allow-other-keys t)
(a a c))
(deftest subst.allow-other-keys.2
(subst 'a 'b (list 'a 'b 'c) :allow-other-keys t)
(a a c))
(deftest subst.allow-other-keys.3
(subst 'a 'b (list 'a 'b 'c) :allow-other-keys nil)
(a a c))
(deftest subst.allow-other-keys.4
(subst 'a 'b (list 'a 'b 'c) :allow-other-keys t :bad t)
(a a c))
(deftest subst.allow-other-keys.5
(subst 'a 'b (list 'a 'b 'c) :allow-other-keys t :allow-other-keys nil
:bad t)
(a a c))
(deftest subst.keywords.6
(subst 'a 'b (list 'a 'b 'c) :test #'eq :test (complement #'eq))
(a a c))
;;; Tests for subst-if, subst-if-not
(deftest subst-if-1
(check-subst-if 'a #'consp '((100 1) (2 3) (4 3 2 1) (a b c)))
...
...
@@ -332,20 +410,63 @@
:key nil)
((a) (a) (c) (d)))
(deftest subst-if-7
(subst-if 'a #'null nil :bad t :allow-other-keys t)
a)
(deftest subst-if-not-5
(check-subst-if-not 'a #'(lambda (x) (not (eql x 'b)))
'((a) (b) (c) (d))
:key nil)
((a) (a) (c) (d)))
(deftest subst-if-not-7
(subst-if 'a #'identity nil :bad t :allow-other-keys t)
nil)
;;; Keyword tests for subst-if
(deftest subst-if.allow-other-keys.1
(subst-if 'a #'null nil :bad t :allow-other-keys t)
a)
(deftest subst-if.allow-other-keys.2
(subst-if 'a #'null nil :allow-other-keys t)
a)
(deftest subst-if.allow-other-keys.3
(subst-if 'a #'null nil :allow-other-keys nil)
a)
(deftest subst-if.allow-other-keys.4
(subst-if 'a #'null nil :allow-other-keys t :bad t)
a)
(deftest subst-if.allow-other-keys.5
(subst-if 'a #'null nil :allow-other-keys t :allow-other-keys nil :bad t)
a)
(deftest subst-if.keywords.6
(subst-if 'a #'null nil :key nil :key (constantly 'b))
a)
;;; Keywords tests for subst-if-not
(deftest subst-if-not.allow-other-keys.1
(subst-if-not 'a #'identity nil :bad t :allow-other-keys t)
a)
(deftest subst-if-not.allow-other-keys.2
(subst-if-not 'a #'identity nil :allow-other-keys t)
a)
(deftest subst-if-not.allow-other-keys.3
(subst-if-not 'a #'identity nil :allow-other-keys nil)
a)
(deftest subst-if-not.allow-other-keys.4
(subst-if-not 'a #'identity nil :allow-other-keys t :bad t)
a)
(deftest subst-if-not.allow-other-keys.5
(subst-if-not 'a #'identity nil :allow-other-keys t :allow-other-keys nil :bad t)
a)
(deftest subst-if-not.keywords.6
(subst-if-not 'a #'identity nil :key nil :key (constantly 'b))
a)
(defvar *nsubst-tree-1* '(10 (30 20 10) (20 10) (10 20 30 40)))
...
...
@@ -404,10 +525,35 @@
:key nil)
(a a c d a a))
(deftest nsubst-10
(nsubst 'a 'b nil :bad t :allow-other-keys t)
nil)
;;; Keyword tests for nsubst
(deftest nsubst.allow-other-keys.1
(nsubst 'a 'b (list 'a 'b 'c) :bad t :allow-other-keys t)
(a a c))
(deftest nsubst.allow-other-keys.2
(nsubst 'a 'b (list 'a 'b 'c) :allow-other-keys t)
(a a c))
(deftest nsubst.allow-other-keys.3
(nsubst 'a 'b (list 'a 'b 'c) :allow-other-keys nil)
(a a c))
(deftest nsubst.allow-other-keys.4
(nsubst 'a 'b (list 'a 'b 'c) :allow-other-keys t :bad t)
(a a c))
(deftest nsubst.allow-other-keys.5
(nsubst 'a 'b (list 'a 'b 'c) :allow-other-keys t :allow-other-keys nil
:bad t)
(a a c))
(deftest nsubst.keywords.6
(nsubst 'a 'b (list 'a 'b 'c) :test #'eq :test (complement #'eq))
(a a c))
;;; Tests for nsubst-if, nsubst-if-not
(deftest nsubst-if-1
(check-nsubst-if 'a #'consp '((100 1) (2 3) (4 3 2 1) (a b c)))
A)
...
...
@@ -488,6 +634,58 @@
(nsubst-if-not 'a #'null nil :bad t :allow-other-keys t)
nil)
;;; Keyword tests for nsubst-if
(deftest nsubst-if.allow-other-keys.1
(nsubst-if 'a #'null nil :bad t :allow-other-keys t)
a)
(deftest nsubst-if.allow-other-keys.2
(nsubst-if 'a #'null nil :allow-other-keys t)
a)
(deftest nsubst-if.allow-other-keys.3
(nsubst-if 'a #'null nil :allow-other-keys nil)
a)
(deftest nsubst-if.allow-other-keys.4
(nsubst-if 'a #'null nil :allow-other-keys t :bad t)
a)
(deftest nsubst-if.allow-other-keys.5
(nsubst-if 'a #'null nil :allow-other-keys t :allow-other-keys nil :bad t)
a)
(deftest nsubst-if.keywords.6
(nsubst-if 'a #'null nil :key nil :key (constantly 'b))
a)
;;; Keywords tests for nsubst-if-not
(deftest nsubst-if-not.allow-other-keys.1
(nsubst-if-not 'a #'identity nil :bad t :allow-other-keys t)
a)
(deftest nsubst-if-not.allow-other-keys.2
(nsubst-if-not 'a #'identity nil :allow-other-keys t)
a)
(deftest nsubst-if-not.allow-other-keys.3
(nsubst-if-not 'a #'identity nil :allow-other-keys nil)
a)
(deftest nsubst-if-not.allow-other-keys.4
(nsubst-if-not 'a #'identity nil :allow-other-keys t :bad t)
a)
(deftest nsubst-if-not.allow-other-keys.5
(nsubst-if-not 'a #'identity nil :allow-other-keys t :allow-other-keys nil :bad t)
a)
(deftest nsubst-if-not.keywords.6
(nsubst-if-not 'a #'identity nil :key nil :key (constantly 'b))
a)
;;; Error cases
;;; subst
...
...
ansi-tests/cons-test-03.lsp
View file @
ce9d2a25
...
...
@@ -189,14 +189,26 @@
(make-list 6 :initial-element 'a)
(a a a a a a))
(deftest make-list-other-key
word
s.1
(deftest make-list
.allow
-other-keys.1
(make-list 5 :allow-other-keys t :foo 'a)
(nil nil nil nil nil))
(deftest make-list-other-key
word
s.2
(deftest make-list
.allow
-other-keys.2
(make-list 5 :bar nil :allow-other-keys t)
(nil nil nil nil nil))
(deftest make-list.allow-other-keys.3
(make-list 5 :allow-other-keys nil)
(nil nil nil nil nil))
(deftest make-list.allow-other-keys.4
(make-list 5 :allow-other-keys t :allow-other-keys nil 'bad t)
(nil nil nil nil nil))
(deftest make-list.allow-other-keys.5
(make-list 5 :allow-other-keys t)
(nil nil nil nil nil))
(deftest make-list-repeated-keyword
(make-list 5 :initial-element 'a :initial-element 'b)
(a a a a a))
...
...
ansi-tests/cons-test-04.lsp
View file @
ce9d2a25
...
...
@@ -258,14 +258,26 @@
:test-not (complement #'equal) :key nil)
(aaa "AAA" "aaa" #\a))
(deftest adjoin-other-keys
-
1
(deftest adjoin
.allow
-other-keys
.
1
(adjoin 'a '(b c) :bad t :allow-other-keys t)
(a b c))
(deftest adjoin-other-keys
-
2
(deftest adjoin
.allow
-other-keys
.
2
(adjoin 'a '(b c) :allow-other-keys t :foo t)
(a b c))
(deftest adjoin.allow-other-keys.3
(adjoin 'a '(b c) :allow-other-keys t)
(a b c))
(deftest adjoin.allow-other-keys.4
(adjoin 'a '(b c) :allow-other-keys nil)
(a b c))
(deftest adjoin.allow-other-keys.5
(adjoin 'a '(b c) :allow-other-keys t :allow-other-keys nil 'bad t)
(a b c))
(deftest adjoin-repeat-key
(adjoin 'a '(b c) :test #'eq :test (complement #'eq))
(a b c))
...
...
ansi-tests/cons-test-13.lsp
View file @
ce9d2a25
...
...
@@ -143,11 +143,29 @@
(member 'z '(a b c d) :key nil)
nil)
(deftest member-20
;;; Keyword tests
(deftest member.allow-other-keys.1
(member 'b '(a b c) :bad t :allow-other-keys t)
(b c))
(deftest member-21
(deftest member.allow-other-keys.2
(member 'b '(a b c) :allow-other-keys t :bad t)
(b c))
(deftest member.allow-other-keys.3
(member 'b '(a b c) :allow-other-keys t)
(b c))
(deftest member.allow-other-keys.4
(member 'b '(a b c) :allow-other-keys nil)
(b c))
(deftest member.allow-other-keys.5
(member 'b '(a b c) :allow-other-keys 17 :allow-other-keys nil '#:x t)
(b c))
(deftest member.keywords.6
(member 'b '(a b c) :test #'eq :test (complement #'eq))
(b c))
...
...
ansi-tests/cons-test-14.lsp
View file @
ce9d2a25
...
...
@@ -43,18 +43,37 @@
(member-if #'identity '(1 2 3 4 5) :key #'evenp)
(2 3 4 5))
(deftest member-if-6
;;; Keyword tests
(deftest member-if.keywords.1
(member-if #'identity '(1 2 3 4 5) :key #'evenp :key #'oddp)
(2 3 4 5))
(deftest member-if
-7
(deftest member-if
.allow-other-keys.2
(member-if #'identity '(nil 2 3 4 5) :allow-other-keys t :bad t)
(2 3 4 5))
(deftest member-if
-8
(deftest member-if
.allow-other-keys.3
(member-if #'identity '(nil 2 3 4 5) :bad t :allow-other-keys t)
(2 3 4 5))
(deftest member-if.allow-other-keys.4
(member-if #'identity '(nil 2 3 4 5) :allow-other-keys t)
(2 3 4 5))
(deftest member-if.allow-other-keys.5
(member-if #'identity '(nil 2 3 4 5) :allow-other-keys nil)
(2 3 4 5))
(deftest member-if.allow-other-keys.5
(member-if #'identity '(nil 2 3 4 5) :allow-other-keys t
:allow-other-keys nil)
(2 3 4 5))
(deftest member-if.allow-other-keys.6
(member-if #'identity '(nil 2 3 4 5) :allow-other-keys t
:allow-other-keys nil :key #'identity :key #'null)
(2 3 4 5))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; member-if-not
...
...
@@ -92,18 +111,34 @@
(member-if-not #'not '(1 2 3 4 5) :key #'evenp)
(2 3 4 5))
(deftest member-if-not-6
;;; Keyword tests
(deftest member-if-not.keywords.1
(member-if-not #'not '(1 2 3 4 5) :key #'evenp :key #'oddp)
(2 3 4 5))
(deftest member-if-not
-7
(deftest member-if-not
.allow-other-keys.2
(member-if-not #'not '(nil 2 3 4 5) :allow-other-keys t :bad t)
(2 3 4 5))
(deftest member-if-not
-8
(deftest member-if-not
.allow-other-keys.3
(member-if-not #'not '(nil 2 3 4 5) :bad t :allow-other-keys t)
(2 3 4 5))
(deftest member-if-not.allow-other-keys.4
(member-if-not #'not '(nil 2 3 4 5) :allow-other-keys t)
(2 3 4 5))
(deftest member-if-not.allow-other-keys.5
(member-if-not #'not '(nil 2 3 4 5) :allow-other-keys nil)
(2 3 4 5))
(deftest member-if-not.allow-other-keys.6
(member-if-not #'not '(nil 2 3 4 5) :allow-other-keys t
:allow-other-keys nil :key #'identity :key #'null)
(2 3 4 5))
;;; Error cases
(deftest member-if.error.1
...
...
ansi-tests/cons-test-16.lsp
View file @
ce9d2a25
...
...
@@ -194,19 +194,38 @@
(eqt x y))))
(A . 3))
(deftest assoc-26
;;; Keyword tests
(deftest assoc.allow-other-keys.1
(assoc 'b '((a . 1) (b . 2) (c . 3)) :bad t :allow-other-keys t)
(b . 2))
(deftest assoc
-27
(deftest assoc
.allow-other-keys.2
(assoc 'b '((a . 1) (b . 2) (c . 3)) :allow-other-keys t :also-bad t)
(b . 2))
(deftest assoc
-28
(deftest assoc
.allow-other-keys.3
(assoc 'b '((a . 1) (b . 2) (c . 3)) :allow-other-keys t :also-bad t
:test-not #'eql)
(a . 1))
(deftest assoc.allow-other-keys.4
(assoc 'b '((a . 1) (b . 2) (c . 3)) :allow-other-keys t)
(b . 2))
(deftest assoc.allow-other-keys.5
(assoc 'b '((a . 1) (b . 2) (c . 3)) :allow-other-keys nil)
(b . 2))
(deftest assoc.keywords.6
(assoc 'b '((a . 1) (b . 2) (c . 3)) :key #'identity :key #'null)
(b . 2))
(deftest assoc.keywords.7
(assoc 'b '((a . 1) (b . 2) (c . 3)) :key nil :key #'null)
(b . 2))
(deftest assoc.error.1
(classify-error (assoc))
program-error)
...
...
@@ -268,20 +287,38 @@
(assoc-if #'null '((a . b) nil (c . d) (nil . e) (f . g)))
(nil . e))
(deftest assoc-if-5
;;; Keyword tests
(deftest assoc-if.allow-other-keys.1
(assoc-if #'null '((a . 1) (nil . 2) (c . 3)) :bad t :allow-other-keys t)
(nil . 2))
(deftest assoc-if
-6
(deftest assoc-if
.allow-other-keys.2
(assoc-if #'null '((a . 1) (nil . 2) (c . 3))
:allow-other-keys t :also-bad t)
(nil . 2))
(deftest assoc-if
-7
(deftest assoc-if
.allow-other-keys.3
(assoc-if #'null '((a . 1) (nil . 2) (c . 3))
:allow-other-keys t :also-bad t :key #'not)
(a . 1))
(deftest assoc-if.allow-other-keys.4
(assoc-if #'null '((a . 1) (nil . 2) (c . 3)) :allow-other-keys t)
(nil . 2))
(deftest assoc-if.allow-other-keys.5
(assoc-if #'null '((a . 1) (nil . 2) (c . 3)) :allow-other-keys nil)
(nil . 2))
(deftest assoc-if.keywords.6
(assoc-if #'null '((a . 1) (nil . 2) (c . 3)) :key #'identity :key #'null)
(nil . 2))
(deftest assoc-if.keywords.7
(assoc-if #'null '((a . 1) (nil . 2) (c . 3)) :key nil :key #'null)
(nil . 2))
;;; Error cases
(deftest assoc-if.error.1
...
...
@@ -345,21 +382,42 @@
(assoc-if-not #'identity '((a . b) nil (c . d) (nil . e) (f . g)))
(nil . e))
(deftest assoc-if-not-5
;;; Keyword tests
(deftest assoc-if-not.allow-other-keys.1
(assoc-if-not #'identity
'((a . 1) (nil . 2) (c . 3)) :bad t :allow-other-keys t)
(nil . 2))
(deftest assoc-if-not
-6
(deftest assoc-if-not
.allow-other-keys.2
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3))
:allow-other-keys t :also-bad t)
(nil . 2))
(deftest assoc-if-not
-7
(deftest assoc-if-not
.allow-other-keys.3
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3))
:allow-other-keys t :also-bad t :key #'not)
(a . 1))
(deftest assoc-if-not.allow-other-keys.4
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3)) :allow-other-keys t)
(nil . 2))
(deftest assoc-if-not.allow-other-keys.5
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3)) :allow-other-keys nil)
(nil . 2))
(deftest assoc-if-not.keywords.6
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3))
:key #'identity :key #'null)
(nil . 2))
(deftest assoc-if-not.keywords.7
(assoc-if-not #'identity '((a . 1) (nil . 2) (c . 3)) :key nil :key #'null)
(nil . 2))
;;; Error tests
(deftest assoc-if-not.error.1
(classify-error (assoc-if-not))
program-error)
...
...
ansi-tests/count-if-not.lsp
View file @
ce9d2a25
...
...
@@ -418,7 +418,7 @@
(count-if-not #'%onep a :from-end t)))))
2 3 2 3)
;;;
Allow-other-keys
tests
;;;
Keyword
tests
(deftest count-if-not.keywords.1
(count-if-not #'oddp '(1 2 3 4 5) :bad t :allow-other-keys t)
...
...
ansi-tests/count-if.lsp
View file @
ce9d2a25
...
...
@@ -417,7 +417,7 @@
(count-if #'digit-char-p s :start 1 :end 2)))
3 3 2 2 1)
;;;
Allow-other-keys
tests
;;;
Keyword
tests
(deftest count-if.allow-other-keys.1
(count-if #'evenp '(1 2 3 4 5) :bad t :allow-other-keys t)
...
...
@@ -435,10 +435,13 @@
:bad t)
2)
(deftest count-if.
allow-other-key
s.4
(deftest count-if.
keyword
s.4
(count-if #'evenp '(1 2 3 4 5) :key #'identity :key #'1+)
2)
(deftest count-if.allow-other-keys.5
(count-if #'evenp '(1 2 3 4 5) :allow-other-keys nil)
2)
;;; Error tests
...
...
ansi-tests/count.lsp
View file @
ce9d2a25
...
...
@@ -486,7 +486,7 @@
:start 2 :end 5)
3)
;;;
Allow-other-keys
tests
;;;
Keyword
tests
(deftest count.allow-other-keys.1
(count 'a '(b a d a c) :bad t :allow-other-keys t)
...
...
@@ -504,7 +504,7 @@
:bad t)
2)
(deftest count.
allow-other-key
s.4
(deftest count.
keyword
s.4
(count 2 '(1 2 3 2 5) :key #'identity :key #'1+)
2)
...
...
ansi-tests/make-sequence.lsp
View file @
ce9d2a25
...
...
@@ -165,6 +165,33 @@
(equalp (make-sequence 'string 5) (make-string 5))
t)
;;; Keyword tests
(deftest make-sequence.allow-other-keys.1
(make-sequence 'list 5 :allow-other-keys t :initial-element 'a :bad t)
(a a a a a))
(deftest make-sequence.allow-other-keys.2
(make-sequence 'list 5 :initial-element 'a :bad t :allow-other-keys t)
(a a a a a))
(deftest make-sequence.allow-other-keys.3
(make-sequence 'list 5 :initial-element 'a :allow-other-keys t)
(a a a a a))
(deftest make-sequence.allow-other-keys.4
(make-sequence 'list 5 :initial-element 'a :allow-other-keys nil)