[Pkg-javascript-commits] [node-expat] 287/371: Refactor
Jonas Smedegaard
dr at jones.dk
Sun Feb 28 10:00:21 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 1b71c3ee4695e67d90ee95fa05c4923723c126b5
Author: Lloyd Watkin <lloyd.watkin at surevine.com>
Date: Mon Nov 24 13:21:41 2014 +0000
Refactor
---
test/index.js | 111 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 57 insertions(+), 54 deletions(-)
diff --git a/test/index.js b/test/index.js
index 4cd1b57..fd3360d 100644
--- a/test/index.js
+++ b/test/index.js
@@ -345,67 +345,70 @@ vows.describe('node-expat').addBatch({
},
'statistics': {
'line number': function() {
- var p = new expat.Parser();
- assert.equal(p.getCurrentLineNumber(), 1);
- p.parse("\n");
- assert.equal(p.getCurrentLineNumber(), 2);
- p.parse("\n");
- assert.equal(p.getCurrentLineNumber(), 3);
+ var p = new expat.Parser()
+ assert.equal(p.getCurrentLineNumber(), 1)
+ p.parse('\n')
+ assert.equal(p.getCurrentLineNumber(), 2)
+ p.parse('\n')
+ assert.equal(p.getCurrentLineNumber(), 3)
},
'column number': function() {
var p = new expat.Parser();
- assert.equal(p.getCurrentColumnNumber(), 0);
- p.parse(" ");
- assert.equal(p.getCurrentColumnNumber(), 1);
- p.parse(" ");
- assert.equal(p.getCurrentColumnNumber(), 2);
- p.parse("\n");
- assert.equal(p.getCurrentColumnNumber(), 0);
+ assert.equal(p.getCurrentColumnNumber(), 0)
+ p.parse(' ')
+ assert.equal(p.getCurrentColumnNumber(), 1)
+ p.parse(' ')
+ assert.equal(p.getCurrentColumnNumber(), 2)
+ p.parse('\n')
+ assert.equal(p.getCurrentColumnNumber(), 0)
},
'byte index': function() {
- var p = new expat.Parser();
- assert.equal(p.getCurrentByteIndex(), -1);
- p.parse("");
- assert.equal(p.getCurrentByteIndex(), -1);
- p.parse("\n");
- assert.equal(p.getCurrentByteIndex(), 1);
- p.parse(" ");
- assert.equal(p.getCurrentByteIndex(), 2);
+ var p = new expat.Parser()
+ assert.equal(p.getCurrentByteIndex(), -1)
+ p.parse('')
+ assert.equal(p.getCurrentByteIndex(), -1)
+ p.parse('\n')
+ assert.equal(p.getCurrentByteIndex(), 1)
+ p.parse(' ')
+ assert.equal(p.getCurrentByteIndex(), 2)
},
},
'Stream interface': {
- 'read file': {
- topic: function() {
- var p = expat.createParser();
- this.startTags = 0;
- p.on('startElement', function(name) {
- this.startTags++;
- }.bind(this));
- this.endTags = 0;
- p.on('endElement', function(name) {
- this.endTags++;
- }.bind(this));
- p.on('end', function() {
- this.ended = true;
- }.bind(this));
- p.on('close', function() {
- this.closed = true;
- this.callback();
- }.bind(this));
+ 'read file': {
+ topic: function() {
+ var p = expat.createParser()
+ this.startTags = 0
+ p.on('startElement', function(name) {
+ this.startTags++
+ }.bind(this));
+ this.endTags = 0;
+ p.on('endElement', function(name) {
+ this.endTags++
+ }.bind(this));
+ p.on('end', function() {
+ this.ended = true
+ }.bind(this))
+ p.on('close', function() {
+ this.closed = true
+ this.callback()
+ }.bind(this))
+ p.on('error', function(error) {
+ assert.fail('Error', error)
+ }.bind(this))
- var mystic = fs.createReadStream(__dirname + '/test-mystic-library.xml');
- mystic.pipe(p);
- },
- 'startElement and endElement events': function() {
- assert.ok(this.startTags > 0, 'startElement events at all');
- assert.ok(this.startTags == this.endTags, 'equal amount');
- },
- 'end event': function() {
- assert.ok(this.ended, 'emit end event');
- },
- 'close event': function() {
- assert.ok(this.closed, 'emit close event');
- }
- }
+ var mystic = fs.createReadStream(__dirname + '/../test-mystic-library.xml')
+ mystic.pipe(p)
+ },
+ 'startElement and endElement events': function() {
+ assert.ok(this.startTags > 0, 'startElement events at all')
+ assert.ok(this.startTags == this.endTags, 'equal amount')
+ },
+ 'end event': function() {
+ assert.ok(this.ended, 'emit end event')
+ },
+ 'close event': function() {
+ assert.ok(this.closed, 'emit close event')
+ }
+ }
}
-}).export(module);
+}).export(module)
--
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