| 1 | (in-package :lol-test) |
| 2 | |
| 3 | (in-suite lisp-on-lines) |
| 4 | |
| 5 | (deftest test-attribute-value () |
| 6 | (eval |
| 7 | '(progn |
| 8 | (define-description attribute-test-2 () |
| 9 | ((attribute-1 :value "VALUE") |
| 10 | (attribute-2 :function (constantly "VALUE")))) |
| 11 | |
| 12 | (deflayer attribute-test) |
| 13 | |
| 14 | (define-description attribute-test-2 () |
| 15 | ((attribute-1 :value "VALUE2") |
| 16 | (attribute-2 :function (constantly "VALUE2"))) |
| 17 | (:in-layer . attribute-test)))) |
| 18 | |
| 19 | (let ((d (find-description 'attribute-test-2))) |
| 20 | |
| 21 | (is (equalp "VALUE" (slot-value (find-attribute d 'attribute-1) 'lol::value))) |
| 22 | |
| 23 | |
| 24 | (with-active-layers (attribute-test) |
| 25 | (is (equalp (attribute-value nil (find-attribute d 'attribute-1)) |
| 26 | (attribute-value nil (find-attribute d 'attribute-2)))) |
| 27 | (is (equalp "VALUE2" (attribute-value nil (find-attribute d 'attribute-1))))))) |
| 28 | |
| 29 | (deftest test-attribute-property-inheriting () |
| 30 | (test-attribute-value) |
| 31 | (eval '(progn |
| 32 | (deflayer attribute-property-test) |
| 33 | (define-description attribute-test-2 () |
| 34 | ((attribute-1 :label "attribute1") |
| 35 | (attribute-2 :label "attribute2")) |
| 36 | (:in-layer . attribute-property-test)))) |
| 37 | |
| 38 | (with-active-layers (attribute-property-test) |
| 39 | (let ((d (find-description 'attribute-test-2))) |
| 40 | |
| 41 | (is (equalp "VALUE" (slot-value (find-attribute d 'attribute-1) 'lol::value))) |
| 42 | |
| 43 | (is (equalp "attribute1" (attribute-label (find-attribute d 'attribute-1)))) |
| 44 | (is (equalp "attribute2" (attribute-label (find-attribute d 'attribute-2)))) |
| 45 | |
| 46 | |
| 47 | (with-active-layers (attribute-test) |
| 48 | (is (equalp (attribute-value nil (find-attribute d 'attribute-1)) |
| 49 | (attribute-value nil (find-attribute d 'attribute-2)))) |
| 50 | (is (equalp "VALUE2" (attribute-value nil (find-attribute d 'attribute-1)))))))) |
| 51 | |
| 52 | |
| 53 | |
| 54 | |