Node.js ç¨ã®ãã¹ãã£ã³ã°ãã¬ã¼ã ã¯ã¼ã¯ Vows ãã® 3
æ¨æ¥ã®ã¨ã³ããªããã® 2ã㧠ReadableStream
ããã® 'data'
ã¤ãã³ããè¡åä½ã«ã³ã¼ã«ããã¯ãã¦ããã read-line ã¢ã¸ã¥ã¼ã«ãä½æãï¼EventEmitter
ã使ã£ã¦æ¬ä¼¼çã«ã¤ãã³ããçºçããããã¹ãã Vows ã使ã£ã¦æ¸ãã¾ããï¼
ä»åã¯ãã®ç¶ãã¨ãã¦ï¼æ¬ç©ã®ãã¡ã¤ã«ã使ã£ããã¹ãã追å ãã¾ãï¼
ãã¡ã¤ã«ãæ±ãã«ã¯ Node.js æ¨æºã®ãã¡ã¤ã«ã·ã¹ãã ã¢ã¸ã¥ã¼ã«ã使ãã¾ãï¼
ä»åã¯ãã¡ã¤ã«ãã¹ããªã¼ã ã¨ãã¦èªã¿è¾¼ãã®ã§ï¼ãfs.ReadStreamãã使ãã¾ãï¼
ãã® fs.createReadStream(path)
ãå¼ã³åºã㨠ReadableStream
ãè¿ã£ã¦ãã¾ãï¼(ãã㯠EventEmitter
ã§ãããã¾ã)ï¼ããã¤ã read-line ã«æ¸¡ãã°ããã ãã§ããï¼
ã§ãã§ãï¼æ¬ä¼¼çãªãã¹ãã§ä½¿ã£ãèªåã® EventEmitter
ã¨éãï¼ReadableStream
ã«å¯¾ã㦠emit()
ãå¼ã³åºãããã«ã¯ããã¾ããï¼å®éã« ReadableStream
ããã®èªã¿è¾¼ã¿ãçµäºãã¦ï¼è¡ãã¨ã®é
åãå®æããã¾ã§ã¯ vow ã§æ¤è¨¼ãããã¨ãã§ããªãã®ã§ãï¼ã©ããããï¼
ããã§ããã® 1ãã§ç´¹ä»ããããããã¹ãã使ã£ã¦ã¿ã¾ãããï¼
ãããã¹ã使ãã®ã¯ç°¡åã§ï¼ãããã¯ã§ (ã¾ããã¦ãï¼) EventEmitter
ãä½ã£ã¦è¿ãã°ããã ãã§ãï¼ãã㦠ReadableStream
ãã¯ãã¼ãºããããããã¹ (EventEmitter
ã®ãã¨ã§ã) ã«ã¤ãã³ããçæãã¦ãããã° vow ãå¼ã³åºããã¦æ¤è¨¼ãè¡ããã¾ãï¼
ä¸ã¤ãã¤é çªã«ããã¾ãããï¼
ã¾ãã¯ãã¹ãç¨ã®ãã¡ã¤ã«ãç¨æãã¾ã (test1.txt
)ï¼
abc
ãã¡ã¤ã«ã·ã¹ãã ã¢ã¸ã¥ã¼ã«ã使ãã®ã§ï¼
-var vows = require('vows'), assert = require('assert'), events = require('events'); +var vows = require('vows'), assert = require('assert'), events = require('events'), fs = require('fs'); var read_line = require('./read-line');
ãå¿
è¦ã§ãï¼
ããã® 2ãã§ä½æããï¼EventEmitter
ãå½ã®ã¹ããªã¼ã ã¨ãã¦æ±ãã³ã³ããã¹ãã¨ã¯å¥ã«ï¼æ¬å½ã®ãã¡ã¤ã«ã使ã£ããã¹ãç¨ã®ã³ã³ããã¹ããç¨æãã¾ãï¼
} } } + }, + 'å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã' : { + '1è¡ã®ãã¡ã¤ã«ã®å ´å' : { + + } } }).export(module);
åã®ã³ã³ããã¹ãã®ãããã¯ã¨ vow ã¯ã¤ã¡ã¼ã¸ããããã®ã§å ã«ä½æãã¾ãï¼
}, 'å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã' : { '1è¡ã®ãã¡ã¤ã«ã®å ´å' : { - + topic : function(topic) { + return topic('test1.txt'); + }, + '1åã ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { + assert.length(topic, 1); + }, + 'è¡å ¨ä½ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { + assert.equal(topic[0], 'abc'); + } } } }).export(module);
ãã®åã³ã³ããã¹ãã®ãããã¯ãè¿ãã®ããããã¹ã§ãï¼ã¤ã¾ãï¼è¦ªã³ã³ããã¹ãã®ãããã¯ãè¿ãé¢æ°ã®æ»ãå¤ããããã¹ã§ãã£ã¦æ¬²ããã¨ãããã¨ã«ãªãã¾ãï¼
ãããªãã㧠(ã©ããªããã§ï¼)ï¼è¦ªã³ã³ããã¹ãã®ãããã¯ã¯ãããªãã¯ãã§ãï¼
} }, 'å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã' : { + topic : function() { + return function(fileName) { + var promise = new (events.EventEmitter); + + return promise; + }; + }, '1è¡ã®ãã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test1.txt');
ããã¦ãã®ä¸ã§ fs.createReadStream(path)
ãå¼ã³åºãã¦ï¼ããã read-line ã® onDataByLine()
ã«æ¸¡ãã¾ãï¼
topic : function() { return function(fileName) { var promise = new (events.EventEmitter); + var stream = fs.createReadStream(fileName); + stream.setEncoding('utf-8'); + read_line.onDataByLine(stream, function(line) { + }); return promise; }; },
ã¡ãªã¿ã« ReadableStream
ããæååãèªã¿è¾¼ãã«ã¯ setEncoding()
ãã¦ãããªãã¨ããã¾ããï¼
read-line ããã³ã¼ã«ããã¯ããããæååãé åã«è²¯ãè¾¼ã¿ã¾ãï¼
'å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã' : { topic : function() { return function(fileName) { + var lines = []; var promise = new (events.EventEmitter); var stream = fs.createReadStream(fileName); stream.setEncoding('utf-8'); read_line.onDataByLine(stream, function(line) { - + lines.push(line); }); return promise; };
ãã¡ã¤ã«ãã¯ãã¼ãºããã¤ãã³ããåãåããªãã¦ã¯ããã¾ããï¼
read_line.onDataByLine(stream, function(line) { lines.push(line); }); + stream.on('end', function() { + + }); return promise; }; },
ãã¡ã¤ã«ãã¯ãã¼ãºãããªããããã¹ã«éç¥ã㦠vow ãå¼ã³åºãããããã«ãã¾ãï¼
lines.push(line); }); stream.on('end', function() { - + promise.emit('success', lines); }); return promise; };
ã¾ã¨ããã¨ï¼è¦ªã³ã³ããã¹ãã®ãããã¯ã¯ãããªãã¾ããï¼
topic : function() { return function(fileName) { var lines = []; var promise = new (events.EventEmitter); var stream = fs.createReadStream(fileName); stream.setEncoding('utf-8'); read_line.onDataByLine(stream, function(line) { lines.push(line); }); stream.on('end', function() { promise.emit('success', lines); }); return promise; }; },
æ¡å¤ã·ã³ãã«ã§ããï¼éåæã¤ãã³ããæ±ããã¹ãã£ã¦å¤§å¤ãããªã¤ã¡ã¼ã¸ã§ãããï¼ãããªãæããªãããï¼
å®è¡ãã¾ãï¼
$ vows read-line-test.js ······························· ✓ OK » 31 honored (0.007s)
ãã¹ããã¼ã¿ãå¢ããã¦ã¿ã¾ãï¼
空ã®ãã¡ã¤ã« (test0.txt
) ã¨ï¼2ã4 è¡ã®ãã¼ã¿ãæã£ããã¡ã¤ã«ãä½æãã¾ãï¼
test2.txt
(æå¾ã«æ¹è¡ãªã)
abc def
test3.txt
(æå¾ã«æ¹è¡ãã)
abc def
test4.txt
(æå¾ã«æ¹è¡ãã)
abc def
Eclipse ã®ã¨ãã£ã¿ãªããã ã¨æå¾ã«æ¹è¡ãããã¨ãã®ä¸ã«ããä¸è¡ãããã®ããã«è¡¨ç¤ºããããã©ï¼ãããããã®ãªã®ããªï¼ ã¨ããããããã§ã¯æ¹è¡ãè¡ã®çµç«¯ã¨ãã¦æ±ããã¨ã«ãã¦ããã®ã§ï¼ãã®å¾ã«è¡ã¯ãªããã®ã¨ãã¦æ±ãã¾ãï¼
æçµå½¢ã¨ãããã¨ã§ï¼ãã¹ããå¢ããã read-line-test.js
å
¨ä½ãæ²è¼ï¼
var vows = require('vows'), assert = require('assert'), events = require('events'), fs = require('fs'); var read_line = require('./read-line'); vows.describe('read-line').addBatch( { 'å½ã®EventEmitterã使ã£ã¦' : { topic : function() { return function(data) { var lines = []; var emitter = new (events.EventEmitter); read_line.onDataByLine(emitter, function(line) { lines.push(line); }); if (!Array.isArray(data)) { emitter.emit('data', data); } else { for ( var i = 0; i < data.length; ++i) { emitter.emit('data', data[i]); } } emitter.emit('end'); return lines; }; }, '1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã' : { 'ãã¼ã¿ãundefinedã®å ´å' : { topic : function(topic) { return topic(undefined); }, '1åãã³ã¼ã«ããã¯ãããªããã¨' : function(topic) { assert.length(topic, 0); } }, 'ãã¼ã¿ãnullã®å ´å' : { topic : function(topic) { return topic(null); }, '1åãã³ã¼ã«ããã¯ãããªããã¨' : function(topic) { assert.length(topic, 0); } }, 'ãã¼ã¿ã空æååã®å ´å' : { topic : function(topic) { return topic(''); }, '1åãã³ã¼ã«ããã¯ãããªããã¨' : function(topic) { assert.length(topic, 0); } }, 'ãã¼ã¿ãæ¹è¡ãå«ã¾ãªãæååã®å ´å' : { topic : function(topic) { return topic('abcdef'); }, '1åã ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 1); }, 'ãã¼ã¿å ¨ä½ãæååã¨ãã¦ã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abcdef'); } }, 'ãã¼ã¿ãæ¹è¡ã§å§ã¾ãæååã®å ´å' : { topic : function(topic) { return topic('\nabc'); }, '2åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 2); }, 'æåã«ç©ºè¡ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], ''); }, '次ã«æ¹è¡ã®å¾ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'abc'); } }, 'ãã¼ã¿ãæ¹è¡ã§çµäºããæååã®å ´å' : { topic : function(topic) { return topic('abcdef\n'); }, '1åã ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 1); }, 'æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abcdef'); } }, 'ãã¼ã¿ãéä¸ã«æ¹è¡ãå«ãæååã®å ´å' : { topic : function(topic) { return topic('abc\ndef'); }, '2åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 2); }, 'æåã«æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«æ¹è¡ã®å¾ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'def'); } }, 'ãã¼ã¿ãéä¸ã«æ¹è¡ãäºã¤å«ãæååã®å ´å' : { topic : function(topic) { return topic('abc\ndef\nghi'); }, '3åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 3); }, 'æåã«ä¸çªç®ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«ä¸çªç®ã®æ¹è¡ã¨äºçªç®ã®æ¹è¡ã®éã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'def'); }, 'æå¾ã«äºçªç®ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[2], 'ghi'); } } }, '2åãã¼ã¿åä¿¡ã¤ãã³ããçºçã' : { 'ã©ã®ãã¼ã¿ã«ãæ¹è¡ãå«ã¾ããªãå ´å' : { topic : function(topic) { return topic( [ 'abc', 'def' ]); }, '1åã ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 1); }, 'ä¸çªç®ã®ãã¼ã¿ã¨äºçªç®ã®ãã¼ã¿ãé£çµããæååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abcdef'); } }, 'æåã®ã¤ãã³ãã«ã ãæ¹è¡ãå«ã¾ããå ´å' : { topic : function(topic) { return topic( [ 'abc\ndef', 'ghi' ]); }, '2åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 2); }, 'æåã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã¨äºçªç®ã®ãã¼ã¿ãé£çµããæååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'defghi'); } }, 'äºçªç®ã®ã¤ãã³ãã«ã ãæ¹è¡ãå«ã¾ããå ´å' : { topic : function(topic) { return topic( [ 'abc', 'def\nghi' ]); }, '2åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 2); }, 'æåã«ä¸çªç®ã®ãã¼ã¿ã¨äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããåãé£çµããæååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abcdef'); }, '次ã«äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'ghi'); } }, 'ä¸çªç®ã¨äºçªç®ã®ä¸¡æ¹ã®ã¤ãã³ãã«æ¹è¡ãå«ã¾ããå ´å' : { topic : function(topic) { return topic( [ 'abc\ndef', 'ghi\njkl' ]); }, '3åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 3); }, 'æåã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã¨ï¼äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããåãé£çµããæååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'defghi'); }, 'æå¾ã«äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[2], 'jkl'); } } } }, 'å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã' : { topic : function() { return function(fileName) { var lines = []; var promise = new (events.EventEmitter); var stream = fs.createReadStream(fileName); stream.setEncoding('utf-8'); read_line.onDataByLine(stream, function(line) { lines.push(line); }); stream.on('end', function() { promise.emit('success', lines); }); return promise; }; }, '空ã®ãã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test0.txt'); }, '1åãã³ã¼ã«ããã¯ãããªããã¨' : function(topic) { assert.length(topic, 0); } }, '1è¡ã®ãã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test1.txt'); }, '1åã ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 1); }, 'è¡å ¨ä½ãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); } }, '2è¡ã§æå¾ã®è¡ãæ¹è¡ã§çµãããªããã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test2.txt'); }, '2åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 2); }, 'æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], 'def'); } }, '空è¡ãå«ãã¦3è¡ã§æå¾ã®è¡ãæ¹è¡ã§çµãããã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test3.txt'); }, '3åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 3); }, 'æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], ''); }, 'æå¾ã«3è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[2], 'def'); } }, '空è¡ãå«ãã¦4è¡ã§æå¾ã®è¡ãæ¹è¡ã®ã¿ã®ç©ºè¡ã§çµãããã¡ã¤ã«ã®å ´å' : { topic : function(topic) { return topic('test4.txt'); }, '4åã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.length(topic, 4); }, 'æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[0], 'abc'); }, '次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[1], ''); }, 'ç¶ãã¦3è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[2], 'def'); }, 'æå¾ã«4è¡ç®ã®æååãã³ã¼ã«ããã¯ããããã¨' : function(topic) { assert.equal(topic[3], ''); } } } }).export(module);
ã¤ãã§ã« read-line.js
ãæ²è¼ï¼ããã® 2ãã®éä¸ããä¿®æ£ãã¦ãªããã©ï¼
exports.onDataByLine = function(stream, callback) { var line = ''; stream.on('data', function(data) { if (data) { line += data; while (line.match(/\r?\n/)) { callback(RegExp.leftContext); line = RegExp.rightContext; } } }); stream.on('end', function() { if (line) { callback(line); } }); };
ããã£ã½ã£ã¡ã®ãã¹ã対象ã«ãã®ãã¹ãã®è¨è¿°éã¯ã©ããªã®ãï¼ ã£ã¦æããªãããªããã©æ°ã«ããªãï¼ï¼ æ°ã«ããªãï¼ï¼
å®è¡ãã¾ãï¼
$ vows read-line-test.js ············································ ✓ OK » 44 honored (0.014s)
--spec
ãã¾ãï¼
$ vows read-line-test.js --spec ♢ read-line å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãundefinedã®å ´å ✓ 1åãã³ã¼ã«ããã¯ãããªãã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãnullã®å ´å ✓ 1åãã³ã¼ã«ããã¯ãããªãã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ã空æååã®å ´å ✓ 1åãã³ã¼ã«ããã¯ãããªãã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãæ¹è¡ãå«ã¾ãªãæååã®å ´å ✓ 1åã ãã³ã¼ã«ããã¯ãããã㨠✓ ãã¼ã¿å ¨ä½ãæååã¨ãã¦ã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãæ¹è¡ã§å§ã¾ãæååã®å ´å ✓ 2åã³ã¼ã«ããã¯ãããã㨠✓ æåã«ç©ºè¡ãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«æ¹è¡ã®å¾ã®æååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãæ¹è¡ã§çµäºããæååã®å ´å ✓ 1åã ãã³ã¼ã«ããã¯ãããã㨠✓ æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãéä¸ã«æ¹è¡ãå«ãæååã®å ´å ✓ 2åã³ã¼ã«ããã¯ãããã㨠✓ æåã«æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«æ¹è¡ã®å¾ã®æååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 1åã ããã¼ã¿åä¿¡ã¤ãã³ããçºçã ãã¼ã¿ãéä¸ã«æ¹è¡ãäºã¤å«ãæååã®å ´å ✓ 3åã³ã¼ã«ããã¯ãããã㨠✓ æåã«ä¸çªç®ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«ä¸çªç®ã®æ¹è¡ã¨äºçªç®ã®æ¹è¡ã®éã®æååãã³ã¼ã«ããã¯ãããã㨠✓ æå¾ã«äºçªç®ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 2åãã¼ã¿åä¿¡ã¤ãã³ããçºçã ã©ã®ãã¼ã¿ã«ãæ¹è¡ãå«ã¾ããªãå ´å ✓ 1åã ãã³ã¼ã«ããã¯ãããã㨠✓ ä¸çªç®ã®ãã¼ã¿ã¨äºçªç®ã®ãã¼ã¿ãé£çµããæååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 2åãã¼ã¿åä¿¡ã¤ãã³ããçºçã æåã®ã¤ãã³ãã«ã ãæ¹è¡ãå«ã¾ããå ´å ✓ 2åã³ã¼ã«ããã¯ãããã㨠✓ æåã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã¨äºçªç®ã®ãã¼ã¿ãé£çµããæååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 2åãã¼ã¿åä¿¡ã¤ãã³ããçºçã äºçªç®ã®ã¤ãã³ãã«ã ãæ¹è¡ãå«ã¾ããå ´å ✓ 2åã³ã¼ã«ããã¯ãããã㨠✓ æåã«ä¸çªç®ã®ãã¼ã¿ã¨äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããåãé£çµããæååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ãããã㨠å½ã®EventEmitterã使ã£ã¦ 2åãã¼ã¿åä¿¡ã¤ãã³ããçºçã ä¸çªç®ã¨äºçªç®ã®ä¸¡æ¹ã®ã¤ãã³ãã«æ¹è¡ãå«ã¾ããå ´å ✓ 3åã³ã¼ã«ããã¯ãããã㨠✓ æåã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããåã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«ä¸çªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã¨ï¼äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããåãé£çµããæååãã³ã¼ã«ããã¯ãããã㨠✓ æå¾ã«äºçªç®ã®ãã¼ã¿ã®æ¹è¡ããå¾ã®æååãã³ã¼ã«ããã¯ãããã㨠å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã 空ã®ãã¡ã¤ã«ã®å ´å ✓ 1åãã³ã¼ã«ããã¯ãããªãã㨠å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã 1è¡ã®ãã¡ã¤ã«ã®å ´å ✓ 1åã ãã³ã¼ã«ããã¯ãããã㨠✓ è¡å ¨ä½ãã³ã¼ã«ããã¯ãããã㨠å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã 2è¡ã§æå¾ã®è¡ãæ¹è¡ã§çµãããªããã¡ã¤ã«ã®å ´å ✓ 2åã³ã¼ã«ããã¯ãããã㨠✓ æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã 空è¡ãå«ãã¦4è¡ã§æå¾ã®è¡ãæ¹è¡ã®ã¿ã®ç©ºè¡ã§çµãããã¡ã¤ã«ã®å ´å ✓ 4åã³ã¼ã«ããã¯ãããã㨠✓ æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ ç¶ãã¦3è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ æå¾ã«4è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠å®éã«èªã¿è¾¼ãã ãã¡ã¤ã«ã 空è¡ãå«ãã¦3è¡ã§æå¾ã®è¡ãæ¹è¡ã§çµãããã¡ã¤ã«ã®å ´å ✓ 3åã³ã¼ã«ããã¯ãããã㨠✓ æåã«1è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ 次ã«2è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ æå¾ã«3è¡ç®ã®æååãã³ã¼ã«ããã¯ãããã㨠✓ OK » 44 honored (0.025s)
幸ããªæ°åã«ãªãã¾ããâª
æå¾ã®äºã¤ã®ã³ã³ããã¹ã (ãã¡ã¤ã«ã 3 è¡ã¨4 è¡ã®ãã¤)ï¼è¡¨ç¤ºã®é çªãè¨è¿°ã®é çªã¨ç°ãªã£ã¦ãããã¨ã«æ³¨æï¼ãããï¼å®è¡ãç¹°ãè¿ããã¨ã«ç°ãªã£ã¦ãããã¾ãï¼
ããã¯ï¼Vows ããã¹ã (ã³ã³ããã¹ã) ãéåæã«å®è¡ãã¦ãã証ã§ãããï¼è¡¨ç¤ºé ã¯ãã¹ãã®å®è¡ãå®äºããé çªã§ï¼ããã¯ãã¡ã¤ã«ã®èªã¿è¾¼ã¿ãå®äºããé çªã«ä¾åãã¦ããããã§ãï¼Vowsâ³ï¼
説æãæååã§æ¸ã辺ãã¨ãè¨è¿°éãå¤ããªããããªã¨ããã§å¥½ãå«ãå¥ãããã§ã¯ããã¾ããï¼Vows ã¯ãªããªãç´ æµãªãã¹ãã£ã³ã°ãã¬ã¼ã ã¯ã¼ã¯ã ã¨æãã¾ãï¼
éåæã¤ãã³ãã®ãã¹ããæã£ã¦ã以ä¸ã«ãã£ããã¨æ¸ãã¾ãããï¼ããã¯ãã¹ã対象ã§ãããããã¯ã¨ï¼æ¤è¨¼ã³ã¼ãã§ãã vow ãåãã¦è¨è¿°ãã¦ãããããã§ãããï¼ããã¦ãããã¯ãæ¤è¨¼å¯è½ã«ãªã£ãæï¼Vows ã vow ãå¼ã³åºãã¦ãããããã§ãï¼ã¾ãã«ã¤ãã³ãé§åï¼
Node.js ã®ãã¹ãã£ã³ã°ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã¦ã¯ä»ã«ã "Promise-based asynchronous test runner" ãªãã¦ããã«ãã³ããããªãpatrããèå³æ·±ãã®ã§ããï¼
ãã°ããã¯æµ®æ°ããã« Vows ãè¶³å ´ã« Node.js ã楽ãã¿ããã¨æã£ã¦ã¾ãï¼