]> gitweb.factorcode.org Git - factor.git/blob - basis/xmode/utilities/utilities-tests.factor
Fix permission bits
[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 [ "hi" 3 ] [
6     { 1 2 3 4 5 6 7 8 } [ H{ { 3 "hi" } } at ] map-find
7 ] unit-test
8
9 [ f f ] [
10     { 1 2 3 4 5 6 7 8 } [ H{ { 11 "hi" } } at ] map-find
11 ] unit-test
12
13 TUPLE: company employees type ;
14
15 : <company> V{ } clone f company boa ;
16
17 : add-employee employees>> push ;
18
19 <TAGS: parse-employee-tag
20
21 TUPLE: employee name description ;
22
23 TAG: employee
24     employee new
25     { { "name" f (>>name) } { f (>>description) } }
26     init-from-tag swap add-employee ;
27
28 TAGS>
29
30 \ parse-employee-tag see
31
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 ;
40
41 [
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