Initial import with skill sheet working

This commit is contained in:
2024-12-04 00:11:23 +01:00
commit 9050c80ab4
4488 changed files with 671048 additions and 0 deletions

9
node_modules/less/test/.eslintrc.json generated vendored Normal file
View File

@ -0,0 +1,9 @@
{
"env": {
"node": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 6
}
}

3
node_modules/less/test/README.md generated vendored Normal file
View File

@ -0,0 +1,3 @@
Tests are generally organized in the `less/` folder by what options are set in index.js.
The main tests are located under `less/_main/`

230
node_modules/less/test/browser/common.js generated vendored Normal file
View File

@ -0,0 +1,230 @@
var logMessages = [];
window.less = window.less || {};
var logLevel_debug = 4,
logLevel_info = 3,
logLevel_warn = 2,
logLevel_error = 1;
// The amount of logging in the javascript console.
// 3 - Debug, information and errors
// 2 - Information and errors
// 1 - Errors
// 0 - None
// Defaults to 2
less.loggers = [
{
debug: function(msg) {
if (less.options.logLevel >= logLevel_debug) {
logMessages.push(msg);
}
},
info: function(msg) {
if (less.options.logLevel >= logLevel_info) {
logMessages.push(msg);
}
},
warn: function(msg) {
if (less.options.logLevel >= logLevel_warn) {
logMessages.push(msg);
}
},
error: function(msg) {
if (less.options.logLevel >= logLevel_error) {
logMessages.push(msg);
}
}
}
];
testLessEqualsInDocument = function () {
testLessInDocument(testSheet);
};
testLessErrorsInDocument = function (isConsole) {
testLessInDocument(isConsole ? testErrorSheetConsole : testErrorSheet);
};
testLessInDocument = function (testFunc) {
var links = document.getElementsByTagName('link'),
typePattern = /^text\/(x-)?less$/;
for (var i = 0; i < links.length; i++) {
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
(links[i].type.match(typePattern)))) {
testFunc(links[i]);
}
}
};
ieFormat = function(text) {
var styleNode = document.createElement('style');
styleNode.setAttribute('type', 'text/css');
var headNode = document.getElementsByTagName('head')[0];
headNode.appendChild(styleNode);
try {
if (styleNode.styleSheet) {
styleNode.styleSheet.cssText = text;
} else {
styleNode.innerText = text;
}
} catch (e) {
throw new Error('Couldn\'t reassign styleSheet.cssText.');
}
var transformedText = styleNode.styleSheet ? styleNode.styleSheet.cssText : styleNode.innerText;
headNode.removeChild(styleNode);
return transformedText;
};
testSheet = function (sheet) {
it(sheet.id + ' should match the expected output', function (done) {
var lessOutputId = sheet.id.replace('original-', ''),
expectedOutputId = 'expected-' + lessOutputId,
lessOutputObj,
lessOutput,
expectedOutputHref = document.getElementById(expectedOutputId).href,
expectedOutput = loadFile(expectedOutputHref);
// Browser spec generates less on the fly, so we need to loose control
less.pageLoadFinished
.then(function () {
lessOutputObj = document.getElementById(lessOutputId);
lessOutput = lessOutputObj.styleSheet ? lessOutputObj.styleSheet.cssText :
(lessOutputObj.innerText || lessOutputObj.innerHTML);
expectedOutput
.then(function (text) {
if (window.navigator.userAgent.indexOf('MSIE') >= 0 ||
window.navigator.userAgent.indexOf('Trident/') >= 0) {
text = ieFormat(text);
}
expect(lessOutput).to.equal(text);
done();
})
.catch(function(err) {
done(err);
});
})
.catch(function(err) {
done(err);
});
});
};
// TODO: do it cleaner - the same way as in css
function extractId(href) {
return href.replace(/^[a-z-]+:\/+?[^\/]+/i, '') // Remove protocol & domain
.replace(/^\//, '') // Remove root /
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
}
waitFor = function (waitFunc) {
return new Promise(function (resolve) {
var timeoutId = setInterval(function () {
if (waitFunc()) {
clearInterval(timeoutId);
resolve();
}
}, 5);
});
};
testErrorSheet = function (sheet) {
it(sheet.id + ' should match an error', function (done) {
var lessHref = sheet.href,
id = 'less-error-message:' + extractId(lessHref),
errorHref = lessHref.replace(/.less$/, '.txt'),
errorFile = loadFile(errorHref),
actualErrorElement,
actualErrorMsg;
// Less.js sets 10ms timer in order to add error message on top of page.
waitFor(function () {
actualErrorElement = document.getElementById(id);
return actualErrorElement !== null;
}).then(function () {
var innerText = (actualErrorElement.innerHTML
.replace(/<h3>|<\/?p>|<a href="[^"]*">|<\/a>|<ul>|<\/?pre( class="?[^">]*"?)?>|<\/li>|<\/?label>/ig, '')
.replace(/<\/h3>/ig, ' ')
.replace(/<li>|<\/ul>|<br>/ig, '\n'))
.replace(/&amp;/ig, '&')
// for IE8
.replace(/\r\n/g, '\n')
.replace(/\. \nin/, '. in');
actualErrorMsg = innerText
.replace(/\n\d+/g, function (lineNo) {
return lineNo + ' ';
})
.replace(/\n\s*in /g, ' in ')
.replace(/\n{2,}/g, '\n')
.replace(/\nStack Trace\n[\s\S]*/i, '')
.replace(/\n$/, '')
.trim();
errorFile
.then(function (errorTxt) {
errorTxt = errorTxt
.replace(/\{path\}/g, '')
.replace(/\{pathrel\}/g, '')
.replace(/\{pathhref\}/g, 'http://localhost:8081/test/less/errors/')
.replace(/\{404status\}/g, ' (404)')
.replace(/\{node\}[\s\S]*\{\/node\}/g, '')
.replace(/\n$/, '')
.trim();
expect(actualErrorMsg).to.equal(errorTxt);
if (errorTxt == actualErrorMsg) {
actualErrorElement.style.display = 'none';
}
done();
})
.catch(function (err) {
done(err);
});
});
});
};
testErrorSheetConsole = function (sheet) {
it(sheet.id + ' should match an error', function (done) {
var lessHref = sheet.href,
id = sheet.id.replace(/^original-less:/, 'less-error-message:'),
errorHref = lessHref.replace(/.less$/, '.txt'),
errorFile = loadFile(errorHref),
actualErrorElement = document.getElementById(id),
actualErrorMsg = logMessages[logMessages.length - 1]
.replace(/\nStack Trace\n[\s\S]*/, '');
describe('the error', function () {
expect(actualErrorElement).to.be.null;
});
errorFile
.then(function (errorTxt) {
errorTxt
.replace(/\{path\}/g, '')
.replace(/\{pathrel\}/g, '')
.replace(/\{pathhref\}/g, 'http://localhost:8081/browser/less/')
.replace(/\{404status\}/g, ' (404)')
.replace(/\{node\}.*\{\/node\}/g, '')
.trim();
expect(actualErrorMsg).to.equal(errorTxt);
done();
});
});
};
loadFile = function (href) {
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.open('GET', href, true);
request.onreadystatechange = function () {
if (request.readyState == 4) {
resolve(request.responseText.replace(/\r/g, ''));
}
};
request.send(null);
});
};

View File

@ -0,0 +1,3 @@
.test {
color: red;
}

View File

@ -0,0 +1,8 @@
.testisimported {
color: gainsboro;
}
.test {
color1: green;
color2: purple;
scalar: 20;
}

3
node_modules/less/test/browser/css/plugin/plugin.css generated vendored Normal file
View File

@ -0,0 +1,3 @@
.test {
val: http://localhost:8081/packages/less/tmp/browser/test-runner-browser.html;
}

View File

@ -0,0 +1,4 @@
hr {height:50px;}
.test {
color: white;
}

View File

