From 0e9c89b28dd3ed5d942d3a387f00d01fc46e64ef Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 15 Nov 2010 21:14:32 -0500 Subject: [PATCH] [test bin] Updates to ensure all tests are passing --- bin/{kyuri.js => kyuri} | 1 + lib/kyuri/parser.js | 4 ---- lib/kyuri/runners/vows.js | 2 -- lib/kyuri/steps.js | 2 +- test/lexer-test.js | 30 +++++++++++++++++------------- test/parser-test.js | 26 ++++++++++++++++---------- test/simple-lexer-test.js | 4 ++-- test/vows-runner-test.js | 6 +++++- 8 files changed, 42 insertions(+), 33 deletions(-) rename bin/{kyuri.js => kyuri} (99%) mode change 100644 => 100755 diff --git a/bin/kyuri.js b/bin/kyuri old mode 100644 new mode 100755 similarity index 99% rename from bin/kyuri.js rename to bin/kyuri index 519e224..119c254 --- a/bin/kyuri.js +++ b/bin/kyuri @@ -153,3 +153,4 @@ var arg, args = [], argv = process.argv.slice(2); // and path of test folder. var root, testFolder; +sys.puts('Kyuri test runner not currently complete in 0.2.0. In the roadmap for 0.2.1'); \ No newline at end of file diff --git a/lib/kyuri/parser.js b/lib/kyuri/parser.js index e8a46e6..32587f5 100644 --- a/lib/kyuri/parser.js +++ b/lib/kyuri/parser.js @@ -370,8 +370,6 @@ Parser.prototype = { this.checkTransition(token, this.current.transitions[token[0]]); } else { - eyes.inspect(token); - eyes.inspect(this.current); throw new Error('Unexpected token "' + token[0] + '" at line ' + token[2]); } }, @@ -436,8 +434,6 @@ Parser.prototype = { return true; } - eyes.inspect(this.last); - eyes.inspect(this.current); throw new Error('Mismatched last token "' + this.last[0] + '" at line ' + this.last[2]); }, diff --git a/lib/kyuri/runners/vows.js b/lib/kyuri/runners/vows.js index 891a2d5..7ca1f4d 100644 --- a/lib/kyuri/runners/vows.js +++ b/lib/kyuri/runners/vows.js @@ -48,8 +48,6 @@ exports.createVows = function (filename, features) { batch[scenario.name] = exports.scenarioVows(scenario); }); - eyes.inspect(batch); - // The the batch representing the feature to the suite suite.addBatch(batch); }); diff --git a/lib/kyuri/steps.js b/lib/kyuri/steps.js index 074f667..5049f08 100644 --- a/lib/kyuri/steps.js +++ b/lib/kyuri/steps.js @@ -25,7 +25,7 @@ exports.When = function (pattern, topicGenerator) { exports.Then = function (pattern, callbackGenerator) { steps.push({ - operator: 'Given', + operator: 'Then', pattern: pattern, generator: callbackGenerator }); diff --git a/test/lexer-test.js b/test/lexer-test.js index d845304..a0105bb 100644 --- a/test/lexer-test.js +++ b/test/lexer-test.js @@ -28,27 +28,31 @@ var kyuri = require('kyuri'), }, maxLength: 4096 }); - -var readAllLines = function (filename) { + +function tokenizeAllLines (filename) { return function () { - fs.readFile(filename, encoding = 'ascii', this.callback); - } -}; + var that = this; + fs.readFile(filename, encoding = 'ascii', function (err, data) { + if (err) return that.callback(err); + that.callback(null, kyuri.tokens(data.toString())); + }); + } +} vows.describe('kyuri/lexer').addBatch({ "When using the Kyuri lexer,": { "lexing simple.feature": { - topic: readAllLines(path.join(__dirname, '..', 'examples', 'simple.feature')), - "should lex correctly": function (err, data) { - assert.isNotNull(data.toString()); - inspect(kyuri.tokens(data.toString())); + topic: tokenizeAllLines(path.join(__dirname, '..', 'examples', 'simple.feature')), + "should lex correctly": function (err, tokens) { + assert.isNull(err); + assert.isNotNull(tokens); } }, "lexing complex.feature": { - topic: readAllLines(path.join(__dirname, '..', 'examples', 'complex.feature')), - "should lex correctly": function (err, data) { - assert.isNotNull(data.toString()); - inspect(kyuri.tokens(data.toString())); + topic: tokenizeAllLines(path.join(__dirname, '..', 'examples', 'complex.feature')), + "should lex correctly": function (err, tokens) { + assert.isNull(err); + assert.isNotNull(tokens); } } } diff --git a/test/parser-test.js b/test/parser-test.js index 89e4c5f..bb0bd98 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -29,26 +29,32 @@ var kyuri = require('kyuri'), maxLength: 4096 }); -var readAllLines = function (filename) { +var parseAllLines = function (filename) { return function () { - fs.readFile(filename, encoding = 'ascii', this.callback); + var that = this; + fs.readFile(filename, encoding = 'ascii', function (err, data) { + if (err) return that.callback(err); + that.callback(null, kyuri.parse(data.toString())); + }); } }; vows.describe('kyuri/parser').addBatch({ "When using the Kyuri parser,": { "parsing simple.feature": { - topic: readAllLines(path.join(__dirname, '..', 'examples', 'simple.feature')), - "should parse correctly": function (err, data) { - assert.isNotNull(data.toString()); - inspect(kyuri.parse(data.toString())); + topic: parseAllLines(path.join(__dirname, '..', 'examples', 'simple.feature')), + "should parse correctly": function (err, ast) { + assert.isNull(err); + assert.isObject(ast); + assert.include(ast, 1); } }, "parsing complex.feature": { - topic: readAllLines(path.join(__dirname, '..', 'examples', 'complex.feature')), - "should parse correctly": function (err, data) { - assert.isNotNull(data.toString()); - inspect(kyuri.parse(data.toString())); + topic: parseAllLines(path.join(__dirname, '..', 'examples', 'complex.feature')), + "should parse correctly": function (err, ast) { + assert.isNull(err); + assert.isObject(ast); + assert.include(ast, 1); } } } diff --git a/test/simple-lexer-test.js b/test/simple-lexer-test.js index a9d6821..9bdf8a3 100644 --- a/test/simple-lexer-test.js +++ b/test/simple-lexer-test.js @@ -19,14 +19,14 @@ vows.describe('kyuri/lexer/simple').addBatch({ topic: kyuri.tokens('Feature: Addition boi'), "should be respond with a single token literal": function (tokens) { assert.instanceOf(tokens, Array); - assert.equal(tokens.length, 1); + assert.equal(tokens.length, 4); } }, "a scenario token": { topic: kyuri.tokens('Scenario: Simple math boi'), "should be respond with a single token literal": function (tokens) { assert.instanceOf(tokens, Array); - assert.equal(tokens.length, 1); + assert.equal(tokens.length, 4); } } } diff --git a/test/vows-runner-test.js b/test/vows-runner-test.js index 80b5c76..89ce3c1 100644 --- a/test/vows-runner-test.js +++ b/test/vows-runner-test.js @@ -29,7 +29,11 @@ vows.describe('kyuri/parser').addBatch({ var text = data.toString(); assert.isNotNull(text); - var suite = kyuri.runners.vows.createVows('simple.feature', kyuri.parse(data.toString()).ast); + var ast = kyuri.parse(data.toString()); + assert.isObject(ast); + assert.include(ast, 1); + + var suite = kyuri.runners.vows.createVows('simple.feature', ast); assert.equal(suite.batches.length, 1); } }