fix some db docs
[factor/jcg.git] / basis / xmode / utilities / utilities-tests.factor
blob45238ca2b18bcf1e0688b52f21c88f9b1211873a
1 IN: xmode.utilities.tests
2 USING: accessors xmode.utilities tools.test xml xml.data kernel
3 strings vectors sequences io.files prettyprint assocs
4 unicode.case ;
5 [ "hi" 3 ] [
6     { 1 2 3 4 5 6 7 8 } [ H{ { 3 "hi" } } at ] map-find
7 ] unit-test
9 [ f f ] [
10     { 1 2 3 4 5 6 7 8 } [ H{ { 11 "hi" } } at ] map-find
11 ] unit-test
13 TUPLE: company employees type ;
15 : <company> V{ } clone f company boa ;
17 : add-employee employees>> push ;
19 <TAGS: parse-employee-tag
21 TUPLE: employee name description ;
23 TAG: employee
24     employee new
25     { { "name" f (>>name) } { f (>>description) } }
26     init-from-tag swap add-employee ;
28 TAGS>
30 \ parse-employee-tag see
32 : parse-company-tag
33     [
34         <company>
35         { { "type" >upper (>>type) } }
36         init-from-tag dup
37     ] keep
38     children>> [ tag? ] filter
39     [ parse-employee-tag ] with each ;
42     T{ company f
43         V{
44             T{ employee f "Joe" "VP Sales" }
45             T{ employee f "Jane" "CFO" }
46         }
47         "PUBLIC"
48     }
49 ] [
50     "resource:basis/xmode/utilities/test.xml"
51     file>xml parse-company-tag
52 ] unit-test