@ -0,0 +1,36 @@
@import "http://localhost:8081/packages/less/test/browser/less/imports/modify-this.css";
@import "http://localhost:8081/packages/less/test/browser/less/imports/modify-again.css";
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/a.png");
}
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/relative-urls/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(http://localhost:8081/packages/less/test/browser/less/relative-urls/images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/relative-urls/bg);
}
.values {
url: url('http://localhost:8081/packages/less/test/browser/less/relative-urls/Trebuchet');
}

View File

@ -0,0 +1,36 @@
@import "http://localhost:8081/packages/less/test/browser/less/imports/modify-this.css";
@import "http://localhost:8081/packages/less/test/browser/less/imports/modify-again.css";
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/a.png");
}
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/rewrite-urls/bg);
}
.values {
url: url('http://localhost:8081/packages/less/test/browser/less/rewrite-urls/Trebuchet');
}

View File

@ -0,0 +1,35 @@
@import "https://www.github.com/cloudhead/imports/modify-this.css";
@import "https://www.github.com/cloudhead/imports/modify-again.css";
.modify {
my-url: url("https://www.github.com/cloudhead/imports/a.png");
}
.modify {
my-url: url("https://www.github.com/cloudhead/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(https://www.github.com/cloudhead/less.js/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(https://www.github.com/cloudhead/less.js/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(https://www.github.com/cloudhead/less.js/bg.jpg) no-repeat, url(https://www.github.com/cloudhead/less.js/bg.png) repeat-x top left, url(https://www.github.com/cloudhead/less.js/bg);
}
.values {
url: url('https://www.github.com/cloudhead/less.js/Trebuchet');
}

View File

@ -0,0 +1,35 @@
@import "https://www.github.com/cloudhead/imports/modify-this.css";
@import "https://www.github.com/cloudhead/imports/modify-again.css";
.modify {
my-url: url("https://www.github.com/cloudhead/imports/a.png");
}
.modify {
my-url: url("https://www.github.com/cloudhead/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(https://www.github.com/cloudhead/less.js/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(https://www.github.com/cloudhead/less.js/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(https://www.github.com/cloudhead/less.js/bg.jpg) no-repeat, url(https://www.github.com/cloudhead/less.js/bg.png) repeat-x top left, url(https://www.github.com/cloudhead/less.js/bg);
}
.values {
url: url('https://www.github.com/cloudhead/less.js/Trebuchet');
}

35
node_modules/less/test/browser/css/rootpath/urls.css generated vendored Normal file
View File

@ -0,0 +1,35 @@
@import "https://localhost/modify-this.css";
@import "https://localhost/modify-again.css";
.modify {
my-url: url("https://localhost/a.png");
}
.modify {
my-url: url("https://localhost/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(https://localhost/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(https://localhost/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(https://localhost/bg.jpg) no-repeat, url(https://localhost/bg.png) repeat-x top left, url(https://localhost/bg);
}
.values {
url: url('https://localhost/Trebuchet');
}

54
node_modules/less/test/browser/css/urls.css generated vendored Normal file
View File

@ -0,0 +1,54 @@
@import "http://localhost:8081/packages/less/test/browser/less/modify-this.css";
@import "http://localhost:8081/packages/less/test/browser/less/modify-again.css";
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/a.png");
}
.modify {
my-url: url("http://localhost:8081/packages/less/test/browser/less/b.png");
}
.gray-gradient {
background: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220%22%2F%3E%3Cstop%20offset%3D%2260%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.05%22%2F%3E%3Cstop%20offset%3D%2270%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.1%22%2F%3E%3Cstop%20offset%3D%2273%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.15%22%2F%3E%3Cstop%20offset%3D%2275%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.2%22%2F%3E%3Cstop%20offset%3D%2280%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.25%22%2F%3E%3Cstop%20offset%3D%2285%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.3%22%2F%3E%3Cstop%20offset%3D%2288%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.35%22%2F%3E%3Cstop%20offset%3D%2290%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.4%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.45%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.5%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E');
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/packages/less/test/browser/less/fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(http://localhost:8081/packages/less/test/browser/less/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(http://localhost:8081/packages/less/test/browser/less/bg.jpg) no-repeat, url(http://localhost:8081/packages/less/test/browser/less/bg.png) repeat-x top left, url(http://localhost:8081/packages/less/test/browser/less/bg);
}
.values {
url: url('http://localhost:8081/packages/less/test/browser/less/Trebuchet');
}
#data-uri {
uri: url('http://localhost:8081/packages/less/test/data/image.jpg');
}
#data-uri-guess {
uri: url('http://localhost:8081/packages/less/test/data/image.jpg');
}
#data-uri-ascii {
uri-1: url('http://localhost:8081/packages/less/test/data/page.html');
uri-2: url('http://localhost:8081/packages/less/test/data/page.html');
}
#svg-functions {
background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E');
background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E');
background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201%201%22%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%221%25%22%20stop-color%3D%22%23c4c4c4%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%225%25%22%20stop-color%3D%22%23008000%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23g)%22%20%2F%3E%3C%2Fsvg%3E');
}

View File

@ -0,0 +1,50 @@
module.exports = {
current: {
// src is used to build list of less files to compile
src: [
'benchmark/benchmark.less'
],
options: {
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-current.html'
}
},
v3_10_3: {
// src is used to build list of less files to compile
src: [
'benchmark/benchmark.less'
],
options: {
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v3_10_3.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.10.3/less.min.js'
}
},
v3_9_0: {
// src is used to build list of less files to compile
src: [
'benchmark/benchmark.less'
],
options: {
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v3_9_0.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js'
}
},
v2_7_3: {
// src is used to build list of less files to compile
src: [
'benchmark/benchmark.less'
],
options: {
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v2_7_3.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.3/less.min.js'
}
}
}

78
node_modules/less/test/browser/generator/generate.js generated vendored Normal file
View File

@ -0,0 +1,78 @@
const template = require('./template')
let config
const fs = require('fs-extra')
const path = require('path')
const globby = require('globby')
const { runner } = require('mocha-headless-chrome')
if (process.argv[2]) {
config = require(`./${process.argv[2]}.config`)
} else {
config = require('./runner.config')
}
/**
* Generate templates and run tests
*/
const tests = []
const cwd = process.cwd()
const tmpDir = path.join(cwd, 'tmp', 'browser')
fs.ensureDirSync(tmpDir)
fs.copySync(path.join(cwd, 'test', 'browser', 'common.js'), path.join(tmpDir, 'common.js'))
let numTests = 0
let passedTests = 0
let failedTests = 0
/** Will run the runners in a series */
function runSerial(tasks) {
var result = Promise.resolve()
start = Date.now()
tasks.forEach(task => {
result = result.then(result => {
if (result && result.result && result.result.stats) {
const stats = result.result.stats
numTests += stats.tests
passedTests += stats.passes
failedTests += stats.failures
}
return task()
}, err => {
console.log(err)
failedTests += 1
})
})
return result
}
Object.entries(config).forEach(entry => {
const test = entry[1]
const paths = globby.sync(test.src)
const templateString = template(paths, test.options.helpers, test.options.specs)
fs.writeFileSync(path.join(cwd, test.options.outfile), templateString)
tests.push(() => {
const file = 'http://localhost:8081/packages/less/' + test.options.outfile
console.log(file)
return runner({
file,
timeout: 3500,
args: ['disable-web-security']
})
})
})
module.exports = () => runSerial(tests).then(() => {
if (failedTests > 0) {
process.stderr.write(failedTests + ' Failed, ' + passedTests + ' passed\n');
} else {
process.stdout.write('All Passed ' + passedTests + ' run\n');
}
if (failedTests) {
process.on('exit', function() { process.reallyExit(1); });
}
process.exit()
}, err => {
process.stderr.write(err.message);
process.exit()
})

View File

