From 43174dd252e09b93931e5f604f1a391b4e379bde Mon Sep 17 00:00:00 2001 From: cloudhead Date: Thu, 25 Feb 2010 15:50:46 -0500 Subject: [PATCH] preliminary test file --- test/less-test.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/less-test.js diff --git a/test/less-test.js b/test/less-test.js new file mode 100644 index 0000000..0e6350e --- /dev/null +++ b/test/less-test.js @@ -0,0 +1,51 @@ +var path = require('path'), + fs = require('fs'), + sys = require('sys'); + +require.paths.unshift(__dirname, path.join(__dirname, '..'), + path.join(__dirname, 'vendor', 'vows')); + +var vows = require('lib/vows'); + +GLOBAL.inspect = inspect; + +var less = require('lib/less/adapters/server'); + +fs.readdirSync('test/less').forEach(function (file) { + toCSS('test/less/' + file, function (err, less) { + read(path.join('test/css', path.basename(file, '.less')) + '.css', function (e, css) { + sys.print(file + ": ") + if (less === css) { sys.print('OK') } + else { sys.print(e || err) } + sys.puts(""); + }); + }); +}); + +function toCSS(path, callback) { + read(path, function (e, str) { + if (e) { return callback(e) } + try { + callback(null, less.parser.parse(str).toCSS([], {frames: []})); + } catch (e) { + callback(e); + } + }); +} + +function read(path, callback) { + fs.stat(path, function (e, stats) { + if (e) return callback(e); + fs.open(path, process.O_RDONLY, stats.mode, function (e, fd) { + fs.read(fd, stats.size, 0, "utf8", function (e, data) { + callback(null, data); + }); + }); + }); +} + + +vows.tell('LeSS', function () {}); + + +