/** * QUnit v1.5.0 - A JavaScript Unit Testing Framework * * http://docs.jquery.com/QUnit * * Copyright (c) 2012 John Resig, Jörn Zaefferer * Dual licensed under the MIT (MIT-LICENSE.txt) * or GPL (GPL-LICENSE.txt) licenses. */ /** * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | * http://flesler.blogspot.com Licensed under BSD * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008 * * @projectDescription Advanced and extensible data dumping for Javascript. * @version 1.0.0 * @author Ariel Flesler * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} */ /* * Javascript Diff Algorithm * By John Resig (http://ejohn.org/) * Modified by Chu Alan "sprite" * * Released under the MIT license. * * More Info: * http://ejohn.org/projects/javascript-diff-algorithm/ * * Usage: QUnit.diff(expected, actual) * * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick brown fox jumped jumps over" */ !function(e){function t(){x.autorun=!0,x.currentModule&&m("moduleDone",T,{name:x.currentModule,failed:x.moduleStats.bad,passed:x.moduleStats.all-x.moduleStats.bad,total:x.moduleStats.all});var e=f("qunit-banner"),t=f("qunit-tests"),n=+new Date-x.started,r=x.stats.all-x.stats.bad,s=["Tests completed in ",n," milliseconds.
",'',r,' tests of ',x.stats.all,' passed, ',x.stats.bad," failed."].join("");if(e&&(e.className=x.stats.bad?"qunit-fail":"qunit-pass"),t&&(f("qunit-testresult").innerHTML=s),x.altertitle&&"undefined"!=typeof document&&document.title&&(document.title=[x.stats.bad?"✖":"✔",document.title.replace(/^[\u2714\u2716] /i,"")].join(" ")),x.reorder&&b.sessionStorage&&0===x.stats.bad)for(var o,i=0;i]/g,function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";default:return e}})):""}function i(e,t){x.queue.push(e),x.autorun&&!x.blocking&&a(t)}function a(n){function r(){a(n)}var s=(new Date).getTime();for(x.depth=x.depth?x.depth+1:1;x.queue.length&&!x.blocking;){if(!(!b.setTimeout||x.updateRate<=0||(new Date).getTime()-s0&&T.pushFailure("Introduced global variable(s): "+t.join(", "));var n=c(e,x.pollution);n.length>0&&T.pushFailure("Deleted global variable(s): "+n.join(", "))}function c(e,t){for(var n=e.slice(),r=0;rn;n++)if(t[n]===e)return n;return-1}var b={setTimeout:"undefined"!=typeof e.setTimeout,sessionStorage:function(){var e="qunit-test-string";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(t){return!1}}()},y=0,w=Object.prototype.toString,q=Object.prototype.hasOwnProperty,E=function(e,t,n,r,s){this.name=e,this.testName=t,this.expected=n,this.async=r,this.callback=s,this.assertions=[]};E.prototype={init:function(){var e=f("qunit-tests");if(e){var t=document.createElement("strong");t.innerHTML="Running "+this.name;var n=document.createElement("li");n.appendChild(t),n.className="running",n.id=this.id="test-output"+y++,e.appendChild(n)}},setup:function(){if(this.module!=x.previousModule?(x.previousModule&&m("moduleDone",T,{name:x.previousModule,failed:x.moduleStats.bad,passed:x.moduleStats.all-x.moduleStats.bad,total:x.moduleStats.all}),x.previousModule=this.module,x.moduleStats={all:0,bad:0},m("moduleStart",T,{name:this.module})):x.autorun&&m("moduleStart",T,{name:this.module}),x.current=this,this.testEnvironment=d({setup:function(){},teardown:function(){}},this.moduleTestEnvironment),m("testStart",T,{name:this.testName,module:this.module}),T.current_testEnvironment=this.testEnvironment,x.pollution||u(),x.notrycatch)return this.testEnvironment.setup.call(this.testEnvironment),void 0;try{this.testEnvironment.setup.call(this.testEnvironment)}catch(e){T.pushFailure("Setup failed on "+this.testName+": "+e.message,r(e,1))}},run:function(){x.current=this;var e=f("qunit-testresult");if(e&&(e.innerHTML="Running:
"+this.name),this.async&&T.stop(),x.notrycatch)return this.callback.call(this.testEnvironment),void 0;try{this.callback.call(this.testEnvironment)}catch(t){T.pushFailure("Died on test #"+(this.assertions.length+1)+": "+t.message,r(t,1)),u(),x.blocking&&T.start()}},teardown:function(){if(x.current=this,x.notrycatch)return this.testEnvironment.teardown.call(this.testEnvironment),void 0;try{this.testEnvironment.teardown.call(this.testEnvironment)}catch(e){T.pushFailure("Teardown failed on "+this.testName+": "+e.message,r(e,1))}l()},finish:function(){x.current=this,null!=this.expected&&this.expected!=this.assertions.length?T.pushFailure("Expected "+this.expected+" assertions, but "+this.assertions.length+" were run"):null!=this.expected||this.assertions.length||T.pushFailure("Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.");var t,n,r=0,s=0,o=f("qunit-tests");if(x.stats.all+=this.assertions.length,x.moduleStats.all+=this.assertions.length,o){var i=document.createElement("ol");for(n=0;n("+s+", "+r+", "+this.assertions.length+")";var l=document.createElement("a");l.innerHTML="Rerun",l.href=T.url({filter:g([u]).replace(/\([^)]+\)$/,"").replace(/(^\s*|\s*$)/g,"")}),p(u,"click",function(){var e=u.nextSibling.nextSibling,t=e.style.display;e.style.display="none"===t?"block":"none"}),p(u,"dblclick",function(t){var n=t&&t.target?t.target:e.event.srcElement;("span"==n.nodeName.toLowerCase()||"b"==n.nodeName.toLowerCase())&&(n=n.parentNode),e.location&&"strong"===n.nodeName.toLowerCase()&&(e.location=T.url({filter:g([n]).replace(/\([^)]+\)$/,"").replace(/(^\s*|\s*$)/g,"")}))}),t=f(this.id),t.className=s?"fail":"pass",t.removeChild(t.firstChild),t.appendChild(u),t.appendChild(l),t.appendChild(i)}else for(n=0;n";if(2===arguments.length&&(r=t,t=null),x.currentModule&&(i=''+x.currentModule+": "+i),n(x.currentModule+": "+e)){var a=new E(i,e,t,s,r);a.module=x.currentModule,a.moduleTestEnvironment=x.currentModuleTestEnviroment,a.queue()}},expect:function(e){x.current.expected=e},ok:function(e,t){if(!x.current)throw new Error("ok() assertion outside test context, was "+s(2));e=!!e;var n={result:e,message:t};if(t=o(t||(e?"okay":"failed")),!e){var r=s(2);r&&(n.source=r,t+='
Source:
'+o(r)+"
")}m("log",T,n),x.current.assertions.push({result:e,message:t})},equal:function(e,t,n){T.push(t==e,e,t,n)},notEqual:function(e,t,n){T.push(t!=e,e,t,n)},deepEqual:function(e,t,n){T.push(T.equiv(e,t),e,t,n)},notDeepEqual:function(e,t,n){T.push(!T.equiv(e,t),e,t,n)},strictEqual:function(e,t,n){T.push(t===e,e,t,n)},notStrictEqual:function(e,t,n){T.push(t!==e,e,t,n)},raises:function(e,t,n){var r,s=!1;"string"==typeof t&&(n=t,t=null);try{e.call(x.current.testEnvironment)}catch(o){r=o}r&&(t?"regexp"===T.objectType(t)?s=t.test(r):r instanceof t?s=!0:t.call({},r)===!0&&(s=!0):s=!0),T.ok(s,n)},start:function(t){x.semaphore-=t||1,x.semaphore>0||(x.semaphore<0&&(x.semaphore=0),b.setTimeout?e.setTimeout(function(){x.semaphore>0||(x.timeout&&clearTimeout(x.timeout),x.blocking=!1,a(!0))},13):(x.blocking=!1,a(!0)))},stop:function(t){x.semaphore+=t||1,x.blocking=!0,x.testTimeout&&b.setTimeout&&(clearTimeout(x.timeout),x.timeout=e.setTimeout(function(){T.ok(!1,"Test timed out"),x.semaphore=1,T.start()},x.testTimeout))}};!function(){function e(){}e.prototype=T,T=new e,T.constructor=e}(),T.equals=function(){T.push(!1,!1,!1,"QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead")},T.same=function(){T.push(!1,!1,!1,"QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead")};var x={queue:[],blocking:!0,hidepassed:!1,reorder:!0,altertitle:!0,urlConfig:["noglobals","notrycatch"],begin:[],done:[],log:[],testStart:[],testDone:[],moduleStart:[],moduleDone:[]};!function(){var t,n=e.location||{search:"",protocol:"file:"},r=n.search.slice(1).split("&"),s=r.length,o={};if(r[0])for(var i=0;s>i;i++)t=r[i].split("="),t[0]=decodeURIComponent(t[0]),t[1]=t[1]?decodeURIComponent(t[1]):!0,o[t[0]]=t[1];T.urlParams=o,x.filter=o.filter,T.isLocal="file:"===n.protocol}(),("undefined"==typeof exports||"undefined"==typeof require)&&(d(e,T),e.QUnit=T),d(T,{config:x,init:function(){d(x,{stats:{all:0,bad:0},moduleStats:{all:0,bad:0},started:+new Date,updateRate:1e3,blocking:!1,autostart:!0,autorun:!1,filter:"",queue:[],semaphore:0});var e=f("qunit");e&&(e.innerHTML='

'+o(document.title)+"

"+'

'+'
'+'

'+'
    ');var t=f("qunit-tests"),n=f("qunit-banner"),r=f("qunit-testresult");t&&(t.innerHTML=""),n&&(n.className=""),r&&r.parentNode.removeChild(r),t&&(r=document.createElement("p"),r.id="qunit-testresult",r.className="result",t.parentNode.insertBefore(r,t),r.innerHTML="Running...
     ")},reset:function(){if(e.jQuery)jQuery("#qunit-fixture").html(x.fixture);else{var t=f("qunit-fixture");t&&(t.innerHTML=x.fixture)}},triggerEvent:function(e,t,n){document.createEvent?(n=document.createEvent("MouseEvents"),n.initMouseEvent(t,!0,!0,e.ownerDocument.defaultView,0,0,0,0,0,!1,!1,!1,!1,0,null),e.dispatchEvent(n)):e.fireEvent&&e.fireEvent("on"+t)},is:function(e,t){return T.objectType(t)==e},objectType:function(e){if("undefined"==typeof e)return"undefined";if(null===e)return"null";var t=w.call(e).match(/^\[object\s(.*)\]$/)[1]||"";switch(t){case"Number":return isNaN(e)?"nan":"number";case"String":case"Boolean":case"Array":case"Date":case"RegExp":case"Function":return t.toLowerCase()}return"object"==typeof e?"object":void 0},push:function(e,t,n,r){if(!x.current)throw new Error("assertion outside test context, was "+s());var i={result:e,message:r,actual:t,expected:n};r=o(r)||(e?"okay":"failed"),r=''+r+"";var a=r;if(!e){n=o(T.jsDump.parse(n)),t=o(T.jsDump.parse(t)),a+='",t!=n&&(a+='",a+='");var u=s();u&&(i.source=u,a+='"),a+="
    Expected:
    '+n+"
    Result:
    '+t+"
    Diff:
    '+T.diff(n,t)+"
    Source:
    '+o(u)+"
    "}m("log",T,i),x.current.assertions.push({result:!!e,message:a})},pushFailure:function(e,t){var n={result:!1,message:e},r=o(e);t&&(n.source=t,r+='
    Source:
    '+o(t)+"
    "),m("log",T,n),x.current.assertions.push({result:!1,message:r})},url:function(t){t=d(d({},T.urlParams),t);var n,r="?";for(n in t)q.call(t,n)&&(r+=encodeURIComponent(n)+"="+encodeURIComponent(t[n])+"&");return e.location.pathname+r.slice(0,-1)},extend:d,id:f,addEvent:p}),d(T.constructor.prototype,{begin:h("begin"),done:h("done"),log:h("log"),testStart:h("testStart"),testDone:h("testDone"),moduleStart:h("moduleStart"),moduleDone:h("moduleDone")}),("undefined"==typeof document||"complete"===document.readyState)&&(x.autorun=!0),T.load=function(){m("begin",T,{});var t=d({},x);T.init(),d(x,t),x.blocking=!1;for(var n,r="",s=x.urlConfig.length,o=0;s>o;o++)n=x.urlConfig[o],x[n]=T.urlParams[n],r+='";var i=f("qunit-userAgent");i&&(i.innerHTML=navigator.userAgent);var a=f("qunit-header");a&&(a.innerHTML=' '+a.innerHTML+" "+r,p(a,"change",function(t){var n={};n[t.target.name]=t.target.checked?!0:void 0,e.location=T.url(n)}));var u=f("qunit-testrunner-toolbar");if(u){var l=document.createElement("input");if(l.type="checkbox",l.id="qunit-filter-pass",p(l,"click",function(){var e=document.getElementById("qunit-tests");if(l.checked)e.className=e.className+" hidepass";else{var t=" "+e.className.replace(/[\n\t\r]/g," ")+" ";e.className=t.replace(/ hidepass /," ")}b.sessionStorage&&(l.checked?sessionStorage.setItem("qunit-filter-passed-tests","true"):sessionStorage.removeItem("qunit-filter-passed-tests"))}),x.hidepassed||b.sessionStorage&&sessionStorage.getItem("qunit-filter-passed-tests")){l.checked=!0;var c=document.getElementById("qunit-tests");c.className=c.className+" hidepass"}u.appendChild(l);var h=document.createElement("label");h.setAttribute("for","qunit-filter-pass"),h.innerHTML="Hide passed tests",u.appendChild(h)}var g=f("qunit-fixture");g&&(x.fixture=g.innerHTML),x.autostart&&T.start()},p(e,"load",T.load),e.onerror=function(e,t,n){T.config.current?T.pushFailure(e,t+":"+n):T.test("global failure",function(){T.pushFailure(e,t+":"+n)})},T.equiv=function(){function e(e,t,n){var r=T.objectType(e);return r?"function"===T.objectType(t[r])?t[r].apply(t,n):t[r]:void 0}var t,n=[],r=[],s=Object.getPrototypeOf||function(e){return e.__proto__},o=function(){function e(e,t){return e instanceof t.constructor||t instanceof e.constructor?t==e:t===e}return{string:e,"boolean":e,number:e,"null":e,undefined:e,nan:function(e){return isNaN(e)},date:function(e,t){return"date"===T.objectType(e)&&t.valueOf()===e.valueOf()},regexp:function(e,t){return"regexp"===T.objectType(e)&&t.source===e.source&&t.global===e.global&&t.ignoreCase===e.ignoreCase&&t.multiline===e.multiline},"function":function(){var e=n[n.length-1];return e!==Object&&"undefined"!=typeof e},array:function(e,n){var s,o,i,a;if("array"!==T.objectType(e))return!1;if(a=n.length,a!==e.length)return!1;for(r.push(n),s=0;a>s;s++){for(i=!1,o=0;o":"\n":this.HTML?" ":" "},indent:function(e){if(!this.multiline)return"";var t=this.indentChar;return this.HTML&&(t=t.replace(/\t/g," ").replace(/ /g," ")),new Array(this._depth_+(e||0)).join(t)},up:function(e){this._depth_+=e||1},down:function(e){this._depth_-=e||1},setParser:function(e,t){this.parsers[e]=t},quote:e,literal:t,join:n,_depth_:1,parsers:{window:"[Window]",document:"[Document]",error:"[ERROR]",unknown:"[Unknown]","null":"null",undefined:"undefined","function":function(e){var t="function",r="name"in e?e.name:(s.exec(e)||[])[1];return r&&(t+=" "+r),t+="(",t=[t,T.jsDump.parse(e,"functionArgs"),"){"].join(""),n(t,T.jsDump.parse(e,"functionCode"),"}")},array:r,nodelist:r,arguments:r,object:function(e,t){var r,s,o,i,a=[];if(T.jsDump.up(),Object.keys)r=Object.keys(e);else{r=[];for(s in e)r.push(s)}for(r.sort(),i=0;i",r=e.nodeName.toLowerCase(),s=t+r;for(var o in T.jsDump.DOMAttrs){var i=e[T.jsDump.DOMAttrs[o]];i&&(s+=" "+o+"="+T.jsDump.parse(i,"attribute"))}return s+n+t+"/"+r+n},functionArgs:function(e){var t=e.length;if(!t)return"";for(var n=new Array(t);t--;)n[t]=String.fromCharCode(97+t);return" "+n.join(", ")+" "},key:e,functionCode:"[code]",attribute:e,string:e,date:e,regexp:t,number:t,"boolean":t},DOMAttrs:{id:"id",name:"name","class":"className"},HTML:!1,indentChar:" ",multiline:!0};return o}(),T.diff=function(){function e(e,t){var n,r={},s={};for(n=0;n0;n--)null!=t[n].text&&null==t[n-1].text&&t[n].row>0&&null==e[t[n].row-1].text&&t[n-1]==e[t[n].row-1]&&(t[n-1]={text:t[n-1],row:t[n].row-1},e[t[n].row-1]={text:e[t[n].row-1],row:n-1});return{o:e,n:t}}return function(t,n){t=t.replace(/\s+$/,""),n=n.replace(/\s+$/,"");var r,s=e(""===t?[]:t.split(/\s+/),""===n?[]:n.split(/\s+/)),o="",i=t.match(/\s+/g);null==i?i=[" "]:i.push(" ");var a=n.match(/\s+/g);if(null==a?a=[" "]:a.push(" "),0===s.n.length)for(r=0;r"+s.o[r]+i[r]+"";else{if(null==s.n[0].text)for(n=0;n"+s.o[n]+i[n]+"";for(r=0;r"+s.n[r]+a[r]+"";else{var u="";for(n=s.n[r].row+1;n"+s.o[n]+i[n]+"";o+=" "+s.n[r].text+a[r]+u}}return o}}(),("undefined"!=typeof exports||"undefined"!=typeof require)&&d(exports,T)}(function(){return this}.call());