node-expat
Advanced tools
Comparing version 1.4.5 to 1.5.0
@@ -43,2 +43,5 @@ var EventEmitter = require('events').EventEmitter; | ||
}; | ||
exports.Parser.prototype.reset = function() { | ||
return this.parser.reset(); | ||
}; | ||
exports.Parser.prototype.getCurrentLineNumber = function() { | ||
@@ -45,0 +48,0 @@ return this.parser.getCurrentLineNumber(); |
{ "name": "node-expat" | ||
,"version": "1.4.5" | ||
,"version": "1.5.0" | ||
,"main": "./lib/node-expat" | ||
@@ -21,5 +21,5 @@ ,"description": "NodeJS binding for fast XML parsing." | ||
} | ||
,"contributors": ["Stephan Maka", "Derek Hammer", "Iein Valdez", "Peter Körner", "Camilo Aguilar", "Michael Weibel"] | ||
,"contributors": ["Stephan Maka", "Derek Hammer", "Iein Valdez", "Peter Körner", "Camilo Aguilar", "Michael Weibel", "Alexey Zhuchkov", "Satyam Shekhar"] | ||
,"licenses": [{ "type": "MIT" }] | ||
,"engines": { "node": ">=0.4" } | ||
} |
34
test.js
@@ -25,5 +25,9 @@ var expat = require('./lib/node-expat'); | ||
function expect(s, evs_expected) { | ||
for(var step = s.length; step > 0; step--) { | ||
for(var step = s.length; step > 0; step--) { | ||
expectWithParserAndStep(s, evs_expected, new expat.Parser("UTF-8"), step); | ||
} | ||
} | ||
function expectWithParserAndStep(s, evs_expected, p, step) { | ||
var evs_received = []; | ||
var p = new expat.Parser("UTF-8"); | ||
//p.setEncoding("UTF-8"); | ||
@@ -70,3 +74,2 @@ p.addListener('startElement', function(name, attrs) { | ||
assert.equal(received, expected); | ||
} | ||
} | ||
@@ -175,2 +178,23 @@ | ||
}, | ||
'reset': { | ||
'complete doc without error': function() { | ||
var p = new expat.Parser("UTF-8"); | ||
expectWithParserAndStep("<start><first /><second>text</second></start>", [['startElement', 'start', {}], ['startElement', 'first', {}], ['endElement', 'first'], ['startElement', 'second', {}], ['text', "text"], ['endElement', 'second'], ['endElement', 'start']], p, 1000); | ||
p.reset(); | ||
expectWithParserAndStep("<restart><third>moretext</third><fourth /></restart>", [['startElement', 'restart', {}], ['startElement', 'third', {}], ['text', "moretext"], ['endElement', 'third'], ['startElement', 'fourth', {}], ['endElement', 'fourth'], ['endElement', 'restart']], p, 1000); | ||
}, | ||
'incomplete doc without error': function() { | ||
var p = new expat.Parser("UTF-8"); | ||
expectWithParserAndStep("<start><first /><second>text</second>", [['startElement', 'start', {}], ['startElement', 'first', {}], ['endElement', 'first'], ['startElement', 'second', {}], ['text', "text"], ['endElement', 'second']], p, 1000); | ||
p.reset(); | ||
expectWithParserAndStep("<restart><third>moretext</third><fourth /></restart>", [['startElement', 'restart', {}], ['startElement', 'third', {}], ['text', "moretext"], ['endElement', 'third'], ['startElement', 'fourth', {}], ['endElement', 'fourth'], ['endElement', 'restart']], p, 1000); | ||
}, | ||
'with doc error': function() { | ||
var p = new expat.Parser("UTF-8"); | ||
expectWithParserAndStep("</end>", [["error"]], p, 1000); | ||
p.reset(); | ||
expectWithParserAndStep("<restart><third>moretext</third><fourth /></restart>", [['startElement', 'restart', {}], ['startElement', 'third', {}], ['text', "moretext"], ['endElement', 'third'], ['startElement', 'fourth', {}], ['endElement', 'fourth'], ['endElement', 'restart']], p, 1000); | ||
} | ||
}, | ||
'stop and resume': { | ||
@@ -240,4 +264,4 @@ topic: function() { | ||
assert.ok(true, "Did not segfault"); | ||
}, | ||
}, | ||
'parsing twice the same document with the same parser instance should be fine': 'reset() not yet implemented' | ||
@@ -244,0 +268,0 @@ /*function() { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29315
393