[Newbies] Elegant way to tests an XMLElement's "string"`
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Apr 18 13:10:36 UTC 2020
Not actually sure what your problem is, but are you aware of String class >> #streamContents:? :-)
io := String streamContents: [:ios |
xmlElement printOn: ios].
Provided that XMLElement follows the usual conventions, you should also be able to simply say
io := xmlElement printString.
Hope that helps :-)
Best,
Christoph
________________________________
Von: Beginners <beginners-bounces at lists.squeakfoundation.org> im Auftrag von tty <gettimothy at zoho.com>
Gesendet: Mittwoch, 8. April 2020 17:01 Uhr
An: beginners at lists.squeakfoundation.org
Betreff: [Newbies] Elegant way to tests an XMLElement's "string"`
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
Beginners at lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20200418/14703e16/attachment.html>
More information about the Beginners
mailing list