Commit dbc6eec1 authored by pfdietz's avatar pfdietz
Browse files

More defgeneric tests of congruence of lambda lists.

parent 6f2ea843
......@@ -295,3 +295,122 @@
((c b a))
((z y x)))
(deftest defgeneric.9
(let ((fn (eval '(defgeneric defgeneric.fun.9 (x &optional y z)
(:method ((x number) &optional (y 10) (z 20))
(list x y z))
(:method ((p symbol) &optional (q 's) (r 't))
(list r q p))))))
(values
(funcall fn 1)
(funcall fn 1 2)
(funcall fn 1 2 3)
(funcall fn 'a)
(funcall fn 'a 'b)
(funcall fn 'a 'b 'c)))
(1 10 20)
(1 2 20)
(1 2 3)
(t s a)
(t b a)
(c b a))
(deftest defgeneric.10
(let ((fn (eval '(defgeneric defgeneric.fun.10 (x &rest y)
(:method ((x number) &key foo) (list x foo))))))
(values
(funcall fn 1)
(funcall fn 1 :foo 'a)
(defgeneric.fun.10 5/3 :foo 'x :foo 'y)
(defgeneric.fun.10 10 :bar t :allow-other-keys t)
(defgeneric.fun.10 20 :allow-other-keys nil :foo 'x)))
(1 nil)
(1 a)
(5/3 x)
(10 nil)
(20 x))
(deftest defgeneric.11
(let ((fn (eval '(defgeneric defgeneric.fun.11 (x &key)
(:method ((x number) &key foo) (list x foo))))))
(values
(funcall fn 1)
(funcall fn 1 :foo 'a)
(defgeneric.fun.11 5/3 :foo 'x :foo 'y)
(defgeneric.fun.11 11 :bar t :allow-other-keys t)
(defgeneric.fun.11 20 :allow-other-keys nil :foo 'x)))
(1 nil)
(1 a)
(5/3 x)
(11 nil)
(20 x))
(deftest defgeneric.12
(let ((fn (eval '(defgeneric defgeneric.fun.12 (x &key foo bar baz)
(:method ((x number) &rest y) (list x y))))))
(values
(funcall fn 1)
(funcall fn 1 :foo 'a)
(defgeneric.fun.12 5/3 :foo 'x :foo 'y :bar 'z)
(defgeneric.fun.12 11 :zzz t :allow-other-keys t)
(defgeneric.fun.12 20 :allow-other-keys nil :foo 'x)))
(1 nil)
(1 (:foo a))
(5/3 (:foo x :foo y :bar z))
(11 (:zzz t :allow-other-keys t))
(20 (:allow-other-keys nil :foo x)))
(deftest defgeneric.13
(let ((fn (eval '(defgeneric defgeneric.fun.13 (x &key)
(:method ((x number) &key foo) (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)))
(1 nil)
(a nil)
(1 2)
(1 2)
(1 nil)
(a nil)
(a b)
(a b))
(deftest defgeneric.14
(let ((fn (eval '(defgeneric defgeneric.fun.14 (x &key &allow-other-keys)
(:method ((x number) &key foo) (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))
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