true 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -4
- data/VERSION +1 -1
- data/lib/main.js +208 -106
- data/sass/true/_assert.scss +72 -115
- data/sass/true/_messages.scss +5 -40
- data/sass/true/_modules.scss +10 -1
- data/sass/true/_results.scss +10 -10
- data/sass/true/_tests.scss +4 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5072257c3b39c1a11769bcdb4fb30e28335625
|
4
|
+
data.tar.gz: f436a6ebea20178be95649a4cd83e175b1b203d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e8c888e372ccf16c0a4b75a846a236724fba87c0cbc33fd5d94c441051be2d4fca5d563b48c8cdfbddbcd22405816b1b67e0828c2adfbdc163a60ee984774d
|
7
|
+
data.tar.gz: ae7a97e9c55ba08d69cddc18061c7174905ec742fcbd50ee04bb6541c316e74cfd4167e22073d77d930c7d2f975a3ee2f23ab4967fe517efe77e3e07635bb5fe
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
True
|
2
2
|
====
|
3
3
|
|
4
|
-
[](https://travis-ci.org/ericam/true)
|
5
5
|
|
6
6
|
*Verb*
|
7
7
|
|
@@ -76,9 +76,7 @@ Usage
|
|
76
76
|
Function unit-tests work across the board,
|
77
77
|
but testing mixins can be a bit more complex.
|
78
78
|
At this point,
|
79
|
-
only Mocha is able to compare/report the results of mixin tests
|
80
|
-
as long as the mixins don't manipulate the selector chain
|
81
|
-
(it can't test media-query mixins for example).
|
79
|
+
only Mocha is able to compare/report the results of mixin tests.
|
82
80
|
Without using Mocha,
|
83
81
|
you can test any mixin,
|
84
82
|
but you will have to compare the expected and actual results manually
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/lib/main.js
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
var _ = require('underscore');
|
2
|
-
var
|
2
|
+
var css = require('css');
|
3
3
|
var path = require('path');
|
4
4
|
var sass = require('node-sass');
|
5
|
-
var CssSelectorParser = require('css-selector-parser').CssSelectorParser;
|
6
|
-
var selectorParser = new CssSelectorParser();
|
7
|
-
|
8
|
-
|
9
|
-
// @@@ maybe catch errors and display as warnings instead?
|
10
5
|
|
11
6
|
|
12
7
|
module.exports.runSass = function (options, describe, it) {
|
@@ -28,16 +23,16 @@ module.exports.runSass = function (options, describe, it) {
|
|
28
23
|
if (!assertion.passed) {
|
29
24
|
var msg = (
|
30
25
|
assertion.description + ' ("' +
|
31
|
-
assertion.
|
32
|
-
assertion.
|
26
|
+
assertion.output + '" ' +
|
27
|
+
assertion.assertionType + ' "' +
|
33
28
|
assertion.expected +
|
34
29
|
'")'
|
35
30
|
);
|
36
31
|
assert.fail(
|
37
|
-
assertion.
|
32
|
+
assertion.output,
|
38
33
|
assertion.expected,
|
39
34
|
msg,
|
40
|
-
assertion.
|
35
|
+
assertion.assertionType
|
41
36
|
);
|
42
37
|
}
|
43
38
|
});
|
@@ -47,108 +42,215 @@ module.exports.runSass = function (options, describe, it) {
|
|
47
42
|
});
|
48
43
|
};
|
49
44
|
|
50
|
-
|
51
|
-
var parse = module.exports.parse = function (
|
52
|
-
var
|
53
|
-
var
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
_.pluck(decls, 'property'),
|
59
|
-
_.pluck(decls, 'value')
|
60
|
-
);
|
61
|
-
var declInfo = _.object(declPairs);
|
62
|
-
var curAssertion, declString;
|
63
|
-
_.each(rule.selectors, function (sel) {
|
64
|
-
var selInfo = parseSelector(sel);
|
65
|
-
if (!selInfo) {
|
66
|
-
throw new Error("Can't understand selector: " + sel);
|
67
|
-
}
|
68
|
-
var curModule = _.findWhere(modules, {module: selInfo.module});
|
69
|
-
if (!curModule) {
|
70
|
-
curModule = {module: selInfo.module, tests: []};
|
71
|
-
modules.push(curModule);
|
72
|
-
}
|
73
|
-
var curTest = _.findWhere(curModule.tests, {test: selInfo.test});
|
74
|
-
if (!curTest) {
|
75
|
-
curTest = {test: selInfo.test, assertions: []};
|
76
|
-
curModule.tests.push(curTest);
|
77
|
-
}
|
78
|
-
if (selInfo.output) {
|
79
|
-
curAssertion = _.findWhere(
|
80
|
-
curTest.assertions, {description: selInfo.assert});
|
81
|
-
if (!curAssertion) {
|
82
|
-
curAssertion = {
|
83
|
-
description: selInfo.assert,
|
84
|
-
assert: 'equal',
|
85
|
-
};
|
86
|
-
curTest.assertions.push(curAssertion);
|
87
|
-
}
|
88
|
-
declString = _.map(declPairs, function (pair) {
|
89
|
-
return pair[0] + ': ' + pair[1] + ';';
|
90
|
-
}).join(' ');
|
91
|
-
if (selInfo.type === 'input') {
|
92
|
-
curAssertion.returned = declString;
|
93
|
-
} else { // if (selInfo.type == 'expect') {
|
94
|
-
curAssertion.expected = declString;
|
95
|
-
}
|
96
|
-
if (curAssertion.returned && curAssertion.expected) {
|
97
|
-
curAssertion.passed = curAssertion.returned === curAssertion.expected;
|
98
|
-
}
|
99
|
-
} else {
|
100
|
-
curAssertion = {
|
101
|
-
assert: selInfo.assert,
|
102
|
-
description: (declInfo['-description'] || '""').slice(1, -1),
|
103
|
-
passed: declInfo['-result'] === 'PASS',
|
104
|
-
};
|
105
|
-
_.each(_.pairs(declInfo), function (pair) {
|
106
|
-
if (_.contains(['-expected--', '-returned--'], pair[0].slice(0, 11))) {
|
107
|
-
var attr = pair[0].slice(1, 9);
|
108
|
-
var type = pair[0].slice(11);
|
109
|
-
var val = pair[1];
|
110
|
-
curAssertion[attr] = type + ': ' + val;
|
111
|
-
}
|
112
|
-
});
|
113
|
-
curTest.assertions.push(curAssertion);
|
114
|
-
}
|
115
|
-
});
|
45
|
+
|
46
|
+
var parse = module.exports.parse = function (rawCss) {
|
47
|
+
var ast = css.parse(rawCss);
|
48
|
+
var ctx = { modules: [] };
|
49
|
+
var handler = parseModule;
|
50
|
+
|
51
|
+
_.each(ast.stylesheet.rules, function (rule) {
|
52
|
+
handler = handler(rule, ctx);
|
116
53
|
});
|
117
54
|
|
118
|
-
|
55
|
+
finishCurrentModule(ctx);
|
56
|
+
|
57
|
+
return ctx.modules;
|
58
|
+
};
|
59
|
+
|
60
|
+
|
61
|
+
var parseError = function (msg, seeking, pos) {
|
62
|
+
throw new Error(
|
63
|
+
'Line ' + pos.start.line + ', column ' + pos.start.column + ': ' +
|
64
|
+
msg + '; looking for ' + seeking);
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
var parseModule = function (rule, ctx) {
|
69
|
+
if (rule.type === 'charset') { return parseModule; }
|
70
|
+
if (rule.type === 'comment') {
|
71
|
+
var text = rule.comment.trim();
|
72
|
+
if (!text) { return parseModule; }
|
73
|
+
if (text.substring(0, 10) === '# Module: ') {
|
74
|
+
finishCurrentModule(ctx);
|
75
|
+
ctx.currentModule = { module: text.substring(10), tests: [] };
|
76
|
+
return parseTest;
|
77
|
+
}
|
78
|
+
parseError('Unexpected comment "' + text + '"', 'module header', rule.position);
|
79
|
+
}
|
80
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'module header', rule.position);
|
81
|
+
};
|
82
|
+
|
83
|
+
|
84
|
+
var parseTest = function (rule, ctx) {
|
85
|
+
if (rule.type === 'comment') {
|
86
|
+
var text = rule.comment.trim();
|
87
|
+
if (!text) { return parseTest; }
|
88
|
+
if (text.match(/^-+$/)) {
|
89
|
+
return parseTest;
|
90
|
+
}
|
91
|
+
if (text.substring(0, 6) === 'Test: ') {
|
92
|
+
finishCurrentTest(ctx);
|
93
|
+
ctx.currentTest = { test: text.substring(6), assertions: [] };
|
94
|
+
return parseAssertion;
|
95
|
+
}
|
96
|
+
return parseModule(rule, ctx);
|
97
|
+
}
|
98
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'test', rule.position);
|
119
99
|
};
|
120
100
|
|
121
101
|
|
122
|
-
var
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
|
150
|
-
|
102
|
+
var parseAssertion = function (rule, ctx) {
|
103
|
+
if (rule.type === 'comment') {
|
104
|
+
var text = rule.comment.trim();
|
105
|
+
if (!text) { return parseAssertion; }
|
106
|
+
if (text.substring(0, 2) === '✔ ') {
|
107
|
+
finishCurrentAssertion(ctx);
|
108
|
+
ctx.currentAssertion = {
|
109
|
+
description: text.substring(2),
|
110
|
+
passed: true
|
111
|
+
};
|
112
|
+
return parseAssertion;
|
113
|
+
} else if (text.substring(0, 10) === '✖ FAILED [') {
|
114
|
+
finishCurrentAssertion(ctx);
|
115
|
+
var endAssertionType = text.indexOf(']');
|
116
|
+
ctx.currentAssertion = {
|
117
|
+
description: text.substring(endAssertionType + 2).trim(),
|
118
|
+
passed: false,
|
119
|
+
assertionType: text.substring(10, endAssertionType),
|
120
|
+
};
|
121
|
+
return parseFailureDetail;
|
122
|
+
} else if (text.substring(0, 8) === 'ASSERT: ') {
|
123
|
+
finishCurrentAssertion(ctx);
|
124
|
+
ctx.currentAssertion = {
|
125
|
+
description: text.substring(8),
|
126
|
+
assertionType: 'equal'
|
127
|
+
};
|
128
|
+
return parseAssertionOutputStart;
|
129
|
+
}
|
130
|
+
return parseTest(rule, ctx);
|
131
|
+
}
|
132
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'assertion', rule.position);
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
var parseFailureDetail = function (rule, ctx) {
|
137
|
+
if (rule.type === 'comment') {
|
138
|
+
var text = rule.comment.trim();
|
139
|
+
if (text.substring(0, 2) === '- ') {
|
140
|
+
var startType = text.indexOf('[');
|
141
|
+
var endType = text.indexOf(']');
|
142
|
+
var type = text.substring(startType, endType + 1);
|
143
|
+
var content = text.substring(endType + 3);
|
144
|
+
var outputOrExpected;
|
145
|
+
if (text.substring(2, startType) === 'Output ') {
|
146
|
+
outputOrExpected = 'output';
|
147
|
+
} else if (text.substring(2, startType) === 'Expected ') {
|
148
|
+
outputOrExpected = 'expected';
|
149
|
+
}
|
150
|
+
if (outputOrExpected) {
|
151
|
+
ctx.currentAssertion[outputOrExpected] = type + ' ' + content;
|
152
|
+
return parseFailureDetail;
|
151
153
|
}
|
152
154
|
}
|
155
|
+
return parseAssertion(rule, ctx);
|
153
156
|
}
|
157
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'output/expected', rule.position);
|
154
158
|
};
|
159
|
+
|
160
|
+
|
161
|
+
var parseAssertionOutputStart = function (rule, ctx) {
|
162
|
+
if (rule.type === 'comment') {
|
163
|
+
var text = rule.comment.trim();
|
164
|
+
if (!text) { return parseAssertionOutputStart; }
|
165
|
+
if (text === 'OUTPUT') {
|
166
|
+
ctx.currentOutputRules = [];
|
167
|
+
return parseAssertionOutput;
|
168
|
+
}
|
169
|
+
parseError('Unexpected comment "' + text + '"', 'OUTPUT', rule.position);
|
170
|
+
}
|
171
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'OUTPUT', rule.position);
|
172
|
+
};
|
173
|
+
|
174
|
+
|
175
|
+
var parseAssertionOutput = function (rule, ctx) {
|
176
|
+
if (rule.type === 'comment') {
|
177
|
+
if (rule.comment.trim() === 'END_OUTPUT') {
|
178
|
+
ctx.currentAssertion.output = css.stringify(
|
179
|
+
{ stylesheet: { rules: ctx.currentOutputRules }});
|
180
|
+
delete ctx.currentOutputRules;
|
181
|
+
return parseAssertionExpectedStart;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
ctx.currentOutputRules.push(rule);
|
185
|
+
return parseAssertionOutput;
|
186
|
+
};
|
187
|
+
|
188
|
+
|
189
|
+
var parseAssertionExpectedStart = function (rule, ctx) {
|
190
|
+
if (rule.type === 'comment') {
|
191
|
+
var text = rule.comment.trim();
|
192
|
+
if (!text) { return parseAssertionExpectedStart; }
|
193
|
+
if (text === 'EXPECTED') {
|
194
|
+
ctx.currentExpectedRules = [];
|
195
|
+
return parseAssertionExpected;
|
196
|
+
}
|
197
|
+
parseError('Unexpected comment "' + text + '"', 'EXPECTED', rule.position);
|
198
|
+
}
|
199
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'EXPECTED', rule.position);
|
200
|
+
};
|
201
|
+
|
202
|
+
|
203
|
+
var parseAssertionExpected = function (rule, ctx) {
|
204
|
+
if (rule.type === 'comment') {
|
205
|
+
if (rule.comment.trim() === 'END_EXPECTED') {
|
206
|
+
ctx.currentAssertion.expected = css.stringify(
|
207
|
+
{ stylesheet: { rules: ctx.currentExpectedRules }});
|
208
|
+
delete ctx.currentExpectedRules;
|
209
|
+
ctx.currentAssertion.passed = (
|
210
|
+
ctx.currentAssertion.output === ctx.currentAssertion.expected);
|
211
|
+
return parseEndAssertion;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
ctx.currentExpectedRules.push(rule);
|
215
|
+
return parseAssertionExpected;
|
216
|
+
};
|
217
|
+
|
218
|
+
|
219
|
+
var parseEndAssertion = function (rule, ctx) {
|
220
|
+
if (rule.type === 'comment') {
|
221
|
+
var text = rule.comment.trim();
|
222
|
+
if (!text) { return parseEndAssertion; }
|
223
|
+
if (text === 'END_ASSERT') {
|
224
|
+
finishCurrentAssertion(ctx);
|
225
|
+
return parseAssertion;
|
226
|
+
}
|
227
|
+
parseError('Unexpected comment "' + text + '"', 'END_ASSERT', rule.position);
|
228
|
+
}
|
229
|
+
parseError('Unexpected rule type "' + rule.type + '"', 'END_ASSERT', rule.position);
|
230
|
+
};
|
231
|
+
|
232
|
+
|
233
|
+
var finishCurrentModule = function (ctx) {
|
234
|
+
finishCurrentTest(ctx);
|
235
|
+
if (ctx.currentModule) {
|
236
|
+
ctx.modules.push(ctx.currentModule);
|
237
|
+
delete ctx.currentModule;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
var finishCurrentTest = function (ctx) {
|
243
|
+
finishCurrentAssertion(ctx);
|
244
|
+
if (ctx.currentTest) {
|
245
|
+
ctx.currentModule.tests.push(ctx.currentTest);
|
246
|
+
delete ctx.currentTest;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
var finishCurrentAssertion = function (ctx) {
|
252
|
+
if (ctx.currentAssertion) {
|
253
|
+
ctx.currentTest.assertions.push(ctx.currentAssertion);
|
254
|
+
delete ctx.currentAssertion;
|
255
|
+
}
|
256
|
+
}
|
data/sass/true/_assert.scss
CHANGED
@@ -14,19 +14,8 @@
|
|
14
14
|
$assert,
|
15
15
|
$description: ''
|
16
16
|
) {
|
17
|
-
@include _true-assert
|
18
|
-
|
19
|
-
|
20
|
-
.assert-true {
|
21
|
-
-result: to-upper-case($result);
|
22
|
-
-description: $description;
|
23
|
-
|
24
|
-
@if $result == fail {
|
25
|
-
@include _true-fail-details(true, $assert);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
@include _true-assert-stop($result);
|
17
|
+
@include _true-context('assert', $description);
|
18
|
+
@include _true-assert-results('assert-true', $assert, true);
|
30
19
|
}
|
31
20
|
|
32
21
|
/// Assert that a parameter is `false`
|
@@ -41,19 +30,8 @@
|
|
41
30
|
$assert,
|
42
31
|
$description: ''
|
43
32
|
) {
|
44
|
-
@include _true-assert
|
45
|
-
|
46
|
-
|
47
|
-
.assert-false {
|
48
|
-
-result: to-upper-case($result);
|
49
|
-
-description: $description;
|
50
|
-
|
51
|
-
@if $result == fail {
|
52
|
-
@include _true-fail-details(false, $assert);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
@include _true-assert-stop($result);
|
33
|
+
@include _true-context('assert', $description);
|
34
|
+
@include _true-assert-results('assert-false', $assert, false);
|
57
35
|
}
|
58
36
|
|
59
37
|
/// /// Assert that two parameters are `equal`
|
@@ -70,19 +48,8 @@
|
|
70
48
|
$expected,
|
71
49
|
$description: ''
|
72
50
|
) {
|
73
|
-
@include _true-assert
|
74
|
-
|
75
|
-
|
76
|
-
.assert-equal {
|
77
|
-
-result: to-upper-case($result);
|
78
|
-
-description: $description;
|
79
|
-
|
80
|
-
@if $result == fail {
|
81
|
-
@include _true-fail-details($expected, $assert);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
@include _true-assert-stop($result);
|
51
|
+
@include _true-context('assert', $description);
|
52
|
+
@include _true-assert-results('assert-equal', $assert, $expected);
|
86
53
|
}
|
87
54
|
|
88
55
|
/// Assert that two parameters are `unequal`
|
@@ -99,19 +66,8 @@
|
|
99
66
|
$expected,
|
100
67
|
$description: ''
|
101
68
|
) {
|
102
|
-
@include _true-assert
|
103
|
-
|
104
|
-
|
105
|
-
.assert-unequal {
|
106
|
-
-result: to-upper-case($result);
|
107
|
-
-description: $description;
|
108
|
-
|
109
|
-
@if $result == fail {
|
110
|
-
@include _true-fail-details($expected, $assert);
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
@include _true-assert-stop($result);
|
69
|
+
@include _true-context('assert', $description);
|
70
|
+
@include _true-assert-results('assert-unequal', $assert, $expected, 'unequal');
|
115
71
|
}
|
116
72
|
|
117
73
|
|
@@ -122,100 +78,101 @@
|
|
122
78
|
/// @access public
|
123
79
|
/// @group testing
|
124
80
|
/// @param {String} $description - Assert description
|
125
|
-
/// @content Use `
|
81
|
+
/// @content Use `output()` and `expect()` mixins to define blocks for comparison
|
126
82
|
/// @require {mixin} _true-assert-start
|
127
83
|
/// @require {mixin} _true-assert-stop
|
128
84
|
/// @require {function} _true-selector
|
129
85
|
@mixin assert(
|
130
86
|
$description
|
131
87
|
) {
|
132
|
-
@include _true-assert
|
88
|
+
@include _true-context('assert', $description);
|
89
|
+
@include _true-message(' ASSERT: #{$description} ', 'comments');
|
133
90
|
|
134
|
-
|
135
|
-
@content;
|
136
|
-
}
|
91
|
+
@content;
|
137
92
|
|
138
|
-
@include _true-
|
93
|
+
@include _true-update('test', 'output-to-css');
|
94
|
+
@include _true-context('assert', null);
|
95
|
+
@include _true-message(' END_ASSERT ', 'comments');
|
139
96
|
}
|
140
97
|
|
141
98
|
/// Describe the test content to be evaluated
|
142
99
|
/// The output will be compared against the results of the `expect()` mixin.
|
143
100
|
/// @access public
|
144
101
|
/// @group testing
|
145
|
-
@mixin
|
146
|
-
|
102
|
+
@mixin output(
|
103
|
+
$selector: true
|
104
|
+
) {
|
105
|
+
@include _true-message(' OUTPUT ', 'comments');
|
106
|
+
|
107
|
+
@if $selector {
|
108
|
+
.test-output {
|
109
|
+
@content;
|
110
|
+
}
|
111
|
+
} @else {
|
147
112
|
@content;
|
148
113
|
}
|
114
|
+
|
115
|
+
@include _true-message(' END_OUTPUT ', 'comments');
|
149
116
|
}
|
150
117
|
|
151
118
|
/// Describe the output content to be expected.
|
152
|
-
/// The output will be compared against the results of the `
|
119
|
+
/// The output will be compared against the results of the `output()` mixin.
|
153
120
|
/// @access public
|
154
121
|
/// @group testing
|
155
|
-
@mixin expect
|
156
|
-
|
122
|
+
@mixin expect(
|
123
|
+
$selector: true
|
124
|
+
) {
|
125
|
+
@include _true-message(' EXPECTED ', 'comments');
|
126
|
+
|
127
|
+
@if $selector {
|
128
|
+
.test-output {
|
129
|
+
@content;
|
130
|
+
}
|
131
|
+
} @else {
|
157
132
|
@content;
|
158
133
|
}
|
159
|
-
}
|
160
134
|
|
161
|
-
|
162
|
-
// Assert Start
|
163
|
-
// ------------
|
164
|
-
|
165
|
-
/// True assert start helper
|
166
|
-
/// @access private
|
167
|
-
/// @group x_private
|
168
|
-
/// @param {String} $name - Assert name
|
169
|
-
/// @require {mixin} _true-context
|
170
|
-
@mixin _true-assert-start(
|
171
|
-
$name
|
172
|
-
) {
|
173
|
-
@include _true-context(assert, $name);
|
135
|
+
@include _true-message(' END_EXPECTED ', 'comments');
|
174
136
|
}
|
175
137
|
|
176
|
-
/// True assert sort helper
|
177
|
-
/// @access private
|
178
|
-
/// @group x_private
|
179
|
-
/// @param {String} $result - Assert result
|
180
|
-
/// @require {mixin} _true-context
|
181
|
-
/// @require {mixin} _true-update
|
182
|
-
@mixin _true-assert-stop(
|
183
|
-
$result
|
184
|
-
) {
|
185
|
-
@include _true-update(test, $result);
|
186
|
-
@include _true-context(assert, null);
|
187
|
-
}
|
188
138
|
|
139
|
+
// Assert Results
|
140
|
+
// --------------
|
189
141
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
/// Fail details
|
194
|
-
/// @access private
|
195
|
-
/// @group x_private
|
196
|
-
/// @param {*} $expected - Expected result
|
197
|
-
/// @param {*} $returned - Returned result
|
198
|
-
/// @param {Bool} $terminal [$true-terminal-output] - Whether or not to use terminal output
|
199
|
-
/// @require $true-terminal-output
|
200
|
-
/// @require {function} _true-context
|
201
|
-
@mixin _true-fail-details(
|
142
|
+
@mixin _true-assert-results(
|
143
|
+
$type,
|
144
|
+
$assert,
|
202
145
|
$expected,
|
203
|
-
$
|
146
|
+
$unequal: false,
|
204
147
|
$terminal: $true-terminal-output
|
205
148
|
) {
|
206
|
-
$
|
207
|
-
$
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
149
|
+
$assertion: _true-context('assert');
|
150
|
+
$equal: _true-is-equal($assert, $expected);
|
151
|
+
$pass: if($unequal, not $equal, $equal);
|
152
|
+
$result: if($pass, 'pass', 'fail');
|
153
|
+
|
154
|
+
@if $result == 'pass' {
|
155
|
+
@include _true-message(' ✔ #{$assertion}', 'comments');
|
156
|
+
} @else {
|
157
|
+
$module: _true-context('module');
|
158
|
+
$test: _true-context('test');
|
159
|
+
|
160
|
+
$title: 'FAILED [#{$type}]: #{$assertion}';
|
161
|
+
$out: 'Output [#{type-of($assert)}]: #{inspect($assert)}';
|
162
|
+
$exp: 'Expected [#{type-of($expected)}]: #{inspect($expected)}';
|
163
|
+
|
164
|
+
@include _true-message(' ✖ #{$title}', 'comments');
|
165
|
+
@include _true-message(' - #{$out}', 'comments');
|
166
|
+
@include _true-message(' - #{$exp}', 'comments');
|
167
|
+
|
168
|
+
@if $terminal {
|
169
|
+
@include _true-message('#{$module} » #{$test}', 'debug');
|
170
|
+
@include _true-message('- #{$out}', 'debug');
|
171
|
+
@include _true-message('- #{$exp}', 'debug');
|
172
|
+
@include _true-message($title, 'warn');
|
173
|
+
}
|
218
174
|
}
|
219
175
|
|
220
|
-
@
|
176
|
+
@include _true-update('test', $result);
|
177
|
+
@include _true-context('assert', null);
|
221
178
|
}
|
data/sass/true/_messages.scss
CHANGED
@@ -8,36 +8,6 @@
|
|
8
8
|
$-tnl: '\a ';
|
9
9
|
|
10
10
|
|
11
|
-
/// Return a CSS selector for the current context
|
12
|
-
/// @access private
|
13
|
-
/// @group x_private
|
14
|
-
/// @param {List} $scope - Scope
|
15
|
-
/// @require {function} _true-context
|
16
|
-
/// @return {String} - CSS selector
|
17
|
-
@function _true-selector(
|
18
|
-
$scope
|
19
|
-
) {
|
20
|
-
$selector: null;
|
21
|
-
|
22
|
-
@each $layer in $scope {
|
23
|
-
$this: '[data-#{$layer}="#{_true-context($layer)}"]';
|
24
|
-
$selector: if($selector, '#{$selector} #{$this}', $this);
|
25
|
-
}
|
26
|
-
|
27
|
-
@return unquote($selector);
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
/// Output a spacer comment
|
32
|
-
/// @access private
|
33
|
-
/// @group x_private
|
34
|
-
/// @output A spacer comment
|
35
|
-
@mixin _true-spacer() {
|
36
|
-
/*
|
37
|
-
*/
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
11
|
/// Output a message to CSS comments, or command line terminal (via debug/warn)
|
42
12
|
/// @access private
|
43
13
|
/// @group x_private
|
@@ -46,25 +16,20 @@ $-tnl: '\a ';
|
|
46
16
|
/// @require {function} _true-str-split
|
47
17
|
@mixin _true-message(
|
48
18
|
$message,
|
49
|
-
$output: comments
|
19
|
+
$output: 'comments'
|
50
20
|
) {
|
51
21
|
$lines: _true-str-split($message, $-tnl);
|
52
|
-
@if index($output, comments) {
|
22
|
+
@if index($output, 'comments') {
|
53
23
|
@each $line in $lines {
|
54
24
|
/* #{$line} */
|
55
25
|
}
|
56
|
-
} @else if index($output, debug) or index($output, terminal) {
|
26
|
+
} @else if index($output, 'debug') or index($output, 'terminal') {
|
57
27
|
@each $line in $lines {
|
58
28
|
@debug $line;
|
59
29
|
}
|
60
|
-
} @else if index($output, warn) {
|
61
|
-
@warn $message;
|
30
|
+
} @else if index($output, 'warn') {
|
62
31
|
@each $line in $lines {
|
63
|
-
@
|
64
|
-
@warn $line;
|
65
|
-
} @else {
|
66
|
-
@debug $line;
|
67
|
-
}
|
32
|
+
@warn $line;
|
68
33
|
}
|
69
34
|
}
|
70
35
|
}
|
data/sass/true/_modules.scss
CHANGED
@@ -32,7 +32,15 @@
|
|
32
32
|
) {
|
33
33
|
@include _true-reset(module);
|
34
34
|
@include _true-context(module, $name);
|
35
|
-
@include _true-message('# #{$name}
|
35
|
+
@include _true-message('# Module: #{$name}', 'comments');
|
36
|
+
|
37
|
+
$underline: '----------';
|
38
|
+
|
39
|
+
@for $i from 1 through str-length($name) {
|
40
|
+
$underline: '#{$underline}-';
|
41
|
+
}
|
42
|
+
|
43
|
+
@include _true-message($underline, 'comments');
|
36
44
|
}
|
37
45
|
|
38
46
|
|
@@ -49,4 +57,5 @@
|
|
49
57
|
@include _true-update(global, null);
|
50
58
|
@include _true-reset(module);
|
51
59
|
@include _true-context(module, null);
|
60
|
+
@include _true-message('', 'comments');
|
52
61
|
}
|
data/sass/true/_results.scss
CHANGED
@@ -145,25 +145,25 @@ $_true-results: (
|
|
145
145
|
/// @return {String} - Reported message
|
146
146
|
/// @require {function} _true-get-results
|
147
147
|
@function _true-report-message(
|
148
|
-
$scope: test,
|
149
|
-
$lines: single
|
148
|
+
$scope: 'test',
|
149
|
+
$lines: 'single'
|
150
150
|
) {
|
151
151
|
$results: _true-get-results($scope);
|
152
|
-
$run: map-get($results, run);
|
153
|
-
$pass: map-get($results, pass);
|
154
|
-
$fail: map-get($results, fail);
|
155
|
-
$output-to-css: map-get($results, output-to-css);
|
152
|
+
$run: map-get($results, 'run');
|
153
|
+
$pass: map-get($results, 'pass');
|
154
|
+
$fail: map-get($results, 'fail');
|
155
|
+
$output-to-css: map-get($results, 'output-to-css');
|
156
156
|
|
157
157
|
$items: null;
|
158
158
|
$message: null;
|
159
159
|
|
160
|
-
@if $scope == global or $scope == module {
|
161
|
-
$items: Tests;
|
162
|
-
} @else if $scope == test {
|
160
|
+
@if $scope == 'global' or $scope == 'module' {
|
161
|
+
$items: 'Tests';
|
162
|
+
} @else if $scope == 'test' {
|
163
163
|
$items: Assertions;
|
164
164
|
}
|
165
165
|
|
166
|
-
@if $lines == single {
|
166
|
+
@if $lines == 'single' {
|
167
167
|
$message: '#{$run} #{$items}, #{$pass} Passed, #{$fail} Failed';
|
168
168
|
$message: if($output-to-css > 0, $message + ', #{$output-to-css} Output to CSS', $message);
|
169
169
|
} @else {
|
data/sass/true/_tests.scss
CHANGED
@@ -13,11 +13,8 @@
|
|
13
13
|
$name
|
14
14
|
) {
|
15
15
|
@include _true-test-start($name);
|
16
|
-
|
17
|
-
|
18
|
-
@content;
|
19
|
-
@include _true-test-stop;
|
20
|
-
}
|
16
|
+
@content;
|
17
|
+
@include _true-test-stop;
|
21
18
|
}
|
22
19
|
|
23
20
|
|
@@ -36,7 +33,7 @@
|
|
36
33
|
) {
|
37
34
|
@include _true-reset(test);
|
38
35
|
@include _true-context(test, $name);
|
39
|
-
@include _true-message($name, comments);
|
36
|
+
@include _true-message('Test: #{$name}', 'comments');
|
40
37
|
}
|
41
38
|
|
42
39
|
|
@@ -54,4 +51,5 @@
|
|
54
51
|
@include _true-update(module, _true-get-result(test));
|
55
52
|
@include _true-reset(test);
|
56
53
|
@include _true-context(test, null);
|
54
|
+
@include _true-message('', 'comments');
|
57
55
|
}
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 'true'
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Eric Suzanne
|
7
|
+
- Miriam Eric Suzanne
|
8
8
|
- Scott Davis
|
9
9
|
- Chris Eppstein
|
10
10
|
autorequire:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
version: '3.4'
|
29
29
|
description: Unit tests for maintaining test-driven Sass libraries.
|
30
30
|
email:
|
31
|
-
-
|
31
|
+
- miriam@oddbird.net
|
32
32
|
- me@sdavis.info
|
33
33
|
- chris@eppsteins.net
|
34
34
|
executables:
|
@@ -56,7 +56,7 @@ files:
|
|
56
56
|
- README.md
|
57
57
|
- VERSION
|
58
58
|
- bin/true-cli
|
59
|
-
homepage: http://
|
59
|
+
homepage: http://oddbird.net/true
|
60
60
|
licenses: []
|
61
61
|
metadata: {}
|
62
62
|
post_install_message:
|