@ -0,0 +1,188 @@
var path = require('path');
var resolve = require('resolve')
var { forceCovertToBrowserPath } = require('./utils');
/** Root of repo */
var testFolder = forceCovertToBrowserPath(path.dirname(resolve.sync('@less/test-data')));
var lessFolder = forceCovertToBrowserPath(path.join(testFolder, 'less'));
var localTests = forceCovertToBrowserPath(path.resolve(__dirname, '..'));
module.exports = {
main: {
// src is used to build list of less files to compile
src: [
`${lessFolder}/_main/*.less`,
`!${lessFolder}/_main/plugin-preeval.less`, // uses ES6 syntax
// Don't test NPM import, obviously
`!${lessFolder}/_main/plugin-module.less`,
`!${lessFolder}/_main/import-module.less`,
`!${lessFolder}/_main/javascript.less`,
`!${lessFolder}/_main/urls.less`,
`!${lessFolder}/_main/empty.less`
],
options: {
helpers: 'test/browser/runner-main-options.js',
specs: 'test/browser/runner-main-spec.js',
outfile: 'tmp/browser/test-runner-main.html'
}
},
legacy: {
src: [`${lessFolder}/legacy/*.less`],
options: {
helpers: 'test/browser/runner-legacy-options.js',
specs: 'test/browser/runner-legacy-spec.js',
outfile: 'tmp/browser/test-runner-legacy.html'
}
},
strictUnits: {
src: [`${lessFolder}/units/strict/*.less`],
options: {
helpers: 'test/browser/runner-strict-units-options.js',
specs: 'test/browser/runner-strict-units-spec.js',
outfile: 'tmp/browser/test-runner-strict-units.html'
}
},
errors: {
src: [
`${lessFolder}/errors/*.less`,
`${testFolder}/errors/javascript-error.less`,
`${localTests}/less/errors/*.less`
],
options: {
timeout: 20000,
helpers: 'test/browser/runner-errors-options.js',
specs: 'test/browser/runner-errors-spec.js',
outfile: 'tmp/browser/test-runner-errors.html'
}
},
noJsErrors: {
src: [`${lessFolder}/no-js-errors/*.less`],
options: {
helpers: 'test/browser/runner-no-js-errors-options.js',
specs: 'test/browser/runner-no-js-errors-spec.js',
outfile: 'tmp/browser/test-runner-no-js-errors.html'
}
},
browser: {
src: [
`${localTests}/less/*.less`,
`${localTests}/less/plugin/*.less`
],
options: {
helpers: 'test/browser/runner-browser-options.js',
specs: 'test/browser/runner-browser-spec.js',
outfile: 'tmp/browser/test-runner-browser.html'
}
},
relativeUrls: {
src: [`${localTests}/less/relative-urls/*.less`],
options: {
helpers: 'test/browser/runner-relative-urls-options.js',
specs: 'test/browser/runner-relative-urls-spec.js',
outfile: 'tmp/browser/test-runner-relative-urls.html'
}
},
rewriteUrls: {
src: [`${localTests}/less/rewrite-urls/*.less`],
options: {
helpers: 'test/browser/runner-rewrite-urls-options.js',
specs: 'test/browser/runner-rewrite-urls-spec.js',
outfile: 'tmp/browser/test-runner-rewrite-urls.html'
}
},
rootpath: {
src: [`${localTests}/less/rootpath/*.less`],
options: {
helpers: 'test/browser/runner-rootpath-options.js',
specs: 'test/browser/runner-rootpath-spec.js',
outfile: 'tmp/browser/test-runner-rootpath.html'
}
},
rootpathRelative: {
src: [`${localTests}/less/rootpath-relative/*.less`],
options: {
helpers: 'test/browser/runner-rootpath-relative-options.js',
specs: 'test/browser/runner-rootpath-relative-spec.js',
outfile: 'tmp/browser/test-runner-rootpath-relative.html'
}
},
rootpathRewriteUrls: {
src: [`${localTests}/less/rootpath-rewrite-urls/*.less`],
options: {
helpers:
'test/browser/runner-rootpath-rewrite-urls-options.js',
specs: 'test/browser/runner-rootpath-rewrite-urls-spec.js',
outfile:
'tmp/browser/test-runner-rootpath-rewrite-urls.html'
}
},
production: {
src: [`${localTests}/less/production/*.less`],
options: {
helpers: 'test/browser/runner-production-options.js',
specs: 'test/browser/runner-production-spec.js',
outfile: 'tmp/browser/test-runner-production.html'
}
},
modifyVars: {
src: [`${localTests}/less/modify-vars/*.less`],
options: {
helpers: 'test/browser/runner-modify-vars-options.js',
specs: 'test/browser/runner-modify-vars-spec.js',
outfile: 'tmp/browser/test-runner-modify-vars.html'
}
},
globalVars: {
src: [`${localTests}/less/global-vars/*.less`],
options: {
helpers: 'test/browser/runner-global-vars-options.js',
specs: 'test/browser/runner-global-vars-spec.js',
outfile: 'tmp/browser/test-runner-global-vars.html'
}
},
postProcessorPlugin: {
src: [`${lessFolder}/postProcessorPlugin/*.less`],
options: {
helpers: [
'test/plugins/postprocess/index.js',
'test/browser/runner-postProcessorPlugin-options.js'
],
specs: 'test/browser/runner-postProcessorPlugin.js',
outfile:
'tmp/browser/test-runner-post-processor-plugin.html'
}
},
preProcessorPlugin: {
src: [`${lessFolder}/preProcessorPlugin/*.less`],
options: {
helpers: [
'test/plugins/preprocess/index.js',
'test/browser/runner-preProcessorPlugin-options.js'
],
specs: 'test/browser/runner-preProcessorPlugin.js',
outfile: 'tmp/browser/test-runner-pre-processor-plugin.html'
}
},
visitorPlugin: {
src: [`${lessFolder}/visitorPlugin/*.less`],
options: {
helpers: [
'test/plugins/visitor/index.js',
'test/browser/runner-VisitorPlugin-options.js'
],
specs: 'test/browser/runner-VisitorPlugin.js',
outfile: 'tmp/browser/test-runner-visitor-plugin.html'
}
},
filemanagerPlugin: {
src: [`${lessFolder}/filemanagerPlugin/*.less`],
options: {
helpers: [
'test/plugins/filemanager/index.js',
'test/browser/runner-filemanagerPlugin-options.js'
],
specs: 'test/browser/runner-filemanagerPlugin.js',
outfile: 'tmp/browser/test-runner-filemanager-plugin.html'
}
}
}

2
node_modules/less/test/browser/generator/runner.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
const runner = require('./generate')
runner()

93
node_modules/less/test/browser/generator/template.js generated vendored Normal file
View File

@ -0,0 +1,93 @@
const html = require('html-template-tag')
const path = require('path')
const { forceCovertToBrowserPath } = require('./utils')
const webRoot = path.resolve(__dirname, '../../../../../');
const mochaDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha'))))
const chaiDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('chai'))))
const mochaTeamCityDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha-teamcity-reporter'))))
/**
* Generates HTML templates from list of test sheets
*/
module.exports = (stylesheets, helpers, spec, less) => {
if (!Array.isArray(helpers)) {
helpers = [helpers]
}
return html`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Less.js Spec Runner</title>
<!-- for each test, generate CSS/LESS link tags -->
$${stylesheets.map(function(fullLessName) {
var pathParts = fullLessName.split('/');
var fullCssName = fullLessName
.replace(/\/(browser|test-data)\/less\//g, '/$1/css/')
.replace(/less$/, 'css')
var lessName = pathParts[pathParts.length - 1];
var name = lessName.split('.')[0];
return `
<!-- the tags to be generated -->
<link id="original-less:test-less-${name}" title="test-less-${name}" rel="stylesheet/less" type="text/css" href="/${path.relative(webRoot, fullLessName)}">
<link id="expected-less:test-less-${name}" rel="stylesheet" type="text/css" href="/${path.relative(webRoot, fullCssName)}">
` }).join('')}
$${helpers.map(helper => `
<script src="../../${helper}"></script>
`).join('')}
<link rel="stylesheet" href="/${mochaDir}/mocha.css">
</head>
<body>
<!-- content -->
<div id="mocha"></div>
<script src="/${mochaDir}/mocha.js"></script>
<script src="/${mochaTeamCityDir}/teamcityBrowser.js"></script>
<script src="/${chaiDir}/chai.js"></script>
<script>
expect = chai.expect
mocha.setup({
ui: 'bdd',
timeout: 2500
});
</script>
<script src="common.js"></script>
<script src="../../${spec}"></script>
<script src="${less || 'less.min.js'}"></script>
<script>
/** Saucelabs config */
onload = function() {
var runner = mocha.run();
var failedTests = [];
runner.on('end', function() {
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
runner.on('fail', logFailure);
function logFailure(test, err){
var flattenTitles = function(test){
var titles = [];
while (test.parent.title) {
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
};
failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) });
};
};
</script>
</body>
</html>
`
}

