]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/tangle/tangle-tests.factor
tools.test: Make the flag public. Finish porting tester changes to fuzzer.
[factor.git] / unmaintained / tangle / tangle-tests.factor
1 USING: accessors arrays continuations db db.sqlite io.files kernel semantic-db sequences tangle tangle.html tangle.menu tangle.page tangle.path tools.test tools.walker tuple-syntax ;
2 IN: tangle.tests
3
4 : db-path "tangle-test.db" temp-file ;
5 : test-db db-path sqlite-db ;
6 : delete-db db-path ?delete-file ;
7
8 : test-tangle ( -- )
9     ensure-root "foo" create-file "bar" create-file "pluck_eggs" create-file
10     "How to Pluck Eggs" create-node swap has-filename
11     "Main Menu" ensure-menu "home" create-node swap subitem-of ;
12
13 test-db [
14     init-semantic-db test-tangle
15     [ "pluck_eggs" ] [ { "foo" "bar" "pluck_eggs" } path>node [ node-content ] when* ] unit-test
16     [ "How to Pluck Eggs" ] [ { "foo" "bar" "pluck_eggs" } path>node [ has-filename-subjects first node-content ] when* ] unit-test
17     [ { "foo" "bar" "pluck_eggs" } ] [ { "foo" "bar" "pluck_eggs" } path>node node>path >array ] unit-test
18     [ f ] [ TUPLE{ node id: 666 content: "some content" } parent-directory ] unit-test
19     [ f ] [ TUPLE{ node id: 666 content: "some content" } node>path ] unit-test
20     [ "Main Menu" ] [ "Main Menu" ensure-menu node-content ] unit-test
21     [ t ] [ "Main Menu" ensure-menu "Main Menu" ensure-menu node= ] unit-test
22     [ "Main Menu" { "home" } ] [ "Main Menu" load-menu dup node>> node-content swap children>> [ node>> node-content ] map >array ] unit-test
23     [ { "home" } ] [ "Main Menu" load-menu menu>ulist items>> [ node>> node-content ] map >array ] unit-test
24     [ f ] [ TUPLE{ node id: 666 content: "node text" } node>path ] unit-test
25     [ "node text" ] [ TUPLE{ node id: 666 content: "node text" } >html ] unit-test
26 ] with-db delete-db