Elegant way to tests an XMLElement's "string"`
Posted by
tty on
Apr 08, 2020; 3:01pm
URL: https://forum.world.st/Elegant-way-to-tests-an-XMLElement-s-string-tp5114676.html
Hi folks,
I am writing SUnit tests for my PEG grammar and I am not fluent in Streams.
I have my first test that checks the structure of an HTML UnorderedList.
The output of the parse run is an XMLElement.
*testListUnordered
<timeout: 10>
| xmlElement actor ios|
actor := PEGWikiMediaGeneratorTables new.
actor transcripton: false.
xmlElement := parser parse: 'UnorderedList' stream: (self listUnordered)
reading actor: actor.
ios := ReadWriteStream on:''.
xmlElement printOn: ios.
self assert: ((ios contents) = '<ul><li> one</li><ul><li> two</li><ul><li>
three</li><ul><li> four</li><li> four</li><ul><li> five</li><li>
five</li><li> five</li></ul><li> four</li><li> four</li></ul><li>
three</li><li> three</li></ul><li> two</li></ul></ul>') .
*
Is there a simpler way, minus the Stream to get the "contents" of the
XMLElement?
thanks in advance.
--
Sent from:
http://forum.world.st/Squeak-Beginners-f107673.html_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners