Thu, 02 Jun 2011 16:27:59 +0100
Add test for parser:stop()
tests/test.lua | file | annotate | diff | comparison | revisions |
--- a/tests/test.lua Thu Jun 02 16:21:30 2011 +0100 +++ b/tests/test.lua Thu Jun 02 16:27:59 2011 +0100 @@ -291,6 +291,24 @@ local status, err = pcall(p.close, p) assert(not status and string.find(err, "error closing parser")) +-- closing unfinished document +print("testing parser:stop()"); +local stopped; +p = lxp.new{ + StartElement = function (parser, name, attr) + if name == "stop" then + parser:stop() + stopped = true + else + stopped = false + end + end +} +local ok, err = p:parse[[<root><parseme>Hello</parseme><stop>here</stop><notparsed/></root>]]; +assert(not ok) +assert(err == "parsing aborted") +assert(stopped == true, "parser not stopped") + -- test for GC print("\ntesting garbage collection")