2017-02-28 11:54:19 -05:00
|
|
|
---
|
|
|
|
Test
|
|
|
|
---
|
|
|
|
| script | lisp interpreter fixture |
|
|
|
|
| # | Object with multiple methods |
|
|
|
|
| show | evaluate |!-
|
|
|
|
|
2017-03-01 11:11:59 -05:00
|
|
|
(defun counter-class ()
|
2017-02-28 11:54:19 -05:00
|
|
|
(let ((counter 0))
|
|
|
|
(lambda (msg)
|
|
|
|
(case msg
|
|
|
|
((:inc)
|
|
|
|
(setq counter (+ counter 1)))
|
|
|
|
((:dec)
|
|
|
|
(setq counter (- counter 1)))))))
|
|
|
|
|
|
|
|
-!|
|
2017-03-01 11:11:59 -05:00
|
|
|
| show | evaluate | (setq my-counter (counter-class)) |
|
2017-02-28 11:54:19 -05:00
|
|
|
| check | evaluate | (funcall my-counter :inc) | 1 |
|
|
|
|
| check | evaluate | (funcall my-counter :inc) | 2 |
|
|
|
|
| check | evaluate | (funcall my-counter :inc) | 3 |
|
|
|
|
| check | evaluate | (funcall my-counter :dec) | 2 |
|
|
|
|
| check | evaluate | (funcall my-counter :dec) | 1 |
|
|
|
|
| check | evaluate | (funcall my-counter :dec) | 0 |
|