goops.test 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. ;;;; goops.test --- test suite for GOOPS -*- scheme -*-
  2. ;;;;
  3. ;;;; Copyright (C) 2001,2003,2004, 2006, 2008, 2009, 2011, 2012, 2014, 2015 Free Software Foundation, Inc.
  4. ;;;;
  5. ;;;; This library is free software; you can redistribute it and/or
  6. ;;;; modify it under the terms of the GNU Lesser General Public
  7. ;;;; License as published by the Free Software Foundation; either
  8. ;;;; version 3 of the License, or (at your option) any later version.
  9. ;;;;
  10. ;;;; This library is distributed in the hope that it will be useful,
  11. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. ;;;; Lesser General Public License for more details.
  14. ;;;;
  15. ;;;; You should have received a copy of the GNU Lesser General Public
  16. ;;;; License along with this library; if not, write to the Free Software
  17. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. (define-module (test-suite test-goops)
  19. #:use-module (test-suite lib)
  20. #:autoload (srfi srfi-1) (unfold))
  21. (define exception:no-applicable-method
  22. '(goops-error . "^No applicable method"))
  23. (pass-if "GOOPS loads"
  24. (false-if-exception
  25. (begin (resolve-module '(oop goops))
  26. #t)))
  27. (use-modules (oop goops))
  28. ;;; more tests here...
  29. (with-test-prefix "basic classes"
  30. (with-test-prefix "<top>"
  31. (pass-if "instance?"
  32. (instance? <top>))
  33. (pass-if "class-of"
  34. (eq? (class-of <top>) <class>))
  35. (pass-if "is a class?"
  36. (is-a? <top> <class>))
  37. (pass-if "class-name"
  38. (eq? (class-name <top>) '<top>))
  39. (pass-if "direct superclasses"
  40. (equal? (class-direct-supers <top>) '()))
  41. (pass-if "superclasses"
  42. (equal? (class-precedence-list <top>) (list <top>)))
  43. (pass-if "direct slots"
  44. (equal? (class-direct-slots <top>) '()))
  45. (pass-if "slots"
  46. (equal? (class-slots <top>) '())))
  47. (with-test-prefix "<object>"
  48. (pass-if "instance?"
  49. (instance? <object>))
  50. (pass-if "class-of"
  51. (eq? (class-of <object>) <class>))
  52. (pass-if "is a class?"
  53. (is-a? <object> <class>))
  54. (pass-if "class-name"
  55. (eq? (class-name <object>) '<object>))
  56. (pass-if "direct superclasses"
  57. (equal? (class-direct-supers <object>) (list <top>)))
  58. (pass-if "superclasses"
  59. (equal? (class-precedence-list <object>) (list <object> <top>)))
  60. (pass-if "direct slots"
  61. (equal? (class-direct-slots <object>) '()))
  62. (pass-if "slots"
  63. (equal? (class-slots <object>) '())))
  64. (with-test-prefix "<class>"
  65. (pass-if "instance?"
  66. (instance? <class>))
  67. (pass-if "class-of"
  68. (eq? (class-of <class>) <class>))
  69. (pass-if "is a class?"
  70. (is-a? <class> <class>))
  71. (pass-if "class-name"
  72. (eq? (class-name <class>) '<class>))
  73. (pass-if "direct superclass"
  74. (equal? (class-direct-supers <class>) (list <object>))))
  75. (with-test-prefix "class-precedence-list"
  76. (for-each (lambda (class)
  77. (run-test (if (slot-bound? class 'name)
  78. (class-name class)
  79. (with-output-to-string
  80. (lambda ()
  81. (display class))))
  82. #t
  83. (lambda ()
  84. (catch #t
  85. (lambda ()
  86. (equal? (class-precedence-list class)
  87. (compute-cpl class)))
  88. (lambda args #t)))))
  89. (let ((table (make-hash-table)))
  90. (let rec ((class <top>))
  91. (hash-create-handle! table class #f)
  92. (for-each rec (class-direct-subclasses class)))
  93. (hash-fold (lambda (class ignore classes)
  94. (cons class classes))
  95. '()
  96. table))))
  97. )
  98. (with-test-prefix "classes for built-in types"
  99. (pass-if "subr"
  100. (eq? (class-of fluid-ref) <procedure>))
  101. (pass-if "gsubr"
  102. (eq? (class-of hashq-ref) <procedure>))
  103. (pass-if "car"
  104. (eq? (class-of car) <procedure>))
  105. (pass-if "string"
  106. (eq? (class-of "foo") <string>))
  107. (pass-if "port"
  108. (is-a? (%make-void-port "w") <port>))
  109. (pass-if "struct vtable"
  110. ;; Previously, `class-of' would fail for nameless structs, i.e., structs
  111. ;; for which `struct-vtable-name' is #f.
  112. (is-a? (class-of (make-vtable
  113. (string-append standard-vtable-fields "prprpr")))
  114. <class>)))
  115. (with-test-prefix "defining classes"
  116. (with-test-prefix "define-class"
  117. (pass-if "creating a new binding"
  118. (if (eval '(defined? '<foo-0>) (current-module))
  119. (throw 'unresolved))
  120. (eval '(define-class <foo-0> ()) (current-module))
  121. (eval '(is-a? <foo-0> <class>) (current-module)))
  122. (pass-if "overwriting a binding to a non-class"
  123. (eval '(define <foo> #f) (current-module))
  124. (eval '(define-class <foo> ()) (current-module))
  125. (eval '(is-a? <foo> <class>) (current-module)))
  126. (expect-fail "bad init-thunk"
  127. (begin
  128. (catch #t
  129. (lambda ()
  130. (eval '(define-class <foo> ()
  131. (x #:init-thunk (lambda (x) 1)))
  132. (current-module))
  133. #t)
  134. (lambda args
  135. #f))))
  136. (pass-if "interaction with `struct-ref'"
  137. (eval '(define-class <class-struct> ()
  138. (foo #:init-keyword #:foo)
  139. (bar #:init-keyword #:bar))
  140. (current-module))
  141. (eval '(let ((x (make <class-struct>
  142. #:foo 'hello
  143. #:bar 'world)))
  144. (and (struct? x)
  145. (eq? (struct-ref x 0) 'hello)
  146. (eq? (struct-ref x 1) 'world)))
  147. (current-module)))
  148. (pass-if "interaction with `struct-set!'"
  149. (eval '(define-class <class-struct-2> ()
  150. (foo) (bar))
  151. (current-module))
  152. (eval '(let ((x (make <class-struct-2>)))
  153. (struct-set! x 0 'hello)
  154. (struct-set! x 1 'world)
  155. (and (struct? x)
  156. (eq? (struct-ref x 0) 'hello)
  157. (eq? (struct-ref x 1) 'world)))
  158. (current-module)))
  159. (pass-if "with accessors"
  160. (eval '(define-class <qux> ()
  161. (x #:accessor x #:init-value 123)
  162. (z #:accessor z #:init-value 789))
  163. (current-module))
  164. (eval '(equal? (x (make <qux>)) 123) (current-module)))
  165. (pass-if-exception "cannot redefine fields of <class>"
  166. '(misc-error . "cannot be redefined")
  167. (eval '(begin
  168. (define-class <test-class> (<class>)
  169. name)
  170. (make <test-class>))
  171. (current-module)))))
  172. (with-test-prefix "defining generics"
  173. (with-test-prefix "define-generic"
  174. (pass-if "creating a new top-level binding"
  175. (if (eval '(defined? 'foo-0) (current-module))
  176. (throw 'unresolved))
  177. (eval '(define-generic foo-0) (current-module))
  178. (eval '(and (is-a? foo-0 <generic>)
  179. (null? (generic-function-methods foo-0)))
  180. (current-module)))
  181. (pass-if "overwriting a top-level binding to a non-generic"
  182. (eval '(define (foo) #f) (current-module))
  183. (eval '(define-generic foo) (current-module))
  184. (eval '(and (is-a? foo <generic>)
  185. (= 1 (length (generic-function-methods foo))))
  186. (current-module)))
  187. (pass-if "overwriting a top-level binding to a generic"
  188. (eval '(define (foo) #f) (current-module))
  189. (eval '(define-generic foo) (current-module))
  190. (eval '(define-generic foo) (current-module))
  191. (eval '(and (is-a? foo <generic>)
  192. (null? (generic-function-methods foo)))
  193. (current-module)))
  194. (pass-if-exception "getters do not have setters"
  195. exception:wrong-type-arg
  196. (eval '(setter foo) (current-module)))))
  197. (with-test-prefix "defining methods"
  198. (pass-if "define-method"
  199. (let ((m (current-module)))
  200. (eval '(define-method (my-plus (s1 <string>) (s2 <string>))
  201. (string-append s1 s2))
  202. m)
  203. (eval '(define-method (my-plus (i1 <integer>) (i2 <integer>))
  204. (+ i1 i2))
  205. m)
  206. (eval '(and (is-a? my-plus <generic>)
  207. (= (length (generic-function-methods my-plus))
  208. 2))
  209. m)))
  210. (pass-if "method-more-specific?"
  211. (eval '(let* ((m+ (generic-function-methods my-plus))
  212. (m1 (car m+))
  213. (m2 (cadr m+))
  214. (arg-types (list <string> <string>)))
  215. (if (memq <string> (method-specializers m1))
  216. (method-more-specific? m1 m2 arg-types)
  217. (method-more-specific? m2 m1 arg-types)))
  218. (current-module)))
  219. (pass-if-exception "method-more-specific? (failure)"
  220. exception:wrong-type-arg
  221. (eval '(let* ((m+ (generic-function-methods my-plus))
  222. (m1 (car m+))
  223. (m2 (cadr m+)))
  224. (method-more-specific? m1 m2 '()))
  225. (current-module))))
  226. (with-test-prefix "the method cache"
  227. (pass-if "defining a method with a rest arg"
  228. (let ((m (current-module)))
  229. (eval '(define-method (foo bar . baz)
  230. (cons bar baz))
  231. m)
  232. (eval '(foo 1)
  233. m)
  234. (eval '(foo 1 2)
  235. m)
  236. (eval '(equal? (foo 1 2) '(1 2))
  237. m))))
  238. (with-test-prefix "defining accessors"
  239. (with-test-prefix "define-accessor"
  240. (pass-if "creating a new top-level binding"
  241. (if (eval '(defined? 'foo-1) (current-module))
  242. (throw 'unresolved))
  243. (eval '(define-accessor foo-1) (current-module))
  244. (eval '(and (is-a? foo-1 <generic-with-setter>)
  245. (null? (generic-function-methods foo-1)))
  246. (current-module)))
  247. (pass-if "accessors have setters"
  248. (procedure? (eval '(setter foo-1) (current-module))))
  249. (pass-if "overwriting a top-level binding to a non-accessor"
  250. (eval '(define (foo) #f) (current-module))
  251. (eval '(define-accessor foo) (current-module))
  252. (eval '(and (is-a? foo <generic-with-setter>)
  253. (= 1 (length (generic-function-methods foo))))
  254. (current-module)))
  255. (pass-if "overwriting a top-level binding to an accessor"
  256. (eval '(define (foo) #f) (current-module))
  257. (eval '(define-accessor foo) (current-module))
  258. (eval '(define-accessor foo) (current-module))
  259. (eval '(and (is-a? foo <generic-with-setter>)
  260. (null? (generic-function-methods foo)))
  261. (current-module)))))
  262. (with-test-prefix "object update"
  263. (pass-if "defining class"
  264. (eval '(define-class <foo> ()
  265. (x #:accessor x #:init-value 123)
  266. (z #:accessor z #:init-value 789))
  267. (current-module))
  268. (eval '(is-a? <foo> <class>) (current-module)))
  269. (pass-if "making instance"
  270. (eval '(define foo (make <foo>)) (current-module))
  271. (eval '(and (is-a? foo <foo>) (= (x foo) 123)) (current-module)))
  272. (pass-if "redefining class"
  273. (eval '(define-class <foo> ()
  274. (x #:accessor x #:init-value 123)
  275. (y #:accessor y #:init-value 456)
  276. (z #:accessor z #:init-value 789))
  277. (current-module))
  278. (eval '(and (= (y foo) 456) (= (z foo) 789)) (current-module)))
  279. (pass-if "changing class"
  280. (let* ((c1 (class () (the-slot #:init-keyword #:value)))
  281. (c2 (class () (the-slot #:init-keyword #:value)
  282. (the-other-slot #:init-value 888)))
  283. (o1 (make c1 #:value 777)))
  284. (and (is-a? o1 c1)
  285. (not (is-a? o1 c2))
  286. (equal? (slot-ref o1 'the-slot) 777)
  287. (let ((o2 (change-class o1 c2)))
  288. (and (eq? o1 o2)
  289. (is-a? o2 c2)
  290. (not (is-a? o2 c1))
  291. (equal? (slot-ref o2 'the-slot) 777))))))
  292. (pass-if "`hell' in `goops.c' grows as expected"
  293. ;; This snippet yielded a segfault prior to the 2008-08-19 `goops.c'
  294. ;; fix (i.e., Guile 1.8.5 and earlier). The root of the problem was
  295. ;; that `go_to_hell ()' would not reallocate enough room for the `hell'
  296. ;; array, leading to out-of-bounds accesses.
  297. (let* ((parent-class (class ()
  298. #:name '<class-that-will-be-redefined>))
  299. (classes
  300. (unfold (lambda (i) (>= i 20))
  301. (lambda (i)
  302. (make-class (list parent-class)
  303. '((the-slot #:init-value #:value)
  304. (the-other-slot))
  305. #:name (string->symbol
  306. (string-append "<foo-to-redefine-"
  307. (number->string i)
  308. ">"))))
  309. (lambda (i)
  310. (+ 1 i))
  311. 0))
  312. (objects
  313. (map (lambda (class)
  314. (make class #:value 777))
  315. classes)))
  316. (define-method (change-class (foo parent-class)
  317. (new <class>))
  318. ;; Called by `scm_change_object_class ()', via `purgatory ()'.
  319. (if (null? classes)
  320. (next-method)
  321. (let ((class (car classes))
  322. (object (car objects)))
  323. (set! classes (cdr classes))
  324. (set! objects (cdr objects))
  325. ;; Redefine the class so that its instances are eventually
  326. ;; passed to `scm_change_object_class ()'. This leads to
  327. ;; nested `scm_change_object_class ()' calls, which increases
  328. ;; the size of HELL and increments N_HELL.
  329. (class-redefinition class
  330. (make-class '() (class-slots class)
  331. #:name (class-name class)))
  332. ;; Use `slot-ref' to trigger the `scm_change_object_class ()'
  333. ;; and `go_to_hell ()' calls.
  334. (slot-ref object 'the-slot)
  335. (next-method))))
  336. ;; Initiate the whole `change-class' chain.
  337. (let* ((class (car classes))
  338. (object (change-class (car objects) class)))
  339. (is-a? object class)))))
  340. (with-test-prefix "object comparison"
  341. (pass-if "default method"
  342. (eval '(begin
  343. (define-class <c> ()
  344. (x #:accessor x #:init-keyword #:x)
  345. (y #:accessor y #:init-keyword #:y))
  346. (define o1 (make <c> #:x '(1) #:y '(2)))
  347. (define o2 (make <c> #:x '(1) #:y '(3)))
  348. (define o3 (make <c> #:x '(4) #:y '(3)))
  349. (define o4 (make <c> #:x '(4) #:y '(3)))
  350. (not (eqv? o1 o2)))
  351. (current-module)))
  352. (pass-if "equal?"
  353. (eval '(begin
  354. (define-method (equal? (a <c>) (b <c>))
  355. (equal? (y a) (y b)))
  356. (equal? o2 o3))
  357. (current-module)))
  358. (pass-if "not equal?"
  359. (eval '(not (equal? o1 o2))
  360. (current-module)))
  361. (pass-if "="
  362. (eval '(begin
  363. (define-method (= (a <c>) (b <c>))
  364. (and (equal? (x a) (x b))
  365. (equal? (y a) (y b))))
  366. (= o3 o4))
  367. (current-module)))
  368. (pass-if "not ="
  369. (eval '(not (= o1 o2))
  370. (current-module)))
  371. )
  372. (use-modules (oop goops active-slot))
  373. (with-test-prefix "active-slot"
  374. (pass-if "defining class with active slot"
  375. (eval '(begin
  376. (define z '())
  377. (define-class <bar> ()
  378. (x #:accessor x
  379. #:init-value 1
  380. #:allocation #:active
  381. #:before-slot-ref
  382. (lambda (o)
  383. (set! z (cons 'before-ref z))
  384. #t)
  385. #:after-slot-ref
  386. (lambda (o)
  387. (set! z (cons 'after-ref z)))
  388. #:before-slot-set!
  389. (lambda (o v)
  390. (set! z (cons* v 'before-set! z)))
  391. #:after-slot-set!
  392. (lambda (o v)
  393. (set! z (cons* v (x o) 'after-set! z))))
  394. #:metaclass <active-class>)
  395. (define bar (make <bar>))
  396. (x bar)
  397. (set! (x bar) 2)
  398. (equal? (reverse z)
  399. '(before-set! 1 before-ref after-ref
  400. after-set! 1 1 before-ref after-ref
  401. before-set! 2 before-ref after-ref after-set! 2 2)))
  402. (current-module))))
  403. (use-modules (oop goops composite-slot))
  404. (with-test-prefix "composite-slot"
  405. (pass-if "creating instance with propagated slot"
  406. (eval '(begin
  407. (define-class <a> ()
  408. (x #:accessor x #:init-keyword #:x)
  409. (y #:accessor y #:init-keyword #:y))
  410. (define-class <c> ()
  411. (o1 #:accessor o1 #:init-form (make <a> #:x 1 #:y 2))
  412. (o2 #:accessor o2 #:init-form (make <a> #:x 3 #:y 4))
  413. (x #:accessor x
  414. #:allocation #:propagated
  415. #:propagate-to '(o1 (o2 y)))
  416. #:metaclass <composite-class>)
  417. (define o (make <c>))
  418. (is-a? o <c>))
  419. (current-module)))
  420. (pass-if "reading propagated slot"
  421. (eval '(= (x o) 1) (current-module)))
  422. (pass-if "writing propagated slot"
  423. (eval '(begin
  424. (set! (x o) 5)
  425. (and (= (x (o1 o)) 5)
  426. (= (y (o1 o)) 2)
  427. (= (x (o2 o)) 3)
  428. (= (y (o2 o)) 5)))
  429. (current-module))))
  430. (with-test-prefix "no-applicable-method"
  431. (pass-if-exception "calling generic, no methods"
  432. exception:no-applicable-method
  433. (eval '(begin
  434. (define-class <qux> ())
  435. (define-generic quxy)
  436. (quxy 1))
  437. (current-module)))
  438. (pass-if "calling generic, one method, applicable"
  439. (eval '(begin
  440. (define-method (quxy (q <qux>))
  441. #t)
  442. (define q (make <qux>))
  443. (quxy q))
  444. (current-module)))
  445. (pass-if-exception "calling generic, one method, not applicable"
  446. exception:no-applicable-method
  447. (eval '(quxy 1)
  448. (current-module))))
  449. (with-test-prefix "foreign slots"
  450. (define-class <foreign-test> ()
  451. (a #:init-keyword #:a #:class <foreign-slot>
  452. #:accessor test-a)
  453. (b #:init-keyword #:b #:init-form 3 #:class <foreign-slot>
  454. #:accessor test-b))
  455. (pass-if-equal "constructing, no initargs"
  456. '(0 3)
  457. (let ((x (make <foreign-test>)))
  458. (list (slot-ref x 'a)
  459. (slot-ref x 'b))))
  460. (pass-if-equal "constructing, initargs"
  461. '(1 2)
  462. (let ((x (make <foreign-test> #:a 1 #:b 2)))
  463. (list (slot-ref x 'a)
  464. (slot-ref x 'b))))
  465. (pass-if-equal "getters"
  466. '(0 3)
  467. (let ((x (make <foreign-test>)))
  468. (list (test-a x) (test-b x))))
  469. (pass-if-equal "setters"
  470. '(10 20)
  471. (let ((x (make <foreign-test>)))
  472. (set! (test-a x) 10)
  473. (set! (test-b x) 20)
  474. (list (test-a x) (test-b x))))
  475. (pass-if-exception "out of range"
  476. exception:out-of-range
  477. (make <foreign-test> #:a (ash 1 64))))
  478. (with-test-prefix "#:each-subclass"
  479. (let* ((<subclass-allocation-test>
  480. (class ()
  481. (test #:init-value '() #:allocation #:each-subclass)
  482. #:name '<subclass-allocation-test>))
  483. (a (make <subclass-allocation-test>)))
  484. (pass-if-equal '() (slot-ref a 'test))
  485. (let ((b (make <subclass-allocation-test>)))
  486. (pass-if-equal '() (slot-ref b 'test))
  487. (slot-set! a 'test 100)
  488. (pass-if-equal 100 (slot-ref a 'test))
  489. (pass-if-equal 100 (slot-ref b 'test))
  490. ;; #:init-value of the class shouldn't reinitialize slot when
  491. ;; instances are allocated.
  492. (make <subclass-allocation-test>)
  493. (pass-if-equal 100 (slot-ref a 'test))
  494. (pass-if-equal 100 (slot-ref b 'test))
  495. (let ((<test-subclass>
  496. (class (<subclass-allocation-test>))))
  497. (pass-if-equal 100 (slot-ref a 'test))
  498. (pass-if-equal 100 (slot-ref b 'test))
  499. (let ((c (make <test-subclass>)))
  500. (pass-if-equal 100 (slot-ref a 'test))
  501. (pass-if-equal 100 (slot-ref b 'test))
  502. (pass-if-equal '() (slot-ref c 'test))
  503. (slot-set! c 'test 200)
  504. (pass-if-equal 200 (slot-ref c 'test))
  505. (make <test-subclass>)
  506. (pass-if-equal 100 (slot-ref a 'test))
  507. (pass-if-equal 100 (slot-ref b 'test))
  508. (pass-if-equal 200 (slot-ref c 'test)))))))
  509. (with-test-prefix "accessor slots"
  510. (let* ((a-accessor (make-accessor 'a))
  511. (b-accessor (make-accessor 'b))
  512. (<a> (class ()
  513. (a #:init-keyword #:a #:accessor a-accessor)
  514. #:name '<a>))
  515. (<b> (class ()
  516. (b #:init-keyword #:b #:accessor b-accessor)
  517. #:name '<b>))
  518. (<ab> (class (<a> <b>) #:name '<ab>))
  519. (<ba> (class (<b> <a>) #:name '<ba>))
  520. (<cab> (class (<ab>)
  521. (a #:init-keyword #:a)
  522. #:name '<cab>))
  523. (<cba> (class (<ba>)
  524. (a #:init-keyword #:a)
  525. #:name '<cba>))
  526. (a (make <a> #:a 'a))
  527. (b (make <b> #:b 'b))
  528. (ab (make <ab> #:a 'a #:b 'b))
  529. (ba (make <ba> #:a 'a #:b 'b))
  530. (cab (make <cab> #:a 'a #:b 'b))
  531. (cba (make <cba> #:a 'a #:b 'b)))
  532. (pass-if-equal "a accessor on a" 'a (a-accessor a))
  533. (pass-if-equal "a accessor on ab" 'a (a-accessor ab))
  534. (pass-if-equal "a accessor on ba" 'a (a-accessor ba))
  535. (pass-if-exception "a accessor on cab" exception:no-applicable-method
  536. (a-accessor cab))
  537. (pass-if-exception "a accessor on cba" exception:no-applicable-method
  538. (a-accessor cba))
  539. (pass-if-equal "b accessor on a" 'b (b-accessor b))
  540. (pass-if-equal "b accessor on ab" 'b (b-accessor ab))
  541. (pass-if-equal "b accessor on ba" 'b (b-accessor ba))
  542. (pass-if-equal "b accessor on cab" 'b (b-accessor cab))
  543. (pass-if-equal "b accessor on cba" 'b (b-accessor cba))))