2017-03-06 11:00:18 -05:00
|
|
|
(load "../unit/unit-test.lisp")
|
2017-03-03 11:56:27 -05:00
|
|
|
(load "dlambda.lisp")
|
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(unit
|
|
|
|
(list
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun empty-dlambda ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments) (case (first arguments)))
|
2017-03-03 15:06:49 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda)))
|
2017-03-06 11:00:18 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun dlambda-default-method-only ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments)
|
|
|
|
(case (first arguments)
|
|
|
|
(t (apply (lambda () (print "nothing")) arguments))))
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda
|
|
|
|
(t () (print "nothing")))))
|
2017-03-06 11:00:18 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun dlambda-named-method-only ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments)
|
|
|
|
(case (first arguments)
|
|
|
|
(:write (apply (lambda () (print "something")) (rest arguments)))))
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda
|
|
|
|
(:write () (print "something")))))
|
2017-03-06 11:00:18 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun dlambda-named-and-default-method ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments)
|
|
|
|
(case (first arguments)
|
|
|
|
(:write (apply (lambda () (print "something")) (rest arguments)))
|
|
|
|
(t (apply (lambda () (print "nothing")) arguments))))
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda
|
|
|
|
(:write () (print "something"))
|
|
|
|
(t () (print "nothing")))))
|
2017-03-06 11:00:18 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun dlambda-methods-with-arguments ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments)
|
|
|
|
(case (first arguments)
|
|
|
|
(:write (apply (lambda (message) (print message)) (rest arguments)))
|
|
|
|
(t (apply (lambda (&rest messages) (print messages)) arguments))))
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda
|
|
|
|
(:write (message) (print message))
|
|
|
|
(t (&rest messages) (print messages)))))
|
2017-03-06 11:00:18 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(defun dlambda-methods-with-multiple-arguments ()
|
|
|
|
(assert-equal
|
|
|
|
'(lambda (&rest arguments)
|
|
|
|
(case (first arguments)
|
|
|
|
(:write
|
|
|
|
(apply
|
|
|
|
(lambda (message &rest other-stuff)
|
|
|
|
(print message)
|
|
|
|
(print other-stuff))
|
|
|
|
(rest arguments)))
|
|
|
|
(t
|
|
|
|
(apply
|
|
|
|
(lambda (message1 message2 &rest other-stuff)
|
|
|
|
(print message1)
|
|
|
|
(print message2)
|
|
|
|
(print other-stuff))
|
|
|
|
arguments))))
|
2017-03-03 11:56:27 -05:00
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
(dlambda
|
|
|
|
(:write (message &rest other-stuff)
|
|
|
|
(print message)
|
|
|
|
(print other-stuff))
|
|
|
|
(t (message1 message2 &rest other-stuff)
|
|
|
|
(print message1)
|
|
|
|
(print message2)
|
|
|
|
(print other-stuff)))))))
|