14
node_modules/less/test/browser/generator/utils.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
/**
* utils for covert browser paths,
* fix https://github.com/less/less.js/pull/4213
*
* @param {string} path
* @returns {string}
*/
function forceCovertToBrowserPath (path) {
return (path || '').replace(/\\/g, '/');
}
module.exports = {
forceCovertToBrowserPath
}

View File

@ -0,0 +1,3 @@
.a {
prop: (3 / #fff);
}

View File

@ -0,0 +1,2 @@
less: OperationError: Can't subtract or divide a color from a number in {pathhref}console-errors/test-error.less on line null, column 0:
1 prop: (3 / #fff);

View File

@ -0,0 +1,3 @@
.test-height{
height: image-height("../data/image.jpg")
}

View File

@ -0,0 +1,4 @@
RuntimeError: Error evaluating function `image-height`: Image size functions are not supported in browser version of less in image-height-error.less on line 2, column 11:
1 .test-height{
2 height: image-height("../data/image.jpg")
3 }

View File

@ -0,0 +1,3 @@
.test-size{
size: image-size("../data/image.jpg")
}

View File

@ -0,0 +1,4 @@
RuntimeError: Error evaluating function `image-size`: Image size functions are not supported in browser version of less in image-size-error.less on line 2, column 9:
1 .test-size{
2 size: image-size("../data/image.jpg")
3 }

View File

@ -0,0 +1,3 @@
.test-width{
width: image-width("../data/image.jpg")
}

View File

@ -0,0 +1,4 @@
RuntimeError: Error evaluating function `image-width`: Image size functions are not supported in browser version of less in image-width-error.less on line 2, column 10:
1 .test-width{
2 width: image-width("../data/image.jpg")
3 }

View File

@ -0,0 +1,3 @@
.test {
color: @global-var;
}

View File

@ -0,0 +1,4 @@
@import "modify-this.css";
.modify {
my-url: url("a.png");
}

View File

@ -0,0 +1,4 @@
@import "modify-again.css";
.modify {
my-url: url("b.png");
}

View File

@ -0,0 +1,4 @@
@var2: blue;
.testisimported {
color: gainsboro;
}

View File

@ -0,0 +1,8 @@
@import "imports/simple2";
@var1: red;
@scale: 10;
.test {
color1: @var1;
color2: @var2;
scalar: @scale
}

View File

@ -0,0 +1,5 @@
@import "svg-gradient-mixin.less";
.gray-gradient {
.gradient-mixin(#999);
}

View File

@ -0,0 +1,15 @@
.gradient-mixin(@color) {
background: svg-gradient(to bottom,
fade(@color, 0%) 0%,
fade(@color, 5%) 60%,
fade(@color, 10%) 70%,
fade(@color, 15%) 73%,
fade(@color, 20%) 75%,
fade(@color, 25%) 80%,
fade(@color, 30%) 85%,
fade(@color, 35%) 88%,
fade(@color, 40%) 90%,
fade(@color, 45%) 95%,
fade(@color, 50%) 100%
);
}

4
node_modules/less/test/browser/less/plugin/plugin.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
functions.add('func', function() {
return less.anonymous(location.href);
});

View File

@ -0,0 +1,4 @@
@plugin "plugin";
.test {
val: func();
}

View File

@ -0,0 +1,4 @@
@color: white;
.test {
color: @color;
}

View File

@ -0,0 +1,34 @@
@import ".././imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}

View File

@ -0,0 +1,34 @@
@import ".././imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}

View File

@ -0,0 +1,33 @@
@import "../imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}

View File

@ -0,0 +1,33 @@
@import "../imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}

33
node_modules/less/test/browser/less/rootpath/urls.less generated vendored Normal file
View File

@ -0,0 +1,33 @@
@import "../imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}

62
node_modules/less/test/browser/less/urls.less generated vendored Normal file
View File

@ -0,0 +1,62 @@
@import "imports/urls.less";
@import "http://localhost:8081/packages/less/test/browser/less/imports/urls2.less";
@import "http://localhost:8081/packages/less/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}
#data-uri {
uri: data-uri('image/jpeg;base64', '../../data/image.jpg');
}
#data-uri-guess {
uri: data-uri('../../data/image.jpg');
}
#data-uri-ascii {
uri-1: data-uri('text/html', '../../data/page.html');
uri-2: data-uri('../../data/page.html');
}
#svg-functions {
@colorlist1: black, white;
background-image: svg-gradient(to bottom, @colorlist1);
background-image: svg-gradient(to bottom, black white);
background-image: svg-gradient(to bottom, black, orange 3%, white);
@colorlist2: black, orange 3%, white;
background-image: svg-gradient(to bottom, @colorlist2);
@green_5: green 5%;
@orange_percentage: 3%;
@orange_color: orange;
@colorlist3: (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%;
background-image: svg-gradient(to bottom,@colorlist3);
background-image: svg-gradient(to bottom, (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%);
}

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console',
plugins: [VisitorPlugin]};

View File

