Skip to content

Commit

Permalink
[test bin] Updates to ensure all tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Nov 16, 2010
1 parent 2d58999 commit 0e9c89b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 33 deletions.
1 change: 1 addition & 0 deletions bin/kyuri.js → bin/kyuri 100644 → 100755
Expand Up @@ -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');
4 changes: 0 additions & 4 deletions lib/kyuri/parser.js
Expand Up @@ -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]);
}
},
Expand Down Expand Up @@ -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]);
},

Expand Down
2 changes: 0 additions & 2 deletions lib/kyuri/runners/vows.js
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/kyuri/steps.js
Expand Up @@ -25,7 +25,7 @@ exports.When = function (pattern, topicGenerator) {

exports.Then = function (pattern, callbackGenerator) {
steps.push({
operator: 'Given',
operator: 'Then',
pattern: pattern,
generator: callbackGenerator
});
Expand Down
30 changes: 17 additions & 13 deletions test/lexer-test.js
Expand Up @@ -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);
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions test/parser-test.js
Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/simple-lexer-test.js
Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/vows-runner-test.js
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 0e9c89b

Please sign in to comment.