Commit b6596547 authored by pfdietz's avatar pfdietz
Browse files

More tests of defgeneric, mostly of variations of specialized lambda lists in method specifiers.

parent dbc6eec1
......@@ -413,4 +413,123 @@
(1 nil)
(a nil))
(deftest defgeneric.15
(let ((fn (eval '(defgeneric defgeneric.fun.15 (x &key)
(:method ((x number) &key foo &allow-other-keys)
(list x foo))
(:method ((x symbol) &key bar) (list x bar))))))
(values
(funcall fn 1)
(funcall fn 'a)
(funcall fn 1 :foo 2)
(funcall fn 1 :foo 2 :bar 3)
(funcall fn 1 :bar 4)
(funcall fn 'a :foo 'b)
(funcall fn 'a :bar 'b)
(funcall fn 'a :foo 'c :bar 'b)
(funcall fn 1 :baz 10)
(funcall fn 'a :baz 10)
(funcall fn 1 :allow-other-keys nil :baz 'a)
(funcall fn 'a :allow-other-keys nil :baz 'b)
))
(1 nil)
(a nil)
(1 2)
(1 2)
(1 nil)
(a nil)
(a b)
(a b)
(1 nil)
(a nil)
(1 nil)
(a nil))
(deftest defgeneric.16
(let ((fn (eval '(defgeneric defgeneric.fun.16 (x &key)
(:method ((x number) &key (foo 'a))
(list x foo))
(:method ((x symbol) &key foo)
(list x foo))))))
(values
(funcall fn 1)
(funcall fn 1 :foo nil)
(funcall fn 1 :foo 2)
(funcall fn 'x)
(funcall fn 'x :foo nil)
(funcall fn 'x :foo 'y)))
(1 a)
(1 nil)
(1 2)
(x nil)
(x nil)
(x y))
(deftest defgeneric.17
(let ((fn (eval '(defgeneric defgeneric.fun.17 (x &key)
(:method ((x number) &key (foo 'a foo-p))
(list x foo (notnot foo-p)))
(:method ((x symbol) &key foo)
(list x foo))))))
(values
(funcall fn 1)
(funcall fn 1 :foo nil)
(funcall fn 1 :foo 2)
(funcall fn 'x)
(funcall fn 'x :foo nil)
(funcall fn 'x :foo 'y)))
(1 a nil)
(1 nil t)
(1 2 t)
(x nil)
(x nil)
(x y))
(deftest defgeneric.18
(let ((fn (eval '(defgeneric defgeneric.fun.18 (x &optional y)
(:method ((x number) &optional (y 'a))
(list x y))
(:method ((x symbol) &optional (z nil z-p))
(list x z (notnot z-p)))))))
(values
(funcall fn 1)
(funcall fn 1 nil)
(funcall fn 1 2)
(funcall fn 'x)
(funcall fn 'x nil)
(funcall fn 'x 'y)))
(1 a)
(1 nil)
(1 2)
(x nil nil)
(x nil t)
(x y t))
(deftest defgeneric.19
(let ((fn (eval '(defgeneric defgeneric.fun.19 (x &key)
(:method ((x number) &key ((:bar foo) 'a foo-p))
(list x foo (notnot foo-p)))))))
(values
(funcall fn 1)
(funcall fn 1 :bar nil)
(funcall fn 1 :bar 2)))
(1 a nil)
(1 nil t)
(1 2 t))
(deftest defgeneric.20
(let ((fn (eval '(defgeneric defgeneric.fun.20 (x &optional y z)
(:method ((x number)
&optional (y (1+ x) y-p)
(z (if y-p (1+ y) (+ x 10))
z-p))
(list x y (notnot y-p) z (notnot z-p)))))))
(values
(funcall fn 1)
(funcall fn 1 5)
(funcall fn 1 5 9)))
(1 2 nil 11 nil)
(1 5 t 6 nil)
(1 5 t 9 t))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment