-
Notifications
You must be signed in to change notification settings - Fork 84
/
run_examples_test_no_root.js
43 lines (37 loc) · 1.08 KB
/
run_examples_test_no_root.js
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
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
mu = require('../lib/mu');
// This tests if Mu also works without using the mu.root variable, and only supplying absolute paths.
mu.root = '/tmp/nonexistant';
[
'boolean',
'carriage_return',
'comments',
'complex',
'deep_partial',
// 'delimiters',
'error_not_found',
'escaped',
'hash_instead_of_array',
'inverted',
'partial',
'recursion_with_same_names',
'reuse_of_enumerables',
'simple',
'twice',
'two_in_a_row',
'unescaped'
].forEach(function (name) {
var js = fs.readFileSync(path.join(__dirname, 'examples', name + '.js')).toString(),
text = fs.readFileSync(path.join(__dirname, 'examples', name + '.txt')).toString();
js = eval('(' + js + ')');
var buffer = '';
mu.compileAndRender(path.join(__dirname, 'examples', name + '.html'), js)
.on('data', function (c) { buffer += c.toString(); })
.on('end', function () {
console.log("Testing: " + name);
assert.equal(buffer, text);
console.log(name + ' passed\n');
});
});