-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.jdists.js
More file actions
40 lines (36 loc) · 1.18 KB
/
example.jdists.js
File metadata and controls
40 lines (36 loc) · 1.18 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
var assert = require('should');
var cbml = require('../.');
var util = require('util');
var printValue;
function print(value) {
if (typeof printValue !== 'undefined') {
throw new Error('Test case does not match.');
}
printValue = value;
}
/*<remove>*/
// <!--jdists encoding="glob" pattern="./src/**/*.js" export="#files" /-->
/*</remove>*/
/*<jdists encoding="jhtmls,regex" pattern="/~/g" replacement="--" data="#files" export="#example">*/
forEach(function (item) {
!#{'describe("' + item + '", function () {'}
!#{'printValue = undefined;'}
<!~jdists import="#{item}?example*" /~>
!#{'});'}
});
/*</jdists>*/
/*<jdists export="#replacer">*/
function (content) {
content = content.replace(/^\s*\*\s*@example\s*(.*)$/mg,
' it("$1", function () {');
content = content.replace(/^\s*```js\s*$/mg, '');
content = content.replace(/\/\/ -?>\s*(.*)/gm, function (all, output) {
return 'assert.equal(printValue, ' + JSON.stringify(output) + '); printValue = undefined;'
});
content = content.replace(/console\.log/g, 'print');
content = content.replace(/^\s*```\s*$/mg,
' });');
return content;
}
/*</jdists>*/
/*<jdists encoding="#replacer" import="#example"/>*/