factor/basis/xmode/utilities/utilities-tests.factor

53 lines
1.1 KiB
Factor
Raw Normal View History

2008-03-01 17:00:45 -05:00
IN: xmode.utilities.tests
USING: accessors xmode.utilities tools.test xml xml.data kernel
strings vectors sequences io.files prettyprint assocs
unicode.case ;
2007-12-10 02:20:36 -05:00
[ "hi" 3 ] [
{ 1 2 3 4 5 6 7 8 } [ H{ { 3 "hi" } } at ] map-find
] unit-test
[ f f ] [
{ 1 2 3 4 5 6 7 8 } [ H{ { 11 "hi" } } at ] map-find
] unit-test
TUPLE: company employees type ;
: <company> V{ } clone f company boa ;
: add-employee employees>> push ;
<TAGS: parse-employee-tag
TUPLE: employee name description ;
TAG: employee
employee new
{ { "name" f (>>name) } { f (>>description) } }
init-from-tag swap add-employee ;
TAGS>
\ parse-employee-tag see
: parse-company-tag
[
<company>
{ { "type" >upper (>>type) } }
init-from-tag dup
] keep
children>> [ tag? ] filter
2008-01-09 17:36:30 -05:00
[ parse-employee-tag ] with each ;
[
T{ company f
V{
T{ employee f "Joe" "VP Sales" }
T{ employee f "Jane" "CFO" }
}
"PUBLIC"
}
] [
2008-09-04 21:11:28 -04:00
"resource:basis/xmode/utilities/test.xml"
file>xml parse-company-tag
] unit-test