mirror of
https://github.com/mrclay/minify.git
synced 2025-08-09 23:56:43 +02:00
add testcase for js minify that produces $jscomp polyfills
with recent closure compiler default input language has changed from ES3 to ES6 produces $jscomp polyfills
This commit is contained in:
@@ -80,12 +80,22 @@ class MinifyClosureCompilerTest extends TestCase
|
||||
{
|
||||
$this->assertHasJar();
|
||||
|
||||
$src = file_get_contents(self::$test_files . '/bug-513.js');
|
||||
$src = $this->getDataFile('bug-513.js');
|
||||
$minExpected = 'var a=4;';
|
||||
$minOutput = Minify_ClosureCompiler::minify($src);
|
||||
$this->assertSame($minExpected, $minOutput, 'advanced optimizations');
|
||||
}
|
||||
|
||||
public function testOptions()
|
||||
{
|
||||
$this->assertHasJar();
|
||||
|
||||
$src = $this->getDataFile('js/jscomp.polyfill.js');
|
||||
$exp = $this->getDataFile('js/jscomp.polyfill.min.js');
|
||||
$res = Minify_ClosureCompiler::minify($src);
|
||||
$this->assertSame($exp, $res);
|
||||
}
|
||||
|
||||
protected function assertHasJar()
|
||||
{
|
||||
$this->assertNotEmpty(Minify_ClosureCompiler::$jarFile);
|
||||
|
@@ -47,4 +47,23 @@ class TestCase extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame($data, $displayed, "$id display");
|
||||
$this->assertEquals($data, $cache->fetch($id), "$id fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data file, assert that it exists and is not empty.
|
||||
* As a side effect calls trim() to fight against different Editors that insert or strip final newline.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
protected function getDataFile($filename)
|
||||
{
|
||||
$path = self::$test_files . '/' . $filename;
|
||||
$this->assertFileExists($path);
|
||||
$contents = file_get_contents($path);
|
||||
$this->assertNotEmpty($contents);
|
||||
$contents = trim($contents);
|
||||
$this->assertNotEmpty($contents);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
}
|
7
tests/_test_files/js/jscomp.polyfill.js
Normal file
7
tests/_test_files/js/jscomp.polyfill.js
Normal file
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
var $array = jQuery.find('#div');
|
||||
print($array.find('a'));
|
||||
})();
|
1
tests/_test_files/js/jscomp.polyfill.min.js
vendored
Normal file
1
tests/_test_files/js/jscomp.polyfill.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(){var a=jQuery.find("#div");print(a.find("a"))})();
|
Reference in New Issue
Block a user