uglify-js
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -10,3 +10,3 @@ { | ||
"version" : "1.0.3", | ||
"version" : "1.0.4", | ||
@@ -13,0 +13,0 @@ "main" : "./uglify-js.js", |
@@ -20,28 +20,37 @@ var fs = require('fs'), | ||
module.exports = nodeunit.testCase({ | ||
compress: function(test) { | ||
var testDir = path.join(scriptsPath, "compress", "test"); | ||
var expectedDir = path.join(scriptsPath, "compress", "expected"); | ||
var testDir = path.join(scriptsPath, "compress", "test"); | ||
var expectedDir = path.join(scriptsPath, "compress", "expected"); | ||
var scripts = fs.readdirSync(testDir); | ||
for (var i in scripts) { | ||
var script = scripts[i]; | ||
testPath = path.join(testDir, script); | ||
expectedPath = path.join(expectedDir, script); | ||
var content = fs.readFileSync(testPath, 'utf-8'); | ||
var outputCompress = compress(content); | ||
function getTester(script) { | ||
return function(test) { | ||
var testPath = path.join(testDir, script); | ||
var expectedPath = path.join(expectedDir, script); | ||
var content = fs.readFileSync(testPath, 'utf-8'); | ||
var outputCompress = compress(content); | ||
// Check if the noncompressdata is larger or same size as the compressed data | ||
test.ok(content.length >= outputCompress.length); | ||
// Check if the noncompressdata is larger or same size as the compressed data | ||
test.ok(content.length >= outputCompress.length); | ||
// Check that a recompress gives the same result | ||
var outputReCompress = compress(content); | ||
test.equal(outputCompress, outputReCompress); | ||
// Check that a recompress gives the same result | ||
var outputReCompress = compress(content); | ||
test.equal(outputCompress, outputReCompress); | ||
// Check if the compressed output is what is expected | ||
var expected = fs.readFileSync(expectedPath, 'utf-8'); | ||
test.equal(outputCompress, expected.replace(/(\r?\n)+$/, "")); | ||
} | ||
// Check if the compressed output is what is expected | ||
var expected = fs.readFileSync(expectedPath, 'utf-8'); | ||
test.equal(outputCompress, expected.replace(/(\r?\n)+$/, "")); | ||
test.done(); | ||
}; | ||
}; | ||
var tests = {}; | ||
var scripts = fs.readdirSync(testDir); | ||
for (var i in scripts) { | ||
var script = scripts[i]; | ||
if (/\.js$/.test(script)) { | ||
tests[script] = getTester(script); | ||
} | ||
}); | ||
} | ||
module.exports = nodeunit.testCase(tests); |
Sorry, the diff of this file is too big to display
222399
89
3705