1 USING: accessors arrays continuations db db.sqlite db.tuples io.files
2 kernel math namespaces semantic-db sequences sorting tools.test
8 : db-path "semantic-db-test.db" temp-file ;
9 : test-db db-path sqlite-db ;
10 : delete-db [ db-path delete-file ] ignore-errors ;
15 node create-table arc create-table
16 [ 1 ] [ "first node" create-node id>> ] unit-test
17 [ 2 ] [ "second node" create-node id>> ] unit-test
18 [ 3 ] [ "third node" create-node id>> ] unit-test
19 [ 4 ] [ f create-node id>> ] unit-test
20 [ ] [ 1 f <node> 2 f <node> 3 f <node> create-arc ] unit-test
21 [ { 1 2 3 4 } ] [ all-node-ids ] unit-test
26 "test content" create-context context set
27 [ T{ node f 3 "test content" } ] [ context get ] unit-test
28 [ T{ node f 4 "is test content" } ] [ "is test content" context get create-relation ] unit-test
29 [ T{ node f 4 "is test content" } ] [ "is test content" context get get-relation ] unit-test
30 [ T{ node f 4 "is test content" } ] [ "is test content" context get ensure-relation ] unit-test
31 [ T{ node f 5 "has parent" } ] [ "has parent" context get ensure-relation ] unit-test
32 [ T{ node f 5 "has parent" } ] [ "has parent" context get ensure-relation ] unit-test
33 [ "has parent" ] [ "has parent" context get ensure-relation node-content ] unit-test
34 [ "test content" ] [ context get node-content ] unit-test
37 ! "test1" "test1-relation-id-word" f f f f <relation-definition> define-relation
38 ! "test2" t t t t t <relation-definition> define-relation
42 ! [ T{ node f 3 "test1" } ] [ test1-relation-id-word ] unit-test
43 ! [ T{ node f 4 "test2" } ] [ test2-relation ] unit-test
44 [ T{ node f 4 "test3" } ] [ test3-relation ] unit-test
51 "adam" create-node "adam" set
52 "eve" create-node "eve" set
53 "bob" create-node "bob" set
54 "fran" create-node "fran" set
55 "charlie" create-node "charlie" set
56 "gertrude" create-node "gertrude" set
57 [ ] [ "bob" get "adam" get has-parent ] unit-test
58 { { "bob" "eve" } { "fran" "eve" } { "gertrude" "bob" } { "fran" "bob" } { "charlie" "fran" } } [ first2 [ get ] bi@ has-parent ] each
59 [ { "bob" "fran" } ] [ "eve" get has-parent-relation children [ node-content ] map ] unit-test
60 [ { "adam" "eve" } ] [ "bob" get has-parent-relation parents [ node-content ] map ] unit-test
61 [ "fran" { "charlie" } ] [ "fran" get has-parent-relation get-node-tree-s dup node>> node-content swap children>> [ node>> node-content ] map ] unit-test
62 [ { "adam" "eve" } ] [ "charlie" get has-parent-relation get-root-nodes [ node-content ] map natural-sort >array ] unit-test
63 [ { } ] [ "charlie" get dup "fran" get !has-parent has-parent-relation parents [ node-content ] map ] unit-test
64 [ { "adam" "eve" } ] [ has-parent-relation ultimate-objects node-results [ node-content ] map ] unit-test
65 [ { "fran" "gertrude" } ] [ has-parent-relation ultimate-subjects node-results [ node-content ] map ] unit-test