xml.traversal: tags-with-attr fix
parent
e68602287c
commit
3806f02111
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2005, 2009 Daniel Ehrenberg
|
! Copyright (C) 2005, 2009 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: xml xml.traversal tools.test xml.data sequences ;
|
USING: xml xml.traversal tools.test xml.data sequences arrays ;
|
||||||
IN: xml.traversal.tests
|
IN: xml.traversal.tests
|
||||||
|
|
||||||
[ "bar" ] [ "<foo>bar</foo>" string>xml children>string ] unit-test
|
[ "bar" ] [ "<foo>bar</foo>" string>xml children>string ] unit-test
|
||||||
|
@ -16,3 +16,6 @@ IN: xml.traversal.tests
|
||||||
[ "blah" ] [ "<foo attr='blah'/>" string>xml "foo" deep-tag-named "attr" attr ] unit-test
|
[ "blah" ] [ "<foo attr='blah'/>" string>xml "foo" deep-tag-named "attr" attr ] unit-test
|
||||||
|
|
||||||
[ { "blah" } ] [ "<foo attr='blah'/>" string>xml "foo" deep-tags-named [ "attr" attr ] map ] unit-test
|
[ { "blah" } ] [ "<foo attr='blah'/>" string>xml "foo" deep-tags-named [ "attr" attr ] map ] unit-test
|
||||||
|
|
||||||
|
[ { "blah" } ] [ "<foo><bar attr='blah'/></foo>" string>xml "blah" "attr" tags-with-attr [ "attr" attr ] map ] unit-test
|
||||||
|
[ { "blah" } ] [ "bar" { { "attr" "blah" } } f <tag> 1array "blah" "attr" tags-with-attr [ "attr" attr ] map ] unit-test
|
||||||
|
|
|
@ -50,7 +50,7 @@ PRIVATE>
|
||||||
assure-name '[ _ _ tag-with-attr? ] find nip ;
|
assure-name '[ _ _ tag-with-attr? ] find nip ;
|
||||||
|
|
||||||
: tags-with-attr ( tag attr-value attr-name -- tags-seq )
|
: tags-with-attr ( tag attr-value attr-name -- tags-seq )
|
||||||
assure-name '[ _ _ tag-with-attr? ] filter children>> ;
|
assure-name '[ _ _ tag-with-attr? ] { } filter-as ;
|
||||||
|
|
||||||
: deep-tag-with-attr ( tag attr-value attr-name -- matching-tag )
|
: deep-tag-with-attr ( tag attr-value attr-name -- matching-tag )
|
||||||
assure-name '[ _ _ tag-with-attr? ] deep-find ;
|
assure-name '[ _ _ tag-with-attr? ] deep-find ;
|
||||||
|
|
Loading…
Reference in New Issue