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
68
69
70
71
72
73
74
75
76
77
78
79 | 1
1
1
1
1
1562
1562
1529
33
6
27
1
68
1
612
612
612
612
612
1683
1071
1683
612
1
568
| module.exports = function (expect) {
expect.installTheme({
jsBoolean: 'jsPrimitive',
jsNumber: 'jsPrimitive',
error: ['red', 'bold'],
success: ['green', 'bold'],
diffAddedLine: 'green',
diffAddedHighlight: ['bgGreen', 'white'],
diffAddedSpecialChar: ['bgGreen', 'cyan', 'bold'],
diffRemovedLine: 'red',
diffRemovedHighlight: ['bgRed', 'white'],
diffRemovedSpecialChar: ['bgRed', 'cyan', 'bold']
});
expect.installTheme('html', {
jsComment: '#969896',
jsFunctionName: '#795da3',
jsKeyword: '#a71d5d',
jsPrimitive: '#0086b3',
jsRegexp: 'jsString',
jsString: '#df5000',
jsKey: '#555'
});
expect.installTheme('ansi', {
jsComment: 'gray',
jsFunctionName: 'jsKeyword',
jsKeyword: 'magenta',
jsNumber: [],
jsPrimitive: 'cyan',
jsRegexp: 'green',
jsString: 'cyan',
jsKey: '#666',
diffAddedHighlight: ['bgGreen', 'black'],
diffRemovedHighlight: ['bgRed', 'black']
});
expect.addStyle('key', function (content) {
content = String(content);
if (/^[a-z\$\_][a-z0-9\$\_]*$/i.test(content)) {
this.text(content, 'jsKey');
} else if (/^(?:0|[1-9][0-9]*)$/.test(content)) {
this.jsNumber(content);
} else {
this.jsString('\'')
.jsString(JSON.stringify(content).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"'))
.jsString('\'');
}
});
// Intended to be redefined by a plugin that offers syntax highlighting:
expect.addStyle('code', function (content, language) {
this.text(content);
});
expect.addStyle('annotationBlock', function () {
var pen = this.getContentFromArguments(arguments);
var height = pen.size().height;
Eif (height > 0) {
this.block(function () {
for (var i = 0; i < height; i += 1) {
if (0 < i) {
this.nl();
}
this.error('//');
}
});
this.sp().block(pen);
}
});
expect.addStyle('shouldEqualError', function (expected, inspect) {
this.error(typeof expected === 'undefined' ? 'should be' : 'should equal').sp().block(inspect(expected));
});
};
|