1 USING: accessors assocs combinators combinators.smart
2 continuations fry generalizations io.pathnames kernel macros
3 sequences stack-checker tools.test xml xml.traversal xml.writer
7 TUPLE: xml-test id uri sections description type ;
9 : >xml-test ( tag -- test )
11 [ "TYPE" attr >>type ]
14 [ "SECTIONS" attr >>sections ]
15 [ children>> xml>string >>description ]
18 : parse-tests ( xml -- tests )
19 "TEST" tags-named [ >xml-test ] map ;
21 CONSTANT: base "vocab:xml/tests/xmltest/"
23 : fails? ( quot -- ? )
24 [ drop-outputs f ] [ nip drop-inputs t ] bi-curry recover ; inline
26 : well-formed? ( uri -- answer )
27 [ file>xml ] fails? "not-wf" "valid" ? ;
29 : test-quots ( test -- result quot )
31 [ '[ _ uri>> base swap append-path well-formed? ] ] bi ;
33 : xml-tests ( -- tests )
34 base "xmltest.xml" append-path file>xml
35 parse-tests [ test-quots 2array ] map ;
37 : run-xml-tests ( -- )
38 xml-tests [ unit-test ] assoc-each ;
40 : works? ( result quot -- ? )
41 [ first ] [ call( -- result ) ] bi* = ;
43 : partition-xml-tests ( -- successes failures )
44 xml-tests [ first2 works? ] partition ;
46 : failing-valids ( -- tests )
47 partition-xml-tests nip [ second first ] map [ type>> "valid" = ] filter ;
49 [ ] [ partition-xml-tests 2drop ] unit-test