mirror of
https://github.com/mrclay/minify.git
synced 2025-08-06 06:07:24 +02:00
test $jscomp polyfill output
This commit is contained in:
@@ -86,13 +86,27 @@ class MinifyClosureCompilerTest extends TestCase
|
|||||||
$this->assertSame($minExpected, $minOutput, 'advanced optimizations');
|
$this->assertSame($minExpected, $minOutput, 'advanced optimizations');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptions()
|
/**
|
||||||
|
* Test that language_in parameter has effect.
|
||||||
|
*/
|
||||||
|
public function testLanguageOptions()
|
||||||
{
|
{
|
||||||
$this->assertHasJar();
|
$this->assertHasJar();
|
||||||
|
|
||||||
$src = $this->getDataFile('js/jscomp.polyfill.js');
|
$src = $this->getDataFile('js/jscomp.polyfill.js');
|
||||||
$exp = $this->getDataFile('js/jscomp.polyfill.min.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);
|
$this->assertSame($exp, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
tests/_test_files/js/jscomp.polyfilled.min.js
vendored
Normal file
3
tests/_test_files/js/jscomp.polyfilled.min.js
vendored
Normal 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"))})();
|
Reference in New Issue
Block a user