mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
Add _.support unit tests and remove _.support from the lodash underscore build.
Former-commit-id: 986c02d5363329f16cde720430b26edb6bc865f0
This commit is contained in:
3
build.js
3
build.js
@@ -2432,6 +2432,9 @@
|
||||
});
|
||||
}());
|
||||
|
||||
// unexpose `lodash.support`
|
||||
source = source.replace(/lodash\.support *= */, '');
|
||||
|
||||
// remove `thisArg` from unexposed `forIn` and `forOwn`
|
||||
_.each([
|
||||
{ 'methodName': 'forIn', 'flag': exposeForIn },
|
||||
|
||||
2
dist/lodash.underscore.js
vendored
2
dist/lodash.underscore.js
vendored
@@ -188,7 +188,7 @@
|
||||
* @memberOf _
|
||||
* @type Object
|
||||
*/
|
||||
var support = lodash.support = {};
|
||||
var support = {};
|
||||
|
||||
(function() {
|
||||
var object = { '0': 1, 'length': 1 };
|
||||
|
||||
2
dist/lodash.underscore.min.js
vendored
2
dist/lodash.underscore.min.js
vendored
@@ -16,7 +16,7 @@ if(typeof u!="number")var i=It(n),u=i.length;return t=W(t,e,4),B(n,function(e,a,
|
||||
}}function T(n,t){for(var r=-1,e=n?n.length:0,u=[];++r<e;){var o=n[r];$t(o)?At.apply(u,t?o:T(o)):u.push(o)}return u}function z(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?Ft(0,u+r):r||0)-1;else if(r)return e=P(n,t),n[e]===t?e:-1;for(;++e<u;)if(n[e]===t)return e;return-1}function C(n,t,r){if(typeof t!="number"&&t!=K){var e=0,u=-1,o=n?n.length:0;for(t=W(t,r);++u<o&&t(n[u],u,n);)e++}else e=t==K||r?1:Ft(0,t);return s(n,e)}function P(n,t,r,e){var u=0,o=n?n.length:u;for(r=r?W(r,e,1):G,t=r(t);u<o;)e=u+o>>>1,r(n[e])<t?u=e+1:o=e;
|
||||
return u}function U(n,t,r,e){var u=-1,o=n?n.length:0,i=[],a=i;for(typeof t!="boolean"&&t!=K&&(e=r,r=t,t=L),r!=K&&(a=[],r=W(r,e));++u<o;){e=n[u];var f=r?r(e,u,n):e;(t?!u||a[a.length-1]!==f:0>z(a,f))&&(r&&a.push(f),i.push(e))}return i}function V(n,t){return Mt.fastBind||Et&&2<arguments.length?Et.call.apply(Et,arguments):i(n,t,s(arguments,2))}function W(n,t,r){if(n==K)return G;var e=typeof n;if("function"!=e){if("object"!=e)return function(t){return t[n]};var u=It(n);return function(t){for(var r=u.length,e=L;r--&&(e=t[u[r]]===n[u[r]]););return e
|
||||
}}return typeof t!="undefined"?1===r?function(r){return n.call(t,r)}:2===r?function(r,e){return n.call(t,r,e)}:4===r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n}function G(n){return n}function H(n){B(m(n),function(t){var r=u[t]=n[t];u.prototype[t]=function(){var n=[this.__wrapped__];return At.apply(n,arguments),n=r.apply(u,n),this.__chain__&&(n=new c(n),n.__chain__=J),n}})}var J=!0,K=null,L=!1,Q=typeof exports=="object"&&exports,X=typeof module=="object"&&module&&module.exports==Q&&module,Y=typeof global=="object"&&global;
|
||||
Y.global===Y&&(n=Y);var Z=0,nt={},tt=/&(?:amp|lt|gt|quot|#39);/g,rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot="[object Arguments]",it="[object Array]",at="[object Boolean]",ft="[object Date]",ct="[object Number]",lt="[object Object]",st="[object RegExp]",pt="[object String]",vt={"boolean":L,"function":J,object:J,number:L,string:L,undefined:L},gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},ht=[],Y={},yt=n._,mt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),_t=Math.ceil,dt=n.clearTimeout,bt=ht.concat,jt=Math.floor,wt=Y.hasOwnProperty,At=ht.push,xt=n.setTimeout,Ot=Y.toString,Et=mt.test(Et=s.bind)&&Et,St=mt.test(St=Array.isArray)&&St,Nt=n.isFinite,kt=n.isNaN,Bt=mt.test(Bt=Object.keys)&&Bt,Ft=Math.max,Rt=Math.min,qt=Math.random,Y=mt.test(n.attachEvent),Dt=Et&&!/\n|true/.test(Et+Y),Mt=u.support={};
|
||||
Y.global===Y&&(n=Y);var Z=0,nt={},tt=/&(?:amp|lt|gt|quot|#39);/g,rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot="[object Arguments]",it="[object Array]",at="[object Boolean]",ft="[object Date]",ct="[object Number]",lt="[object Object]",st="[object RegExp]",pt="[object String]",vt={"boolean":L,"function":J,object:J,number:L,string:L,undefined:L},gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},ht=[],Y={},yt=n._,mt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),_t=Math.ceil,dt=n.clearTimeout,bt=ht.concat,jt=Math.floor,wt=Y.hasOwnProperty,At=ht.push,xt=n.setTimeout,Ot=Y.toString,Et=mt.test(Et=s.bind)&&Et,St=mt.test(St=Array.isArray)&&St,Nt=n.isFinite,kt=n.isNaN,Bt=mt.test(Bt=Object.keys)&&Bt,Ft=Math.max,Rt=Math.min,qt=Math.random,Y=mt.test(n.attachEvent),Dt=Et&&!/\n|true/.test(Et+Y),Mt={};
|
||||
(function(){var n={0:1,length:1};Mt.argsObject=arguments.constructor==Object,Mt.fastBind=Et&&!Dt,Mt.spliceObjects=(ht.splice.call(n,0,1),!n[0])})(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},c.prototype=u.prototype,v(arguments)||(v=function(n){return n?wt.call(n,"callee"):L});var $t=St||function(n){return Mt.argsObject&&n instanceof Array||Ot.call(n)==it},It=Bt?function(n){return w(n)?Bt(n):[]}:g,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},zt=_(Tt);
|
||||
j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==Ot.call(n)});var Ct=F;u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=V,u.bindAll=function(n){for(var t=bt.apply(ht,arguments),r=1<t.length?0:(t=m(n),-1),e=t.length;++r<e;){var u=t[r];n[u]=V(n[u],n)}return n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];++t<r;){var u=n[t];u&&e.push(u)}return e},u.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];
|
||||
return t[0]}},u.countBy=function(n,t,r){var e={};return t=W(t,r),B(n,function(n,r,u){r=t(n,r,u)+"",wt.call(e,r)?e[r]++:e[r]=1}),e},u.debounce=function(n,t,r){function e(){a=K,r||(o=n.apply(i,u))}var u,o,i,a;return function(){var f=r&&!a;return u=arguments,i=this,dt(a),a=xt(e,t),f&&(o=n.apply(i,u)),o}},u.defaults=y,u.defer=function(n){var t=s(arguments,1);return xt(function(){n.apply(void 0,t)},1)},u.delay=function(n,t){var r=s(arguments,2);return xt(function(){n.apply(void 0,r)},t)},u.difference=function(n){for(var t=-1,r=n.length,e=bt.apply(ht,arguments),u=[];++t<r;){var o=n[t];
|
||||
|
||||
@@ -913,6 +913,7 @@
|
||||
strictEqual(lodash.some([false, true, false]), true, '_.some: ' + basename);
|
||||
deepEqual(lodash.times(null, function() {}), [null], '_.times should not coerce `n` to a number: ' + basename);
|
||||
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
||||
equal('support' in lodash, false, '_.support should not exist: ' + basename);
|
||||
equal('imports' in lodash.templateSettings, false, '_.templateSettings should not have an "imports" property: ' + basename);
|
||||
strictEqual(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
|
||||
|
||||
|
||||
31
test/test.js
31
test/test.js
@@ -2244,7 +2244,6 @@
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.some');
|
||||
@@ -2329,6 +2328,36 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.support');
|
||||
|
||||
(function() {
|
||||
test('should contain properties with boolean values', function() {
|
||||
var props = [
|
||||
'argsObject',
|
||||
'argsClass',
|
||||
'enumPrototypes',
|
||||
'fastBind',
|
||||
'fastKeys',
|
||||
'ownLast',
|
||||
'nonEnumArgs',
|
||||
'nonEnumShadows',
|
||||
'spliceObjects',
|
||||
'unindexedChars',
|
||||
'nodeClass'
|
||||
];
|
||||
|
||||
_.each(props, function(prop) {
|
||||
if (_.has(_.support, prop)) {
|
||||
equal(typeof _.support[prop], 'boolean');
|
||||
} else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.template');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user