1
0
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:
Elan Ruusamäe
2016-12-06 14:46:46 +02:00
parent b8c79ac8d4
commit 8949df33dd
4 changed files with 38 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -0,0 +1,7 @@
(function() {
/**
* @type {string}
*/
var $array = jQuery.find('#div');
print($array.find('a'));
})();

View File

@@ -0,0 +1 @@
(function(){var a=jQuery.find("#div");print(a.find("a"))})();