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