]> gitweb.factorcode.org Git - factor.git/blob - basis/xmode/utilities/utilities-tests.factor
Adding map-find to core
[factor.git] / basis / xmode / utilities / utilities-tests.factor
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
6 TUPLE: company employees type ;
7
8 : <company> V{ } clone f company boa ;
9
10 : add-employee employees>> push ;
11
12 <TAGS: parse-employee-tag
13
14 TUPLE: employee name description ;
15
16 TAG: employee
17     employee new
18     { { "name" f (>>name) } { f (>>description) } }
19     init-from-tag swap add-employee ;
20
21 TAGS>
22
23 \ parse-employee-tag see
24
25 : parse-company-tag
26     [
27         <company>
28         { { "type" >upper (>>type) } }
29         init-from-tag dup
30     ] keep
31     children>> [ tag? ] filter
32     [ parse-employee-tag ] with each ;
33
34 [
35     T{ company f
36         V{
37             T{ employee f "Joe" "VP Sales" }
38             T{ employee f "Jane" "CFO" }
39         }
40         "PUBLIC"
41     }
42 ] [
43     "vocab:xmode/utilities/test.xml"
44     file>xml parse-company-tag
45 ] unit-test