|
5 | 5 |
|
6 | 6 | (describe "Elsa reader"
|
7 | 7 |
|
| 8 | + (describe "helpers" |
| 9 | + |
| 10 | + (describe "elsa-locate-dominating-form" |
| 11 | + |
| 12 | + (it "should look up first form with given name in the parent hierarchy" |
| 13 | + (elsa-test-with-read-form "|(progn (prog1 (when (foo))))" form |
| 14 | + (let ((foo-form (elsa-cadr (elsa-cadr (elsa-cadr form))))) |
| 15 | + (expect (elsa-locate-dominating-form foo-form 'progn) |
| 16 | + :to-be form)))) |
| 17 | + |
| 18 | + (it "should return nil if no form with name exists in the hierarchy" |
| 19 | + (elsa-test-with-read-form "|(progn (prog1 (when (foo))))" form |
| 20 | + (let ((foo-form (elsa-cadr (elsa-cadr (elsa-cadr form))))) |
| 21 | + (expect (elsa-locate-dominating-form foo-form 'let) |
| 22 | + :to-be nil)))) |
| 23 | + |
| 24 | + (it "should return itself if its name is name" |
| 25 | + (elsa-test-with-read-form "|(progn (prog1 (when (foo))))" form |
| 26 | + (let ((foo-form (elsa-cadr (elsa-cadr (elsa-cadr form))))) |
| 27 | + (expect (elsa-locate-dominating-form foo-form 'foo) |
| 28 | + :to-be foo-form)))) |
| 29 | + |
| 30 | + (it "should work with a list of names" |
| 31 | + (elsa-test-with-read-form "|(progn (prog1 (when (foo))))" form |
| 32 | + (let ((foo-form (elsa-cadr (elsa-cadr (elsa-cadr form)))) |
| 33 | + (when-form (elsa-cadr (elsa-cadr form)))) |
| 34 | + (expect (elsa-locate-dominating-form foo-form '(when progn)) |
| 35 | + :to-be when-form))))) |
| 36 | + |
| 37 | + (describe "elsa-form-find-child" |
| 38 | + |
| 39 | + (it "should find a child form matching a predicate" |
| 40 | + (elsa-test-with-analysed-form "(progn (foo) (bar))" form |
| 41 | + (let ((foo-form (elsa-cadr form))) |
| 42 | + (expect (elsa-form-find-child form |
| 43 | + (lambda (f) (eq (elsa-get-name f) 'foo))) |
| 44 | + :to-be foo-form)))) |
| 45 | + |
| 46 | + (it "should return nil if no child form matches the predicate" |
| 47 | + (elsa-test-with-analysed-form "(progn (foo) (bar))" form |
| 48 | + (expect (elsa-form-find-child form |
| 49 | + (lambda (f) (eq (elsa-get-name f) 'baz))) |
| 50 | + :to-be nil))))) |
| 51 | + |
8 | 52 | (describe "symbols"
|
9 | 53 |
|
10 | 54 | (it "should read a symbol"
|
|
0 commit comments