[Pkg-javascript-commits] [node-expat] 286/371: Move test file, add a reset() call

Jonas Smedegaard dr at jones.dk
Sun Feb 28 10:00:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-expat.

commit a7288c1296f23607e076c73d0e23b55af69e45c5
Author: Lloyd Watkin <lloyd.watkin at surevine.com>
Date:   Mon Nov 24 13:15:27 2014 +0000

    Move test file, add a reset() call
---
 lib/node-expat.js        | 127 ++++++++++++++++++++++++-----------------------
 package.json             |   2 +-
 test.js => test/index.js |  26 +++++-----
 3 files changed, 78 insertions(+), 77 deletions(-)

diff --git a/lib/node-expat.js b/lib/node-expat.js
index 36c469a..260209a 100644
--- a/lib/node-expat.js
+++ b/lib/node-expat.js
@@ -1,105 +1,106 @@
-var EventEmitter = require('events').EventEmitter;
-var util = require('util');
+var EventEmitter = require('events').EventEmitter
+var util = require('util')
 // Only support nodejs v0.6 and on so no need to look for older module location
-var expat = require('bindings')('node_expat');
-var Stream = require('stream').Stream;
+var expat = require('bindings')('node_expat')
+var Stream = require('stream').Stream
 
 var Parser = function(encoding) {
-  this.parser = new expat.Parser(encoding);
-  this.parser.emit = this.emit.bind(this);
+  this.parser = new expat.Parser(encoding)
+  this.parser.emit = this.emit.bind(this)
 
-  //stream API
-  this.writable = true;
-  this.readable = true;
-};
-util.inherits(Parser, Stream);
+  // Stream API
+  this.writable = true
+  this.readable = true
+}
+util.inherits(Parser, Stream)
 
 Parser.prototype.parse = function(buf, isFinal) {
-  return this.parser.parse(buf, isFinal);
-};
+  return this.parser.parse(buf, isFinal)
+}
 
 Parser.prototype.setEncoding = function(encoding) {
-  return this.parser.setEncoding(encoding);
-};
+  return this.parser.setEncoding(encoding)
+}
 
 Parser.prototype.setUnknownEncoding = function(map, convert) {
-  return this.parser.setUnknownEncoding(map, convert);
-};
+  return this.parser.setUnknownEncoding(map, convert)
+}
 
 Parser.prototype.getError = function() {
-  return this.parser.getError();
-};
+  return this.parser.getError()
+}
 Parser.prototype.stop = function() {
-  return this.parser.stop();
-};
+  return this.parser.stop()
+}
 Parser.prototype.pause = function() {
-  return this.stop();
-};
+  return this.stop()
+}
 Parser.prototype.resume = function() {
-  return this.parser.resume();
-};
+  return this.parser.resume()
+}
 
 Parser.prototype.destroy = function() {
-  this.parser.stop();
-  this.end();
-};
+  this.parser.stop()
+  this.end()
+}
 
 Parser.prototype.destroySoon = function() {
-  this.destroy();
-};
+  this.destroy()
+}
 
 Parser.prototype.write = function(data) {
-    var error, result;
+    var error, result
     try {
-	result = this.parse(data);
+	result = this.parse(data)
 	if (!result)
-	    error = this.getError();
+	    error = this.getError()
     } catch (e) {
-	error = e;
+	error = e
     }
     if (error) {
-	this.emit('error', error);
-	this.emit('close');
+	this.emit('error', error)
+	this.emit('close')
     }
-    return result;
-};
+    return result
+}
 
 Parser.prototype.end = function(data) {
-    var error, result;
+    var error, result
     try {
-	result = this.parse(data || "", true);
+	result = this.parse(data || '', true)
 	if (!result)
-	    error = this.getError();
+      error = this.getError()
     } catch (e) {
-	error = e;
+      error = e
     }
 
-    if (!error)
-	this.emit('end');
-    else
-	this.emit('error', error);
-    this.emit('close');
-};
+    if (!error) {
+	  this.emit('end')
+    } else {
+	  this.emit('error', error)
+      this.emit('close')
+    }
+}
 
 Parser.prototype.reset = function() {
-    return this.parser.reset();
-};
+    return this.parser.reset()
+}
 Parser.prototype.getCurrentLineNumber = function() {
-    return this.parser.getCurrentLineNumber();
-};
+    return this.parser.getCurrentLineNumber()
+}
 Parser.prototype.getCurrentColumnNumber = function() {
-    return this.parser.getCurrentColumnNumber();
-};
+    return this.parser.getCurrentColumnNumber()
+}
 Parser.prototype.getCurrentByteIndex = function() {
-    return this.parser.getCurrentByteIndex();
-};
-
-//Exports
+    return this.parser.getCurrentByteIndex()
+}
 
-exports.Parser = Parser;
+exports.Parser = Parser
 
 exports.createParser = function(cb) {
-  var parser = new Parser();
-  if(cb)  { parser.on('startElement', cb); }
-  return parser;
-};
+  var parser = new Parser()
+  if (cb) {
+      parser.on('startElement', cb)
+  }
+  return parser
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index c1d91a8..f98586b 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
     "parsing"
   ],
   "scripts": {
-    "test": "vows --spec ./test.js"
+    "test": "vows --spec ./test/**/*.js"
   },
   "dependencies": {
     "bindings": "~1.2.1",
diff --git a/test.js b/test/index.js
similarity index 96%
rename from test.js
rename to test/index.js
index 9b9a446..4cd1b57 100644
--- a/test.js
+++ b/test/index.js
@@ -1,4 +1,4 @@
-var expat = require('./lib/node-expat');
+var expat = require('../lib/node-expat');
 var Iconv  = require('iconv').Iconv;
 var Buffer = require('buffer').Buffer;
 var vows = require('vows');
@@ -329,19 +329,19 @@ vows.describe('node-expat').addBatch({
 		['text', 'foo & bar'],
 		['endElement', 'e']])
     },
-	'parsing twice the same document with the same parser instance should be fine': 'reset() not yet implemented'
-	/*function() {
-	   var p = new expat.Parser("UTF-8");
-           var xml = "<foo>bar</foo>";
-           var result = p.parse(xml);
-           assert.ok(result);
-           assert.isNull(p.getError());
+	'parsing twice the same document with the same parser instance should be fine': 
+	  function() {
+	   var p = new expat.Parser('UTF-8')
+           var xml = '<foo>bar</foo>'
+           var result = p.parse(xml)
+           assert.ok(result)
+           assert.isNull(p.getError())
+           p.reset()
+           var result2 = p.parse(xml)
+           assert.isNull(p.getError())
+           assert.ok(result2)
 
-           var result2 = p.parse(xml);
-           assert.isNull(p.getError());
-           assert.ok(result2);
-
-        }*/
+        }
     },
     'statistics': {
 	'line number': function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git



More information about the Pkg-javascript-commits mailing list