Fix those damn Jade tests
This commit is contained in:
Родитель
194c711626
Коммит
de3b22eed4
|
@ -34,41 +34,42 @@ function parseJade(str, options) {
|
|||
return extractGettext(this[key].val);
|
||||
}
|
||||
|
||||
var buf = [], lineN, lineAdjust = -1;
|
||||
var buf = [];
|
||||
|
||||
function append(text) {
|
||||
function append(text, offset) {
|
||||
/* jshint -W040 */
|
||||
var ctx = this;
|
||||
if (ctx && ctx.bump) {
|
||||
lineN += 1;
|
||||
if (this.type === 'attrs') {
|
||||
// offset for attribute tokens are invalid
|
||||
// we treat all attr tokens to be on the same line as the first one =(
|
||||
offset = 0;
|
||||
}
|
||||
var line = this.line + (offset || 0) - 1;
|
||||
if (text.length) {
|
||||
buf[lineN] = [buf[lineN], text, ';'].join('');
|
||||
buf[line] = [buf[line], text, ';'].join('');
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
token = lexer.next();
|
||||
lineN = token.line + lineAdjust;
|
||||
switch (token.type) {
|
||||
case 'attrs':
|
||||
Object.keys(token.attrs)
|
||||
.map(extractFromObj, token.attrs)
|
||||
.forEach(append);
|
||||
.forEach(append, token);
|
||||
break;
|
||||
case 'text':
|
||||
case 'code':
|
||||
append(extractGettext(token.val));
|
||||
append.call(token, extractGettext(token.val));
|
||||
break;
|
||||
case 'pipeless-text':
|
||||
token.line -= token.val.length - 1;
|
||||
token.val
|
||||
.map(extractGettext)
|
||||
.forEach(append, { bump: true });
|
||||
lineAdjust += token.val.length;
|
||||
.forEach(append, token);
|
||||
break;
|
||||
case 'comment':
|
||||
if (/^\s*L10n:/.test(token.val)) {
|
||||
append(['/*', token.val, '*/'].join(''));
|
||||
append.call(token, ['/*', token.val, '*/'].join(''));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"acorn": "^0.11.0",
|
||||
"gettext-parser": "^1.1.0",
|
||||
"commander": "2.5.0",
|
||||
"jade": "^1.0.0",
|
||||
"jade": "^1.11.0",
|
||||
"escape-string-regexp": "1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -61,4 +61,4 @@ msgstr ""
|
|||
|
||||
#: inputs/example.jade:30
|
||||
msgid "in line one line (30)"
|
||||
msgstr ""
|
||||
msgstr ""
|
||||
|
|
|
@ -4,10 +4,12 @@ var fs = require('fs');
|
|||
|
||||
exports.compareResultWithFile = function (result, filePath, assert, cb, msg) {
|
||||
// Ignore the header
|
||||
result = result.slice(result.indexOf('\n\n') + 2);
|
||||
result = result.slice(result.indexOf('\n\n') + 2).trimRight();
|
||||
|
||||
|
||||
fs.readFile(filePath, function (err, source) {
|
||||
assert.equal(result, source.toString('utf8'), msg || 'Results match.');
|
||||
var sourceContent = source.toString('utf8').trimRight();
|
||||
assert.equal(result, sourceContent, msg || 'Results match.');
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче