1
0
mirror of https://github.com/mrclay/minify.git synced 2025-01-17 21:28:14 +01:00

test $jscomp polyfill output

This commit is contained in:
Elan Ruusamäe 2016-12-06 17:00:58 +02:00
parent 6a330d9091
commit 8fe915f486
2 changed files with 19 additions and 2 deletions

View File

@ -86,13 +86,27 @@ class MinifyClosureCompilerTest extends TestCase
$this->assertSame($minExpected, $minOutput, 'advanced optimizations');
}
public function testOptions()
/**
* Test that language_in parameter has effect.
*/
public function testLanguageOptions()
{
$this->assertHasJar();
$src = $this->getDataFile('js/jscomp.polyfill.js');
$exp = $this->getDataFile('js/jscomp.polyfill.min.js');
$res = Minify_ClosureCompiler::minify($src);
$options = array(
'language_in' => 'ECMASCRIPT3',
);
$res = Minify_ClosureCompiler::minify($src, $options);
$this->assertSame($exp, $res);
$options = array(
'language_in' => 'ECMASCRIPT6',
);
$exp = $this->getDataFile('js/jscomp.polyfilled.min.js');
$res = Minify_ClosureCompiler::minify($src, $options);
$this->assertSame($exp, $res);
}

View File

@ -0,0 +1,3 @@
var $jscomp={scope:{},findInternal:function(a,c,b){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(c.call(b,f,e,a))return{i:e,v:f}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){if(b.get||b.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in b||(b[e]={});b=b[e]}a=a[a.length-1];d=b[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:c})}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6-impl","es3");(function(){var a=jQuery.find("#div");print(a.find("a"))})();