diff --git a/test.it/test.it.min.js b/test.it/test.it.min.js index 9d99542..55a6603 100644 --- a/test.it/test.it.min.js +++ b/test.it/test.it.min.js @@ -1 +1 @@ -(function(e){"use strict";function t(e){this.print=e.print;this.group=e.group;this.test=e.test;this.error=e.error}function n(){function n(n){e=new t(n)}function s(){this.type="group";this.name=undefined;this.status=undefined;this.comment=undefined;this.error=undefined;this.time=0;this.result={pass:0,fail:0,error:0,total:0};this.stack=[]}function l(){this.type="test";this.status=undefined;this.comment=undefined;this.description=undefined;this.error=undefined;this.argument=[]}function h(){return c}function p(e,t,n){var r=(new Date).getTime();var i;var u=false;for(var a in this.stack){if(this.stack[a].type!=="group")continue;if(this.stack[a].name===e){i=this.stack[a];u=true;break}}if(!u)i=new s;i.name=e;i.linkBack=this;var f;if(u)f=i.status;i.status="pass";var l=c;c=i;try{t()}catch(h){i.status="error";i.error=o(h)}c=l;i.time+=(new Date).getTime()-r;if(!u&&!n)this.stack.push(i);O(i);return i}function d(e){var t=this.stack;for(var n in t){if(t[n].type!=="group")continue;if(t[n].name===e){return t[n]}}throw new ReferenceError("there is no group with name: "+e)}function v(e,t){var n=this.link?this.link:c;var r;switch(arguments.length){case 0:throw new RangeError("test.group expect at least 1 argument");case 1:{r=d.call(n,e)}break;case 2:{r=p.call(n,e,t,this.excluded)}break;default:throw new RangeError("test.group expect no more than 2 arguments")}var i=u();return Object.create(this,{link:{value:r},trace:{value:i}})}function m(e,t){var n=new l;for(var r in t){n.argument.push(t[r])}switch(e){case"it":g(n);break;case"them":y(n);break;case"type":b(n);break;case"types":w(n);break;case"is":E(n);break;case"are":S(n);break}if(this.timestamp)n.time=(new Date).getTime()-this.timestamp;if(!this.excluded)c.stack.push(n);O(c);var i=u();return Object.create(this,{link:{value:n},trace:{value:i}})}function g(e){switch(e.argument.length){case 0:{e.status="error";e.error=o(new RangeError("at least one argument expected"))}break;case 1:{if(e.argument[0]){e.description="argument is true-like";e.status="pass"}else{e.description="argument is false-like";e.status="fail"}}break;case 2:{if(r(e.argument[0])!==r(e.argument[1])){e.description="argument hase different types";e.status="fail"}else if(f(e.argument[0],e.argument[1])){e.description="arguments are equal";e.status="pass"}else{e.description="argument are not equal";e.status="fail"}}break;default:{e.status="error";e.error=o(new RangeError("maximum of 2 arguments expected"))}}}function y(e){switch(e.argument.length){case 0:{e.status="error";e.error=o(new RangeError("at least one argument expected"))}break;case 1:{if(r(e.argument[0])!=="Array"){e.status="error";e.error=o(new TypeError("argument should be an array"))}else{for(var t in e.argument[0]){if(!e.argument[0][t]){e.status="fail";e.description="there are at least one false-like element"}}if(e.status!=="fail"){e.status="pass";e.description="arguments are true-like"}}}break;default:{e.status="error";e.error=o(new RangeError("maximum of 1 arguments expected"))}}}function b(e){if(e.argument.length!==2){e.status="error";e.error=o(new RangeError("expect two arguments"))}else if(r(e.argument[1])!=="String"){e.status="error";e.error=o(new TypeError("second argument should be a String"))}else if(!a(i,e.argument[1].toLowerCase())){e.status="error";e.error=o(new TypeError("second argument should be a standart type"))}else{e.description="type of argument is ";if(r(e.argument[0]).toLowerCase()!==e.argument[1].toLowerCase()){e.description+="not "+e.argument[1];e.status="fail"}else{e.description+=r(e.argument[0]);e.status="pass"}}}function w(e){if(e.argument.length==0){e.status="error";e.error=o(new RangeError("at least one argument expected"))}else if(e.argument.length>2){e.status="error";e.error=o(new RangeError("maximum of two arguments expected"))}else if(r(e.argument[0])!=="Array"){e.status="error";e.error=o(new TypeError("first argument should be an array"))}else{var t,n;if(r(e.argument[1])==="undefined"){t=r(e.argument[0][0]);n="same"}else if(r(e.argument[1])!=="String"){e.status="error";e.error=o(new TypeError("second argument should be a String"))}else if(!a(i,e.argument[1].toLowerCase())){e.status="error";e.error=o(new TypeError("second argument should be a standart type"))}else{t=e.argument[1];n="right"}if(e.status!=="error"){t=t.toLowerCase();for(var s in e.argument[0]){if(r(e.argument[0][s]).toLowerCase()!==t){e.status="fail";e.description="There are at least one element with different type"}}if(e.status!=="fail"){e.status="pass";e.description="arguments are "+n+" type"}}}}function E(e){if(e.argument.length!==2){e.status="error";e.error=o(new RangeError("expect two arguments"))}else if(r(e.argument[1])!=="Function"){e.status="error";e.error=o(new TypeError("second argument should be a constructor (function)"))}else{if(e.argument[1].name==""){e.description="argument has ";if(e.argument[0].constructor!==e.argument[1]){e.description+="wrong";e.status="fail"}else{e.description+="right";e.status="pass"}e.description+=" constructor"}else{e.description="argument is ";if(e.argument[0].constructor!==e.argument[1]){e.description+="not "+e.argument[1].name;e.status="fail"}else{e.description+=e.argument[1].name;e.status="pass"}}}}function S(e){if(e.argument.length==0){e.status="error";e.error=o(new RangeError("at least one argument expected"))}else if(e.argument.length>2){e.status="error";e.error=o(new RangeError("maximum of two arguments expected"))}else if(r(e.argument[0])!=="Array"){e.status="error";e.error=o(new TypeError("first argument should be an array"))}else{var t,n;if(r(e.argument[1])==="undefined"){t=e.argument[0][0].constructor;n="same"}else if(r(e.argument[1])!=="Function"){e.status="error";e.error=o(new TypeError("second argument should be a constructor (function)"))}else{t=e.argument[1];n="right"}if(e.status!=="error"){for(var i in e.argument[0]){if(e.argument[0][i].constructor!==t){e.status="fail";var s=1+parseInt(i);e.description="There are at least one ("+s+") element with different constructor"}}if(e.status!=="fail"){e.status="pass";if(typeof e.argument[1]!=="undefined"){e.description="arguments "+(e.argument[1].name!=="undefined")?"are "+e.argument[1].name:"has same constructor"}else{e.description="arguments has same constructor"}}}}}function x(){return Object.create(this,{timestamp:{value:(new Date).getTime()}})}function T(e){if(!this.link)throw new ReferenceError("comment can only be used in testit chain");this.link.comment=e;return this}function N(e,t,n){if(!this.link)throw new ReferenceError("callback can only be used in testit chain");if(this.link.status==="pass"&&r(e)==="Function")try{e()}catch(i){throw i}if(this.link.status==="fail"&&r(t)==="Function")try{t()}catch(i){throw i}if(this.link.status==="error"&&r(n)==="Function")try{n()}catch(i){throw i}return this}function C(e){if(!this.link)throw new ReferenceError("addTrace can only be used in testit chain");if(this.trace){var t=this.trace;if(r(e)==="Number")t=t.split("\n").slice(0,e+1).join("\n");this.link.trace=t}return this}function k(){if(this.link){return this.link.status=="pass"?true:false}else{return c.status=="pass"?true:false}return undefined}function L(){if(this.link){if(this.link.type!=="test")return TypeError("groups don't return arguments");switch(this.link.argument.length){case 0:return undefined;case 1:return this.link.argument[0];default:return this.link.argument}}return undefined}function A(n){var r=this.link?this.link:c;if(n)(new t(n)).print(r);else if(e)e.print(r);else return false;return true}function O(e){e.result={pass:0,fail:0,error:0,total:0};for(var t in e.stack){e.result.total++;switch(e.stack[t].status){case"pass":{e.result.pass++}break;case"fail":{e.result.fail++}break;case"error":{e.result.error++}break}}if(e.result.error||e.error){e.status="error"}else if(e.result.fail){e.status="fail"}else{e.status="pass"}if(e.root){e.time=(new Date).getTime()-e.timestamp}if(e.linkBack){O(e.linkBack)}}var e;this.printer=function(t){if(t)n(t);return e};var c=new s;c.root=true;c.name="root";c.timestamp=(new Date).getTime();this.getRoot=this.r=h;this.root=c;this.group=v;this.it=function(){return m.call(this,"it",arguments)};this.them=function(){return m.call(this,"them",arguments)};this.is=function(){return m.call(this,"is",arguments)};this.are=function(){return m.call(this,"are",arguments)};this.type=function(){return m.call(this,"type",arguments)};this.types=function(){return m.call(this,"types",arguments)};this.addTime=x;this.time=Object.create(this,{timestamp:{value:(new Date).getTime()}});this.exclude=this.x=Object.create(this,{excluded:{value:true}});this.comment=T;this.callback=N;this.addTrace=C;this.result=k;this.arguments=L;this.print=A;this.done=A;this.typeof=r;this.trace=u;return this}function r(e){var t;try{switch(e.constructor){case Array:t="Array";break;case Boolean:t="Boolean";break;case Date:t="Date";break;case Error:t="Error";break;case EvalError:t="EvalError";break;case Function:t="Function";break;case Number:{t=isNaN(e)?"NaN":"Number"}break;case Object:t="Object";break;case RangeError:t="RangeError";break;case ReferenceError:t="ReferenceError";break;case RegExp:t="RegExp";break;case String:t="String";break;case SyntaxError:t="SyntaxError";break;case TypeError:t="TypeError";break;case URIError:t="URIError";break;case Window:t="Window";break;case HTMLDocument:t="HTML";break;case NodeList:t="NodeList";break;default:{if(typeof e==="object"&&e.toString().indexOf("HTML")!==-1){t="HTML"}else{t=undefined}}}}catch(n){t=e===null?"null":typeof e}return t}function s(e,t){if(e===undefined)return t;if(t===undefined)return e;if(e==="error"||t==="error")return"error";if(e==="fail"||t==="fail")return"fail";return"pass"}function o(e){var t={error:e,type:r(e),message:e.message};if(u(e))t.stack=u(e);return t}function u(e){if(!e)e=new Error;if(!e.stack)return;var t="";e.stack.split(/[\n]/).forEach(function(n,i){var s=true;if(n==="")s=false;if(n.indexOf(r(e))!==-1)s=false;if(n.indexOf("test.it.js")!==-1||n.indexOf("test.it.min.js")!==-1)s=false;if(n.indexOf("getTrace")!==-1)s=false;if(s){t+=t?"\n":"";t+=n.replace(/((\s+at\s+)|(^@))/,"")}});return t}function a(e,t){for(var n in e)if(e[n]===t)return true;return false}function f(){function n(r,i){var s;if(isNaN(r)&&isNaN(i)&&typeof r==="number"&&typeof i==="number"){return true}if(r===i){return true}if(typeof r==="function"&&typeof i==="function"||r instanceof Date&&i instanceof Date||r instanceof RegExp&&i instanceof RegExp||r instanceof String&&i instanceof String||r instanceof Number&&i instanceof Number){return r.toString()===i.toString()}if((window||false)&&(window.jQuery||false)&&r instanceof jQuery&&i instanceof jQuery){return r.is(i)}if(!(r instanceof Object&&i instanceof Object)){return false}if(r.isPrototypeOf(i)||i.isPrototypeOf(r)){return false}if(r.constructor!==i.constructor){return false}if(r.prototype!==i.prototype){return false}if(e.indexOf(r)>-1||t.indexOf(i)>-1){return false}for(s in i){if(i.hasOwnProperty(s)!==r.hasOwnProperty(s)){return false}else if(typeof i[s]!==typeof r[s]){return false}}for(s in r){if(i.hasOwnProperty(s)!==r.hasOwnProperty(s)){return false}else if(typeof i[s]!==typeof r[s]){return false}switch(typeof r[s]){case"object":case"function":e.push(r);t.push(i);if(!n(r[s],i[s])){return false}e.pop();t.pop();break;default:if(r[s]!==i[s]){return false}break}}return true}var e,t;if(arguments.length<1){return true}for(var r=1,i=arguments.length;r2)e.status="error",e.error=a(new RangeError("maximum of two arguments expected"));else if("Array"!==n(e.argument[0]))e.status="error",e.error=a(new TypeError("first argument should be an array"));else{var r,t;if("undefined"===n(e.argument[1])?(r=n(e.argument[0][0]),t="same"):"String"!==n(e.argument[1])?(e.status="error",e.error=a(new TypeError("second argument should be a String"))):i(u,e.argument[1].toLowerCase())?(r=e.argument[1],t="right"):(e.status="error",e.error=a(new TypeError("second argument should be a standart type"))),"error"!==e.status){r=r.toLowerCase();for(var s in e.argument[0])n(e.argument[0][s]).toLowerCase()!==r&&(e.status="fail",e.description="There are at least one element with different type");"fail"!==e.status&&(e.status="pass",e.description="arguments are "+t+" type")}}}function y(e){2!==e.argument.length?(e.status="error",e.error=a(new RangeError("expect two arguments"))):"Function"!==n(e.argument[1])?(e.status="error",e.error=a(new TypeError("second argument should be a constructor (function)"))):""==e.argument[1].name?(e.description="argument has ",e.argument[0].constructor!==e.argument[1]?(e.description+="wrong",e.status="fail"):(e.description+="right",e.status="pass"),e.description+=" constructor"):(e.description="argument is ",e.argument[0].constructor!==e.argument[1]?(e.description+="not "+e.argument[1].name,e.status="fail"):(e.description+=e.argument[1].name,e.status="pass"))}function b(e){if(0==e.argument.length)e.status="error",e.error=a(new RangeError("at least one argument expected"));else if(e.argument.length>2)e.status="error",e.error=a(new RangeError("maximum of two arguments expected"));else if("Array"!==n(e.argument[0]))e.status="error",e.error=a(new TypeError("first argument should be an array"));else{var r,t;if("undefined"===n(e.argument[1])?(r=e.argument[0][0].constructor,t="same"):"Function"!==n(e.argument[1])?(e.status="error",e.error=a(new TypeError("second argument should be a constructor (function)"))):(r=e.argument[1],t="right"),"error"!==e.status){for(var s in e.argument[0])if(e.argument[0][s].constructor!==r){e.status="fail";var i=1+parseInt(s);e.description="There are at least one ("+i+") element with different constructor"}"fail"!==e.status&&(e.status="pass","undefined"!=typeof e.argument[1]?e.description="are "+e.argument[1].name:e.description="arguments has same constructor")}}}function v(){return Object.create(this,{timestamp:{value:(new Date).getTime()}})}function E(e){if(!this.link)throw new ReferenceError("comment can only be used in testit chain");return this.link.comment=e,this}function x(e,r,t){if(!this.link)throw new ReferenceError("callback can only be used in testit chain");if("pass"===this.link.status&&"Function"===n(e))try{e()}catch(a){throw a}if("fail"===this.link.status&&"Function"===n(r))try{r()}catch(a){throw a}if("error"===this.link.status&&"Function"===n(t))try{t()}catch(a){throw a}return this}function T(e){if(!this.link)throw new ReferenceError("addTrace can only be used in testit chain");if(this.trace){var r=this.trace;"Number"===n(e)&&(r=r.split("\n").slice(0,e+1).join("\n")),this.link.trace=r}return this}function R(){return this.link?"pass"==this.link.status?!0:!1:"pass"==D.status?!0:!1}function O(){if(this.link){if("test"!==this.link.type)return TypeError("groups don't return arguments");switch(this.link.argument.length){case 0:return void 0;case 1:return this.link.argument[0];default:return this.link.argument}}return void 0}function j(e){var t=this.link?this.link:D;if(e)new r(e).print(t);else{if(!S)return!1;S.print(t)}return!0}function N(e){e.result={pass:0,fail:0,error:0,total:0};for(var r in e.stack)switch(e.result.total++,e.stack[r].status){case"pass":e.result.pass++;break;case"fail":e.result.fail++;break;case"error":e.result.error++}e.result.error||e.error?e.status="error":e.result.fail?e.status="fail":e.status="pass",e.root&&(e.time=(new Date).getTime()-e.timestamp),e.linkBack&&N(e.linkBack)}var S;this.printer=function(r){return r&&e(r),S};var D=new t;return D.root=!0,D.name="root",D.timestamp=(new Date).getTime(),this.getRoot=this.r=f,this.root=D,this.group=h,this.it=function(){return l.call(this,"it",arguments)},this.them=function(){return l.call(this,"them",arguments)},this.is=function(){return l.call(this,"is",arguments)},this.are=function(){return l.call(this,"are",arguments)},this.type=function(){return l.call(this,"type",arguments)},this.types=function(){return l.call(this,"types",arguments)},this.addTime=v,this.time=Object.create(this,{timestamp:{value:(new Date).getTime()}}),this.exclude=this.x=Object.create(this,{excluded:{value:!0}}),this.comment=E,this.callback=x,this.addTrace=T,this.result=R,this.arguments=O,this.print=j,this.done=j,this["typeof"]=n,this.trace=s,this}function n(e){var r;try{switch(e.constructor){case Array:r="Array";break;case Boolean:r="Boolean";break;case Date:r="Date";break;case Error:r="Error";break;case EvalError:r="EvalError";break;case Function:r="Function";break;case Number:r=isNaN(e)?"NaN":"Number";break;case Object:r="Object";break;case RangeError:r="RangeError";break;case ReferenceError:r="ReferenceError";break;case RegExp:r="RegExp";break;case String:r="String";break;case SyntaxError:r="SyntaxError";break;case TypeError:r="TypeError";break;case URIError:r="URIError";break;case Window:r="Window";break;case HTMLDocument:r="HTML";break;case NodeList:r="NodeList";break;default:r="object"==typeof e&&-1!==e.toString().indexOf("HTML")?"HTML":void 0}}catch(t){r=null===e?"null":typeof e}return r}function a(e){var r={error:e,type:n(e),message:e.message};return s(e)&&(r.stack=s(e)),r}function s(e){if(e||(e=new Error),e.stack){var r="";return e.stack.split(/[\n]/).forEach(function(t,a){var s=!0;""===t&&(s=!1),-1!==t.indexOf(n(e))&&(s=!1),(-1!==t.indexOf("test.it.js")||-1!==t.indexOf("test.it.min.js"))&&(s=!1),-1!==t.indexOf("getTrace")&&(s=!1),s&&(r+=r?"\n":"",r+=t.replace(/((\s+at\s+)|(^@))/,""))}),r}}function i(e,r){for(var t in e)if(e[t]===r)return!0;return!1}function o(){function e(n,a){var s;if(isNaN(n)&&isNaN(a)&&"number"==typeof n&&"number"==typeof a)return!0;if(n===a)return!0;if("function"==typeof n&&"function"==typeof a||n instanceof Date&&a instanceof Date||n instanceof RegExp&&a instanceof RegExp||n instanceof String&&a instanceof String||n instanceof Number&&a instanceof Number)return n.toString()===a.toString();if("undefined"!=typeof window&&window.jQuery&&n instanceof jQuery&&a instanceof jQuery)return n.is(a);if(!(n instanceof Object&&a instanceof Object))return!1;if(n.isPrototypeOf(a)||a.isPrototypeOf(n))return!1;if(n.constructor!==a.constructor)return!1;if(n.prototype!==a.prototype)return!1;if(r.indexOf(n)>-1||t.indexOf(a)>-1)return!1;for(s in a){if(a.hasOwnProperty(s)!==n.hasOwnProperty(s))return!1;if(typeof a[s]!=typeof n[s])return!1}for(s in n){if(a.hasOwnProperty(s)!==n.hasOwnProperty(s))return!1;if(typeof a[s]!=typeof n[s])return!1;switch(typeof n[s]){case"object":case"function":if(r.push(n),t.push(a),!e(n[s],a[s]))return!1;r.pop(),t.pop();break;default:if(n[s]!==a[s])return!1}}return!0}var r,t;if(arguments.length<1)return!0;for(var n=1,a=arguments.length;a>n;n++)if(r=[],t=[],!e(arguments[0],arguments[n]))return!1;return!0}var u=["array","boolean","date","error","evalerror","function","html","nan","nodelist","null","number","object","rangeerror","referenceerror","regexp","string","syntaxerror","typeerror","urierror","window"];"undefined"!=typeof module&&module.exports?module.exports=new t:e.test=new t}(this); \ No newline at end of file