-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathparser-test.js
More file actions
67 lines (63 loc) · 2.07 KB
/
parser-test.js
File metadata and controls
67 lines (63 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* lexer-test.js: More complex tests for the Kyuri lexer.
*
* (C) 2010 Charlie Robbins
* MIT LICENSE
*
*/
var kyuri = require('../../kyuri'),
fs = require('fs'),
path = require('path'),
vows = require('vows'),
assert = require('assert'),
inspect = require('eyes').inspector({
styles: {
all: 'cyan', // Overall style applied to everything
label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
other: 'inverted', // Objects which don't have a literal representation, such as functions
key: 'bold', // The keys in object literals, like 'a' in `{a: 1}`
special: 'grey', // null, undefined...
string: 'green',
number: 'magenta',
bool: 'blue', // true false
regexp: 'green', // /\d+/
},
maxLength: 4096
});
var parseAllLines = function (filename) {
return function () {
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: 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: parseAllLines(path.join(__dirname, '..', 'examples', 'complex.feature')),
"should parse correctly": function (err, ast) {
assert.isNull(err);
assert.isObject(ast);
assert.include(ast, 1);
}
},
"parsing complex_space.feature": {
topic: parseAllLines(path.join(__dirname, '..', 'examples', 'complex_space.feature')),
"should parse correctly": function (err, ast) {
assert.isNull(err);
assert.isObject(ast);
assert.include(ast, 1);
}
}
}
}).export(module);