# HG changeset patch # User Matthew Wild # Date 1307028479 -3600 # Node ID a3cc83281bb83021936c1d4520c28dd21b48edeb # Parent d7524f66562597d54220fd18dd802c20c5e0b799 Add test for parser:stop() diff -r d7524f665625 -r a3cc83281bb8 tests/test.lua --- 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[[Hellohere]]; +assert(not ok) +assert(err == "parsing aborted") +assert(stopped == true, "parser not stopped") + -- test for GC print("\ntesting garbage collection")