@ -0,0 +1,3 @@
describe('less.js Visitor Plugin', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,51 @@
var less = {
logLevel: 4,
errorReporting: 'console',
javascriptEnabled: true,
math: 'always'
};
// test inline less in style tags by grabbing an assortment of less files and doing `@import`s
var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
testSheets = [];
// setup style tags with less and link tags pointing to expected css output
/**
* @todo - generate the node_modules path for this file and in templates
*/
var lessFolder = '../../node_modules/@less/test-data/less'
var cssFolder = '../../node_modules/@less/test-data/css'
for (var i = 0; i < testFiles.length; i++) {
var file = testFiles[i],
lessPath = lessFolder + '/_main/' + file + '.less',
cssPath = cssFolder + '/_main/' + file + '.css',
lessStyle = document.createElement('style'),
cssLink = document.createElement('link'),
lessText = '@import "' + lessPath + '";';
lessStyle.type = 'text/less';
lessStyle.id = file;
lessStyle.href = file;
if (lessStyle.styleSheet === undefined) {
lessStyle.appendChild(document.createTextNode(lessText));
}
cssLink.rel = 'stylesheet';
cssLink.type = 'text/css';
cssLink.href = cssPath;
cssLink.id = 'expected-' + file;
var head = document.getElementsByTagName('head')[0];
head.appendChild(lessStyle);
if (lessStyle.styleSheet) {
lessStyle.styleSheet.cssText = lessText;
}
head.appendChild(cssLink);
testSheets[i] = lessStyle;
}

12
node_modules/less/test/browser/runner-browser-spec.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
describe('less.js browser behaviour', function() {
testLessEqualsInDocument();
it('has some log messages', function() {
expect(logMessages.length).to.be.above(0);
});
for (var i = 0; i < testFiles.length; i++) {
var sheet = testSheets[i];
testSheet(sheet);
}
});

View File

@ -0,0 +1,5 @@
less.errorReporting = 'console';
describe('less.js error reporting console test', function() {
testLessErrorsInDocument(true);
});

View File

@ -0,0 +1,6 @@
var less = {
strictUnits: true,
math: 'strict-legacy',
logLevel: 4,
javascriptEnabled: true
};

3
node_modules/less/test/browser/runner-errors-spec.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
describe('less.js error tests', function() {
testLessErrorsInDocument();
});

View File

@ -0,0 +1,5 @@
var less = {
logLevel: 4,
errorReporting: 'console',
plugins: [AddFilePlugin]
};

View File

@ -0,0 +1,3 @@
describe('less.js filemanager Plugin', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,7 @@
var less = {
logLevel: 4,
errorReporting: 'console',
globalVars: {
'@global-var': 'red'
}
};

View File

@ -0,0 +1,3 @@
describe('less.js global vars', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,6 @@
var less = {
logLevel: 4,
errorReporting: 'console',
math: 'always',
strictUnits: false
};

3
node_modules/less/test/browser/runner-legacy-spec.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
describe('less.js legacy tests', function() {
testLessEqualsInDocument();
});

17
node_modules/less/test/browser/runner-main-options.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
var less = {
logLevel: 4,
errorReporting: 'console'
};
less.functions = {
add: function(a, b) {
return new(less.tree.Dimension)(a.value + b.value);
},
increment: function(a) {
return new(less.tree.Dimension)(a.value + 1);
},
_color: function(str) {
if (str.value === 'evil red') {
return new(less.tree.Color)('600');
}
}
};

7
node_modules/less/test/browser/runner-main-spec.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
console.warn('start spec');
describe('less.js main tests', function() {
testLessEqualsInDocument();
it('the global environment', function() {
expect(window.require).to.be.undefined;
});
});

View File

@ -0,0 +1,5 @@
/* exported less */
var less = {
logLevel: 4,
errorReporting: 'console'
};

View File

@ -0,0 +1,33 @@
var alreadyRun = false;
describe('less.js modify vars', function () {
beforeEach(function (done) {
// simulating "setUp" or "beforeAll" method
if (alreadyRun) {
done();
return;
}
alreadyRun = true;
less.pageLoadFinished
.then(function () {
less.modifyVars({
var1: 'green',
var2: 'purple',
scale: 20
}).then(function () {
done();
});
});
});
testLessEqualsInDocument();
it('Should log only 2 XHR requests', function (done) {
var xhrLogMessages = logMessages.filter(function (item) {
return (/XHR: Getting '/).test(item);
});
expect(xhrLogMessages.length).to.equal(2);
done();
});
});

View File

@ -0,0 +1,4 @@
var less = {logLevel: 4};
less.strictUnits = true;
less.javascriptEnabled = false;

View File

@ -0,0 +1,3 @@
describe('less.js javascript disabled error tests', function() {
testLessErrorsInDocument();
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console',
plugins: [postProcessorPlugin]};

View File

@ -0,0 +1,3 @@
describe('less.js postProcessor Plugin', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console',
plugins: [preProcessorPlugin]};

View File

@ -0,0 +1,3 @@
describe('less.js preProcessor Plugin', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 1,
errorReporting: 'console'};
less.env = 'production';

View File

@ -0,0 +1,5 @@
describe('less.js production behaviour', function() {
it('doesn\'t log any messages', function() {
expect(logMessages.length).to.equal(0);
});
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console'};
less.relativeUrls = true;

View File

@ -0,0 +1,3 @@
describe('less.js browser test - relative url\'s', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console'};
less.rewriteUrls = 'all';

View File

@ -0,0 +1,3 @@
describe('less.js browser test - rewrite urls', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: 'console'};
less.rootpath = 'https://localhost/';

View File

@ -0,0 +1,4 @@
var less = {logLevel: 4,
errorReporting: 'console'};
less.rootpath = 'https://www.github.com/cloudhead/less.js/';
less.relativeUrls = true;

View File

@ -0,0 +1,3 @@
describe('less.js browser test - rootpath and relative urls', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,4 @@
var less = {logLevel: 4,
errorReporting: 'console'};
less.rootpath = 'https://www.github.com/cloudhead/less.js/';
less.rewriteUrls = 'all';

View File

@ -0,0 +1,3 @@
describe('less.js browser test - rootpath and rewrite urls', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,3 @@
describe('less.js browser test - rootpath url\'s', function() {
testLessEqualsInDocument();
});

View File

@ -0,0 +1,5 @@
var less = {
logLevel: 4,
errorReporting: 'console',
strictMath: true,
strictUnits: true };

View File

@ -0,0 +1,3 @@
describe('less.js strict units tests', function() {
testLessEqualsInDocument();
});

112
node_modules/less/test/index.js generated vendored Normal file
View File

@ -0,0 +1,112 @@
var lessTest = require('./less-test'),
lessTester = lessTest(),
path = require('path'),
stylize = require('../lib/less-node/lessc-helper').stylize,
nock = require('nock');
console.log('\n' + stylize('Less', 'underline') + '\n');
var testMap = [
[{
// TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
relativeUrls: true,
silent: true,
javascriptEnabled: true
}, '_main/'],
[{}, 'namespacing/'],
[{
math: 'parens'
}, 'math/strict/'],
[{
math: 'parens-division'
}, 'math/parens-division/'],
[{
math: 'always'
}, 'math/always/'],
// Use legacy strictMath: true here to demonstrate it still works
[{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/eval/',
lessTester.testErrors, null],
[{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/parse/',
lessTester.testErrors, null],
[{math: 'strict', strictUnits: true, javascriptEnabled: true}, 'js-type-errors/',
lessTester.testTypeErrors, null],
[{math: 'strict', strictUnits: true, javascriptEnabled: false}, 'no-js-errors/',
lessTester.testErrors, null],
[{math: 'strict', dumpLineNumbers: 'comments'}, 'debug/', null,
function(name) { return name + '-comments'; }],
[{math: 'strict', dumpLineNumbers: 'mediaquery'}, 'debug/', null,
function(name) { return name + '-mediaquery'; }],
[{math: 'strict', dumpLineNumbers: 'all'}, 'debug/', null,
function(name) { return name + '-all'; }],
// TODO: Change this to rewriteUrls: false once the relativeUrls option is removed
[{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'],
[{math: 'strict', compress: true}, 'compression/'],
[{math: 0, strictUnits: true}, 'units/strict/'],
[{math: 0, strictUnits: false}, 'units/no-strict/'],
[{math: 'strict', strictUnits: true, sourceMap: true, globalVars: true }, 'sourcemaps/',
lessTester.testSourcemap, null, null,
function(filename, type, baseFolder) {
if (type === 'vars') {
return path.join(baseFolder, filename) + '.json';
}
return path.join('test/sourcemaps', filename) + '.json';
}],
[{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
lessTester.testImports, null, true,
function(filename, type, baseFolder) {
return path.join(baseFolder, filename) + '.json';
}],
[{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
'sourcemaps-empty/', lessTester.testEmptySourcemap],
[{math: 'strict', strictUnits: true, sourceMap: {disableSourcemapAnnotation: true}},
'sourcemaps-disable-annotation/', lessTester.testSourcemapWithoutUrlAnnotation],
[{math: 'strict', strictUnits: true, sourceMap: true},
'sourcemaps-variable-selector/', lessTester.testSourcemapWithVariableInSelector],
[{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
[{modifyVars: true}, 'modifyVars/',
null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
[{urlArgs: '424242'}, 'url-args/'],
[{rewriteUrls: 'all'}, 'rewrite-urls-all/'],
[{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
[{paths: ['data/', '_main/import/']}, 'include-path/'],
[{paths: 'data/'}, 'include-path-string/'],
[{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
[{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
[{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
[{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
[{math: 0}, '3rd-party/'],
[{ processImports: false }, 'process-imports/']
];
testMap.forEach(function(args) {
lessTester.runTestSet.apply(lessTester, args)
});
lessTester.testSyncronous({syncImport: true}, '_main/import');
lessTester.testSyncronous({syncImport: true}, '_main/plugin');
lessTester.testSyncronous({syncImport: true}, 'math/strict/css');
lessTester.testNoOptions();
lessTester.testDisablePluginRule();
lessTester.testJSImport();
lessTester.finished();
(() => {
// Create new tester, since tests are not independent and tests
// above modify tester in a way that breaks remote imports.
lessTester = lessTest();
var scope = nock('https://example.com')
.get('/redirect.less').query(true)
.reply(301, null, { location: '/target.less' })
.get('/target.less').query(true)
.reply(200);
lessTester.runTestSet(
{},
'import-redirect/',
lessTester.testImportRedirect(scope)
);
lessTester.finished();
})();

623
node_modules/less/test/less-test.js generated vendored Normal file
View File

@ -0,0 +1,623 @@
/* jshint latedef: nofunc */
var semver = require('semver');
var logger = require('../lib/less/logger').default;
var isVerbose = process.env.npm_config_loglevel !== 'concise';
logger.addListener({
info(msg) {
if (isVerbose) {
process.stdout.write(msg + '\n');
}
},
warn(msg) {
process.stdout.write(msg + '\n');
},
erro(msg) {
process.stdout.write(msg + '\n');
}
});
module.exports = function() {
var path = require('path'),
fs = require('fs'),
clone = require('copy-anything').copy;
var less = require('../');
var stylize = require('../lib/less-node/lessc-helper').stylize;
var globals = Object.keys(global);
var oneTestOnly = process.argv[2],
isFinished = false;
var testFolder = path.dirname(require.resolve('@less/test-data'));
var lessFolder = path.join(testFolder, 'less');
// Define String.prototype.endsWith if it doesn't exist (in older versions of node)
// This is required by the testSourceMap function below
if (typeof String.prototype.endsWith !== 'function') {
String.prototype.endsWith = function (str) {
return this.slice(-str.length) === str;
}
}
var queueList = [],
queueRunning = false;
function queue(func) {
if (queueRunning) {
// console.log("adding to queue");
queueList.push(func);
} else {
// console.log("first in queue - starting");
queueRunning = true;
func();
}
}
function release() {
if (queueList.length) {
// console.log("running next in queue");
var func = queueList.shift();
setTimeout(func, 0);
} else {
// console.log("stopping queue");
queueRunning = false;
}
}
var totalTests = 0,
failedTests = 0,
passedTests = 0,
finishTimer = setInterval(endTest, 500);
less.functions.functionRegistry.addMultiple({
add: function (a, b) {
return new(less.tree.Dimension)(a.value + b.value);
},
increment: function (a) {
return new(less.tree.Dimension)(a.value + 1);
},
_color: function (str) {
if (str.value === 'evil red') { return new(less.tree.Color)('600'); }
}
});
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
if (err) {
fail('ERROR: ' + (err && err.message));
return;
}
// Check the sourceMappingURL at the bottom of the file
var expectedSourceMapURL = name + '.css.map',
sourceMappingPrefix = '/*# sourceMappingURL=',
sourceMappingSuffix = ' */',
expectedCSSAppendage = sourceMappingPrefix + expectedSourceMapURL + sourceMappingSuffix;
if (!compiledLess.endsWith(expectedCSSAppendage)) {
// To display a better error message, we need to figure out what the actual sourceMappingURL value was, if it was even present
var indexOfSourceMappingPrefix = compiledLess.indexOf(sourceMappingPrefix);
if (indexOfSourceMappingPrefix === -1) {
fail('ERROR: sourceMappingURL was not found in ' + baseFolder + '/' + name + '.css.');
return;
}
var startOfSourceMappingValue = indexOfSourceMappingPrefix + sourceMappingPrefix.length,
indexOfNextSpace = compiledLess.indexOf(' ', startOfSourceMappingValue),
actualSourceMapURL = compiledLess.substring(startOfSourceMappingValue, indexOfNextSpace === -1 ? compiledLess.length : indexOfNextSpace);
fail('ERROR: sourceMappingURL should be "' + expectedSourceMapURL + '" but is "' + actualSourceMapURL + '".');
}
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
if (sourcemap === expectedSourcemap) {
ok('OK');
} else if (err) {
fail('ERROR: ' + (err && err.message));
if (isVerbose) {
process.stdout.write('\n');
process.stdout.write(err.stack + '\n');
}
} else {
difference('FAIL', expectedSourcemap, sourcemap);
}
});
}
function testSourcemapWithoutUrlAnnotation(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
if (err) {
fail('ERROR: ' + (err && err.message));
return;
}
// This matches with strings that end($) with source mapping url annotation.
var sourceMapRegExp = /\/\*# sourceMappingURL=.+\.css\.map \*\/$/;
if (sourceMapRegExp.test(compiledLess)) {
fail('ERROR: sourceMappingURL found in ' + baseFolder + '/' + name + '.css.');
return;
}
// Even if annotation is not necessary, the map file should be there.
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
if (sourcemap === expectedSourcemap) {
ok('OK');
} else if (err) {
fail('ERROR: ' + (err && err.message));
if (isVerbose) {
process.stdout.write('\n');
process.stdout.write(err.stack + '\n');
}
} else {
difference('FAIL', expectedSourcemap, sourcemap);
}
});
}
function testEmptySourcemap(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
if (err) {
fail('ERROR: ' + (err && err.message));
} else {
var expectedSourcemap = undefined;
if ( compiledLess !== '' ) {
difference('\nCompiledLess must be empty', '', compiledLess);
} else if (sourcemap !== expectedSourcemap) {
fail('Sourcemap must be undefined');
} else {
ok('OK');
}
}
}
function testSourcemapWithVariableInSelector(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
if (err) {
fail('ERROR: ' + (err && err.message));
return;
}
// Even if annotation is not necessary, the map file should be there.
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
if (sourcemap === expectedSourcemap) {
ok('OK');
} else if (err) {
fail('ERROR: ' + (err && err.message));
if (isVerbose) {
process.stdout.write('\n');
process.stdout.write(err.stack + '\n');
}
} else {
difference('FAIL', expectedSourcemap, sourcemap);
}
});
}
function testImports(name, err, compiledLess, doReplacements, sourcemap, baseFolder, imports) {
if (err) {
fail('ERROR: ' + (err && err.message));
return;
}
function stringify(str) {
return JSON.stringify(imports, null, ' ')
}
/** Imports are not sorted */
const importsString = stringify(imports.sort())
fs.readFile(path.join(lessFolder, name) + '.json', 'utf8', function (e, expectedImports) {
if (e) {
fail('ERROR: ' + (e && e.message));
return;
}
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
expectedImports = stringify(JSON.parse(expectedImports).sort());
expectedImports = globalReplacements(expectedImports, baseFolder);
if (expectedImports === importsString) {
ok('OK');
} else if (err) {
fail('ERROR: ' + (err && err.message));
if (isVerbose) {
process.stdout.write('\n');
process.stdout.write(err.stack + '\n');
}
} else {
difference('FAIL', expectedImports, importsString);
}
});
}
function testErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
fs.readFile(path.join(baseFolder, name) + '.txt', 'utf8', function (e, expectedErr) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename);
if (!err) {
if (compiledLess) {
fail('No Error', 'red');
} else {
fail('No Error, No Output');
}
} else {
var errMessage = err.toString();
if (errMessage === expectedErr) {
ok('OK');
} else {
difference('FAIL', expectedErr, errMessage);
}
}
});
}
// To fix ci fail about error format change in upstream v8 project
// https://github.com/v8/v8/commit/c0fd89c3c089e888c4f4e8582e56db7066fa779b
// Node 16.9.0+ include this change via https://github.com/nodejs/node/pull/39947
function testTypeErrors(name, err, compiledLess, doReplacements, sourcemap, baseFolder) {
const fileSuffix = semver.gte(process.version, 'v16.9.0') ? '-2.txt' : '.txt';
fs.readFile(path.join(baseFolder, name) + fileSuffix, 'utf8', function (e, expectedErr) {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
expectedErr = doReplacements(expectedErr, baseFolder, err && err.filename);
if (!err) {
if (compiledLess) {
fail('No Error', 'red');
} else {
fail('No Error, No Output');
}
} else {
var errMessage = err.toString();
if (errMessage === expectedErr) {
ok('OK');
} else {
difference('FAIL', expectedErr, errMessage);
}
}
});
}
// https://github.com/less/less.js/issues/3112
function testJSImport() {
process.stdout.write('- Testing root function registry');
less.functions.functionRegistry.add('ext', function() {
return new less.tree.Anonymous('file');
});
var expected = '@charset "utf-8";\n';
toCSS({}, path.join(lessFolder, 'root-registry', 'root.less'), function(error, output) {
if (error) {
return fail('ERROR: ' + error);
}
if (output.css === expected) {
return ok('OK');
}
difference('FAIL', expected, output.css);
});
}
function globalReplacements(input, directory, filename) {
var path = require('path');
var p = filename ? path.join(path.dirname(filename), '/') : directory,
pathimport = path.join(directory + 'import/'),
pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); }),
pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a == '\\' ? '\/' : a); });
return input.replace(/\{path\}/g, p)
.replace(/\{node\}/g, '')
.replace(/\{\/node\}/g, '')
.replace(/\{pathhref\}/g, '')
.replace(/\{404status\}/g, '')
.replace(/\{nodepath\}/g, path.join(process.cwd(), 'node_modules', '/'))
.replace(/\{pathrel\}/g, path.join(path.relative(lessFolder, p), '/'))
.replace(/\{pathesc\}/g, pathesc)
.replace(/\{pathimport\}/g, pathimport)
.replace(/\{pathimportesc\}/g, pathimportesc)
.replace(/\r\n/g, '\n');
}
function checkGlobalLeaks() {
return Object.keys(global).filter(function(v) {
return globals.indexOf(v) < 0;
});
}
function testSyncronous(options, filenameNoExtension) {
if (oneTestOnly && ('Test Sync ' + filenameNoExtension) !== oneTestOnly) {
return;
}
totalTests++;
queue(function() {
var isSync = true;
toCSS(options, path.join(lessFolder, filenameNoExtension + '.less'), function (err, result) {
process.stdout.write('- Test Sync ' + filenameNoExtension + ': ');
if (isSync) {
ok('OK');
} else {
fail('Not Sync');
}
release();
});
isSync = false;
});
}
function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
options = options ? clone(options) : {};
runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
}
function runTestSetNormalOnly(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
runTestSetInternal(lessFolder, options, foldername, verifyFunction, nameModifier, doReplacements, getFilename);
}
function runTestSetInternal(baseFolder, opts, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
foldername = foldername || '';
var originalOptions = opts || {};
if (!doReplacements) {
doReplacements = globalReplacements;
}
function getBasename(file) {
return foldername + path.basename(file, '.less');
}
fs.readdirSync(path.join(baseFolder, foldername)).forEach(function (file) {
if (!/\.less$/.test(file)) { return; }
var options = clone(originalOptions);
var name = getBasename(file);
if (oneTestOnly && name !== oneTestOnly) {
return;
}
totalTests++;
if (options.sourceMap && !options.sourceMap.sourceMapFileInline) {
options.sourceMap = {
sourceMapOutputFilename: name + '.css',
sourceMapBasepath: baseFolder,
sourceMapRootpath: 'testweb/',
disableSourcemapAnnotation: options.sourceMap.disableSourcemapAnnotation
};
// This options is normally set by the bin/lessc script. Setting it causes the sourceMappingURL comment to be appended to the CSS
// output. The value is designed to allow the sourceMapBasepath option to be tested, as it should be removed by less before
// setting the sourceMappingURL value, leaving just the sourceMapOutputFilename and .map extension.
options.sourceMap.sourceMapFilename = options.sourceMap.sourceMapBasepath + '/' + options.sourceMap.sourceMapOutputFilename + '.map';
}
options.getVars = function(file) {
try {
return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars', baseFolder), 'utf8'));
}
catch (e) {
return {};
}
};
var doubleCallCheck = false;
queue(function() {
toCSS(options, path.join(baseFolder, foldername + file), function (err, result) {
if (doubleCallCheck) {
totalTests++;
fail('less is calling back twice');
process.stdout.write(doubleCallCheck + '\n');
process.stdout.write((new Error()).stack + '\n');
return;
}
doubleCallCheck = (new Error()).stack;
/**
* @todo - refactor so the result object is sent to the verify function
*/
if (verifyFunction) {
var verificationResult = verifyFunction(
name, err, result && result.css, doReplacements, result && result.map, baseFolder, result && result.imports
);
release();
return verificationResult;
}
if (err) {
fail('ERROR: ' + (err && err.message));
if (isVerbose) {
process.stdout.write('\n');
if (err.stack) {
process.stdout.write(err.stack + '\n');
} else {
// this sometimes happen - show the whole error object
console.log(err);
}
}
release();
return;
}
var css_name = name;
if (nameModifier) { css_name = nameModifier(name); }
fs.readFile(path.join(testFolder, 'css', css_name) + '.css', 'utf8', function (e, css) {
process.stdout.write('- ' + path.join(baseFolder, css_name) + ': ');
css = css && doReplacements(css, path.join(baseFolder, foldername));
if (result.css === css) { ok('OK'); }
else {
difference('FAIL', css, result.css);
}
release();
});
});
});
});
}
function diff(left, right) {
require('diff').diffLines(left, right).forEach(function(item) {
if (item.added || item.removed) {
var text = item.value && item.value.replace('\n', String.fromCharCode(182) + '\n').replace('\ufeff', '[[BOM]]');
process.stdout.write(stylize(text, item.added ? 'green' : 'red'));
} else {
process.stdout.write(item.value && item.value.replace('\ufeff', '[[BOM]]'));
}
});
process.stdout.write('\n');
}
function fail(msg) {
process.stdout.write(stylize(msg, 'red') + '\n');
failedTests++;
endTest();
}
function difference(msg, left, right) {
process.stdout.write(stylize(msg, 'yellow') + '\n');
failedTests++;
diff(left || '', right || '');
endTest();
}
function ok(msg) {
process.stdout.write(stylize(msg, 'green') + '\n');
passedTests++;
endTest();
}
function finished() {
isFinished = true;
endTest();
}
function endTest() {
if (isFinished && ((failedTests + passedTests) >= totalTests)) {
clearInterval(finishTimer);
var leaked = checkGlobalLeaks();
process.stdout.write('\n');
if (failedTests > 0) {
process.stdout.write(failedTests + stylize(' Failed', 'red') + ', ' + passedTests + ' passed\n');
} else {
process.stdout.write(stylize('All Passed ', 'green') + passedTests + ' run\n');
}
if (leaked.length > 0) {
process.stdout.write('\n');
process.stdout.write(stylize('Global leak detected: ', 'red') + leaked.join(', ') + '\n');
}
if (leaked.length || failedTests) {
process.on('exit', function() { process.reallyExit(1); });
}
}
}
function contains(fullArray, obj) {
for (var i = 0; i < fullArray.length; i++) {
if (fullArray[i] === obj) {
return true;
}
}
return false;
}
/**
*
* @param {Object} options
* @param {string} filePath
* @param {Function} callback
*/
function toCSS(options, filePath, callback) {
options = options || {};
var str = fs.readFileSync(filePath, 'utf8'), addPath = path.dirname(filePath);
if (typeof options.paths !== 'string') {
options.paths = options.paths || [];
if (!contains(options.paths, addPath)) {
options.paths.push(addPath);
}
} else {
options.paths = [options.paths]
}
options.paths = options.paths.map(searchPath => {
return path.resolve(lessFolder, searchPath)
})
options.filename = path.resolve(process.cwd(), filePath);
options.optimization = options.optimization || 0;
if (options.globalVars) {
options.globalVars = options.getVars(filePath);
} else if (options.modifyVars) {
options.modifyVars = options.getVars(filePath);
}
if (options.plugin) {
var Plugin = require(path.resolve(process.cwd(), options.plugin));
options.plugins = [Plugin];
}
less.render(str, options, callback);
}
function testNoOptions() {
if (oneTestOnly && 'Integration' !== oneTestOnly) {
return;
}
totalTests++;
try {
process.stdout.write('- Integration - creating parser without options: ');
less.render('');
} catch (e) {
fail(stylize('FAIL\n', 'red'));
return;
}
ok(stylize('OK\n', 'green'));
}
function testImportRedirect(nockScope) {
return (name, err, css, doReplacements, sourcemap, baseFolder) => {
process.stdout.write('- ' + path.join(baseFolder, name) + ': ');
if (err) {
fail('FAIL: ' + (err && err.message));
return;
}
const expected = 'h1 {\n color: red;\n}\n';
if (css !== expected) {
difference('FAIL', expected, css);
return;
}
nockScope.done();
ok('OK');
};
}
function testDisablePluginRule() {
less.render(
'@plugin "../../plugin/some_plugin";',
{disablePluginRule: true},
function(err) {
// TODO: Need a better way of identifing exactly which error is thrown. Checking
// text like this tends to be rather brittle.
const EXPECTED = '@plugin statements are not allowed when disablePluginRule is set to true';
if (!err || String(err).indexOf(EXPECTED) < 0) {
fail('ERROR: Expected "' + EXPECTED + '" error');
return;
}
ok(stylize('OK\n', 'green'));
}
);
}
return {
runTestSet: runTestSet,
runTestSetNormalOnly: runTestSetNormalOnly,
testSyncronous: testSyncronous,
testErrors: testErrors,
testTypeErrors: testTypeErrors,
testSourcemap: testSourcemap,
testSourcemapWithoutUrlAnnotation: testSourcemapWithoutUrlAnnotation,
testSourcemapWithVariableInSelector: testSourcemapWithVariableInSelector,
testImports: testImports,
testImportRedirect: testImportRedirect,
testEmptySourcemap: testEmptySourcemap,
testNoOptions: testNoOptions,
testDisablePluginRule: testDisablePluginRule,
testJSImport: testJSImport,
finished: finished
};
};

28
node_modules/less/test/modify-vars.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
var less;
// Dist fallback for NPM-installed Less (for plugins that do testing)
try {
less = require('../tmp/less.cjs.js');
}
catch (e) {
less = require('../dist/less.cjs.js');
}
var fs = require('fs');
var input = fs.readFileSync('./test/less/modifyVars/extended.less', 'utf8');
var expectedCss = fs.readFileSync('./test/css/modifyVars/extended.css', 'utf8');
var options = {
modifyVars: JSON.parse(fs.readFileSync('./test/less/modifyVars/extended.json', 'utf8'))
};
less.render(input, options, function (err, result) {
if (err) {
console.log(err);
}
if (result.css === expectedCss) {
console.log('PASS');
} else {
console.log('FAIL');
}
});

19
node_modules/less/test/plugins/filemanager/index.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
(function(exports) {
var plugin = function(less) {
var FileManager = less.FileManager, TestFileManager = new FileManager();
function TestFileManager() { }
TestFileManager.loadFile = function (filename, currentDirectory, options, environment, callback) {
if (filename.match(/.*\.test$/)) {
return less.environment.fileManagers[0].loadFile('colors.test', currentDirectory, options, environment, callback);
}
return less.environment.fileManagers[0].loadFile(filename, currentDirectory, options, environment, callback);
};
return TestFileManager;
};
exports.install = function(less, pluginManager) {
less.environment.addFileManager(new plugin(less));
};
})(typeof exports === 'undefined' ? this['AddFilePlugin'] = {} : exports);

14
node_modules/less/test/plugins/postprocess/index.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
(function(exports) {
var postProcessor = function() {};
postProcessor.prototype = {
process: function (css) {
return 'hr {height:50px;}\n' + css;
}
};
exports.install = function(less, pluginManager) {
pluginManager.addPostProcessor( new postProcessor());
};
})(typeof exports === 'undefined' ? this['postProcessorPlugin'] = {} : exports);

19
node_modules/less/test/plugins/preprocess/index.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
(function(exports) {
var preProcessor = function() {};
preProcessor.prototype = {
process : function (src, extra) {
var injected = '@color: red;\n';
var ignored = extra.imports.contentsIgnoredChars;
var fileInfo = extra.fileInfo;
ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;
ignored[fileInfo.filename] += injected.length;
return injected + src;
}
};
exports.install = function(less, pluginManager) {
pluginManager.addPreProcessor( new preProcessor() );
};
})(typeof exports === 'undefined' ? this['preProcessorPlugin'] = {} : exports);

24
node_modules/less/test/plugins/visitor/index.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
(function(exports) {
var RemoveProperty = function(less) {
this._visitor = new less.visitors.Visitor(this);
};
RemoveProperty.prototype = {
isReplacing: true,
run: function (root) {
return this._visitor.visit(root);
},
visitDeclaration: function (ruleNode, visitArgs) {
if (ruleNode.name != '-some-aribitrary-property') {
return ruleNode;
} else {
return [];
}
}
};
exports.install = function(less, pluginManager) {
pluginManager.addVisitor( new RemoveProperty(less));
};
})(typeof exports === 'undefined' ? this['VisitorPlugin'] = {} : exports);

View File

@ -0,0 +1 @@
{"version":3,"sources":["testweb/sourcemaps-disable-annotation/basic.less"],"names":[],"mappings":"AAAA;;EAEE,YAAA","file":"sourcemaps-disable-annotation/basic.css"}

View File

@ -0,0 +1 @@
{"version":3,"sources":["testweb/sourcemaps-variable-selector/basic.less"],"names":[],"mappings":"AAEC;EACG,eAAA","file":"sourcemaps-variable-selector/basic.css"}

1
node_modules/less/test/sourcemaps/basic.json generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["testweb/sourcemaps/basic.less","testweb/sourcemaps/imported.css"],"names":[],"mappings":"AAMA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,iBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAQN,OARE,GAQF,UARE;AAQF,OARE,GAEI,KAFJ;AAQF,OARE,GAQF,UARM;AAQN,OARE,GAEI,KAFA;AAEF,EAFF,GAQF,UARE;AAEE,EAFF,GAQF,UARM;AAQN,OARM,GAQN,UARE;AAQF,OARM,GAEA,KAFJ;AAQF,OARM,GAQN,UARM;AAQN,OARM,GAEA,KAFA;AAEF,EAFE,GAQN,UARE;AAEE,EAFE,GAQN,UARM;EAGA,UAAA;;AAKN;EACE,WAAA;;ACxBF;AACA;AACA;AACA;AACA;AACA;AACA","file":"sourcemaps/basic.css"}

1
node_modules/less/test/sourcemaps/custom-props.json generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["testweb/sourcemaps/custom-props.less"],"names":[],"mappings":"AAEA;EACC,uBAHO,UAGP;EACA,OAAO,eAAP;EACA,sBALO,UAKP","file":"sourcemaps/custom-props.css"}

17
node_modules/less/test/sourcemaps/index.html generated vendored Normal file
View File

@ -0,0 +1,17 @@
<html>
<link type="text/css" rel="stylesheet" media="all" href="import.css">
<link type="text/css" rel="stylesheet" media="all" href="basic.css">
<head>
</head>
<body>
<div id="import-test">id import-test</div>
<div id="import">id import-test</div>
<div class="imported inline">class imported inline</div>
<div id="mixin">class mixin</div>
<div class="a">class a</div>
<div class="b">class b</div>
<div class="b">class b<div class="c">class c</div></div>
<div class="a">class a<div class="d">class d</div></div>
<div class="extend">class extend<div class="c">class c</div></div>
</body>
</html>

17
node_modules/less/test/test-es6.ts generated vendored Normal file
View File

@ -0,0 +1,17 @@
// https://github.com/less/less.js/issues/3533
console.log('Testing ES6 imports...')
import less from '..';
const lessRender = less.render;
// then I call lessRender on something
lessRender(`
body {
a: 1;
b: 2;
c: 30;
d: 4;
}`, {sourceMap: {}}, function(error: any, output: any) {
if (error)
console.error(error)
})