2017-03-02 16:36:23 -05:00
|
|
|
---
|
|
|
|
Test
|
|
|
|
---
|
|
|
|
An object with multiple methods.
|
|
|
|
|
2017-03-06 12:44:06 -05:00
|
|
|
| script | lisp interpreter fixture |
|
|
|
|
| show | evaluate text |!-
|
2017-03-02 16:36:23 -05:00
|
|
|
|
|
|
|
(defun counter-class ()
|
|
|
|
(let ((counter 0))
|
|
|
|
(lambda (msg)
|
|
|
|
(case msg
|
|
|
|
((:inc)
|
|
|
|
(setq counter (+ counter 1)))
|
|
|
|
((:dec)
|
|
|
|
(setq counter (- counter 1)))))))
|
|
|
|
|
2017-03-03 15:06:49 -05:00
|
|
|
-!|
|
2017-03-06 12:44:06 -05:00
|
|
|
| show | evaluate text | (setq my-counter (counter-class)) |
|
|
|
|
| check | evaluate text | (funcall my-counter :inc) | 1 |
|
|
|
|
| check | evaluate text | (funcall my-counter :inc) | 2 |
|
|
|
|
| check | evaluate text | (funcall my-counter :inc) | 3 |
|
|
|
|
| check | evaluate text | (funcall my-counter :dec) | 2 |
|
|
|
|
| check | evaluate text | (funcall my-counter :dec) | 1 |
|
|
|
|
| check | evaluate text | (funcall my-counter :dec) | 0 |
|