/** * QUnit v1.11.0 - A JavaScript Unit Testing Framework * * http://qunitjs.com * * Copyright 2012 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license */ /** * 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(e){p(this,e),this.assertions=[],this.testNumber=++t.count}function n(){x.autorun=!0,x.currentModule&&y("moduleDone",q,{name:x.currentModule,failed:x.moduleStats.bad,passed:x.moduleStats.all-x.moduleStats.bad,total:x.moduleStats.all});var t,n,r=v("qunit-banner"),s=v("qunit-tests"),o=+new M-x.started,i=x.stats.all-x.stats.bad,a=["Tests completed in ",o," milliseconds.
","",i," assertions of ",x.stats.all," passed, ",x.stats.bad," failed."].join("");if(r&&(r.className=x.stats.bad?"qunit-fail":"qunit-pass"),s&&(v("qunit-testresult").innerHTML=a),x.altertitle&&"undefined"!=typeof document&&document.title&&(document.title=[x.stats.bad?"✖":"✔",document.title.replace(/^[\u2714\u2716] /i,"")].join(" ")),x.reorder&&L.sessionStorage&&0===x.stats.bad)for(t=0;t&]/g,function(e){switch(e){case"'":return"'";case'"':return""";case"<":return"<";case">":return">";case"&":return"&"}})):""}function a(e,t){x.queue.push(e),x.autorun&&!x.blocking&&u(t)}function u(t){function r(){u(t)}var s=(new M).getTime();for(x.depth=x.depth?x.depth+1:1;x.queue.length&&!x.blocking;){if(!(!L.setTimeout||x.updateRate<=0||(new M).getTime()-s0&&q.pushFailure("Introduced global variable(s): "+e.join(", ")),t=d(n,x.pollution),t.length>0&&q.pushFailure("Deleted global variable(s): "+t.join(", "))}function d(e,t){var n,r,s=e.slice();for(n=0;n-1}function g(e,t){h(e,t)||(e.className+=(e.className?" ":"")+t)}function b(t,n){for(var r=" "+t.className+" ";r.indexOf(" "+n+" ")>-1;)r=r.replace(" "+n+" "," ");t.className=e.jQuery?jQuery.trim(r):r.trim?r.trim():r}function v(e){return!("undefined"==typeof document||!document||!document.getElementById)&&document.getElementById(e)}function w(e){return function(t){x[e].push(t)}}function y(e,t,n){var r,s;if(q.hasOwnProperty(e))q[e].call(t,n);else for(s=x[e],r=0;rn;n++)if(t[n]===e)return n;return-1}var q,T,x,k,S=0,N=(o(0)||"").replace(/(:\d+)+\)?/,"").replace(/.+\//,""),j=Object.prototype.toString,C=Object.prototype.hasOwnProperty,M=e.Date,L={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}}()},D=function(e){var t,n,r=e.toString();return"[object"===r.substring(0,7)?(t=e.name?e.name.toString():"Error",n=e.message?e.message.toString():"",t&&n?t+": "+n:t?t:n?n:"Error"):r},H=function(e){var t,n,r=q.is("array",e)?[]:{};for(t in e)C.call(e,t)&&(n=e[t],r[t]=n===Object(n)?H(n):n);return r};t.count=0,t.prototype={init:function(){var e,t,n,r=v("qunit-tests");r&&(t=document.createElement("strong"),t.innerHTML=this.nameHtml,e=document.createElement("a"),e.innerHTML="Rerun",e.href=q.url({testNumber:this.testNumber}),n=document.createElement("li"),n.appendChild(t),n.appendChild(e),n.className="running",n.id=this.id="qunit-test-output"+S++,r.appendChild(n))},setup:function(){if(this.module!==x.previousModule?(x.previousModule&&y("moduleDone",q,{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},y("moduleStart",q,{name:this.module})):x.autorun&&y("moduleStart",q,{name:this.module}),x.current=this,this.testEnvironment=p({setup:function(){},teardown:function(){}},this.moduleTestEnvironment),this.started=+new M,y("testStart",q,{name:this.testName,module:this.module}),q.current_testEnvironment=this.testEnvironment,x.pollution||l(),x.notrycatch)return this.testEnvironment.setup.call(this.testEnvironment),void 0;try{this.testEnvironment.setup.call(this.testEnvironment)}catch(e){q.pushFailure("Setup failed on "+this.testName+": "+(e.message||e),s(e,1))}},run:function(){x.current=this;var e=v("qunit-testresult");if(e&&(e.innerHTML="Running:
"+this.nameHtml),this.async&&q.stop(),this.callbackStarted=+new M,x.notrycatch)return this.callback.call(this.testEnvironment,q.assert),this.callbackRuntime=+new M-this.callbackStarted,void 0;try{this.callback.call(this.testEnvironment,q.assert),this.callbackRuntime=+new M-this.callbackStarted}catch(t){this.callbackRuntime=+new M-this.callbackStarted,q.pushFailure("Died on test #"+(this.assertions.length+1)+" "+this.stack+": "+(t.message||t),s(t,0)),l(),x.blocking&&q.start()}},teardown:function(){if(x.current=this,x.notrycatch)return"undefined"==typeof this.callbackRuntime&&(this.callbackRuntime=+new M-this.callbackStarted),this.testEnvironment.teardown.call(this.testEnvironment),void 0;try{this.testEnvironment.teardown.call(this.testEnvironment)}catch(e){q.pushFailure("Teardown failed on "+this.testName+": "+(e.message||e),s(e,1))}c()},finish:function(){x.current=this,x.requireExpects&&null===this.expected?q.pushFailure("Expected number of assertions to be defined, but expect() was not called.",this.stack):null!==this.expected&&this.expected!==this.assertions.length?q.pushFailure("Expected "+this.expected+" assertions, but "+this.assertions.length+" were run",this.stack):null!==this.expected||this.assertions.length||q.pushFailure("Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.",this.stack);var t,n,r,s,o,i,a,u=this,l=0,c=0,d=v("qunit-tests");if(this.runtime=+new M-this.started,x.stats.all+=this.assertions.length,x.moduleStats.all+=this.assertions.length,d){for(a=document.createElement("ol"),a.className="qunit-assert-list",t=0;t("+c+", "+l+", "+this.assertions.length+")",f(s,"click",function(){var e=s.parentNode.lastChild,t=h(e,"qunit-collapsed");(t?b:g)(e,"qunit-collapsed")}),f(s,"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=q.url({testNumber:u.testNumber}))}),o=document.createElement("span"),o.className="runtime",o.innerHTML=this.runtime+" ms",i=v(this.id),i.className=c?"fail":"pass",i.removeChild(i.firstChild),r=i.firstChild,i.appendChild(s),i.appendChild(r),i.appendChild(o),i.appendChild(a)}else for(t=0;t";2===arguments.length&&(s=n,n=null),x.currentModule&&(l=""+i(x.currentModule)+": "+l),u=new t({nameHtml:l,testName:e,expected:n,async:a,callback:s,module:x.currentModule,moduleTestEnvironment:x.currentModuleTestEnvironment,stack:o(2)}),r(u)&&u.queue()},expect:function(e){return 1!==arguments.length?x.current.expected:(x.current.expected=e,void 0)},start:function(t){return void 0===x.semaphore?(q.begin(function(){setTimeout(function(){q.start(t)})}),void 0):(x.semaphore-=t||1,x.semaphore>0?void 0:x.semaphore<0?(x.semaphore=0,q.pushFailure("Called start() while already started (QUnit.config.semaphore was 0 already)",null,o(2)),void 0):(L.setTimeout?e.setTimeout(function(){x.semaphore>0||(x.timeout&&clearTimeout(x.timeout),x.blocking=!1,u(!0))},13):(x.blocking=!1,u(!0)),void 0))},stop:function(t){x.semaphore+=t||1,x.blocking=!0,x.testTimeout&&L.setTimeout&&(clearTimeout(x.timeout),x.timeout=e.setTimeout(function(){q.ok(!1,"Test timed out"),x.semaphore=1,q.start()},x.testTimeout))}},T={ok:function(e,t){if(!x.current)throw new Error("ok() assertion outside test context, was "+o(2));e=!!e;var n,r={module:x.current.module,name:x.current.testName,result:e,message:t};t=i(t||(e?"okay":"failed")),t=""+t+"",e||(n=o(2),n&&(r.source=n,t+="
Source:
"+i(n)+"
")),y("log",q,r),x.current.assertions.push({result:e,message:t})},equal:function(e,t,n){q.push(t==e,e,t,n)},notEqual:function(e,t,n){q.push(t!=e,e,t,n)},propEqual:function(e,t,n){e=H(e),t=H(t),q.push(q.equiv(e,t),e,t,n)},notPropEqual:function(e,t,n){e=H(e),t=H(t),q.push(!q.equiv(e,t),e,t,n)},deepEqual:function(e,t,n){q.push(q.equiv(e,t),e,t,n)},notDeepEqual:function(e,t,n){q.push(!q.equiv(e,t),e,t,n)},strictEqual:function(e,t,n){q.push(t===e,e,t,n)},notStrictEqual:function(e,t,n){q.push(t!==e,e,t,n)},"throws":function(e,t,n){var r,s=t,o=!1;"string"==typeof t&&(n=t,t=null),x.current.ignoreGlobalErrors=!0;try{e.call(x.current.testEnvironment)}catch(i){r=i}x.current.ignoreGlobalErrors=!1,r?(t?"regexp"===q.objectType(t)?o=t.test(D(r)):r instanceof t?o=!0:t.call({},r)===!0&&(s=null,o=!0):(o=!0,s=null),q.push(o,r,s,n)):q.pushFailure(n,null,"No exception was thrown.")}},p(q,T),q.raises=T["throws"],q.equals=function(){q.push(!1,!1,!1,"QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead")},q.same=function(){q.push(!1,!1,!1,"QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead")},function(){function e(){}e.prototype=q,q=new e,q.constructor=e}(),x={queue:[],blocking:!0,hidepassed:!1,reorder:!0,altertitle:!0,requireExpects:!1,urlConfig:[{id:"noglobals",label:"Check for Globals",tooltip:"Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."},{id:"notrycatch",label:"No try-catch",tooltip:"Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."}],modules:{},begin:[],done:[],log:[],testStart:[],testDone:[],moduleStart:[],moduleDone:[]},"undefined"==typeof exports&&(p(e,q),e.QUnit=q),function(){var t,n,r=e.location||{search:"",protocol:"file:"},s=r.search.slice(1).split("&"),o=s.length,i={};if(s[0])for(t=0;o>t;t++)n=s[t].split("="),n[0]=decodeURIComponent(n[0]),n[1]=n[1]?decodeURIComponent(n[1]):!0,i[n[0]]=n[1];q.urlParams=i,x.filter=i.filter,x.module=i.module,x.testNumber=parseInt(i.testNumber,10)||null,q.isLocal="file:"===r.protocol}(),p(q,{assert:T,config:x,init:function(){p(x,{stats:{all:0,bad:0},moduleStats:{all:0,bad:0},started:+new M,updateRate:1e3,blocking:!1,autostart:!0,autorun:!1,filter:"",queue:[],semaphore:1});var e,t,n,r=v("qunit");r&&(r.innerHTML="

"+i(document.title)+"

"+"

"+"
"+"

"+"
    "),e=v("qunit-tests"),t=v("qunit-banner"),n=v("qunit-testresult"),e&&(e.innerHTML=""),t&&(t.className=""),n&&n.parentNode.removeChild(n),e&&(n=document.createElement("p"),n.id="qunit-testresult",n.className="result",e.parentNode.insertBefore(n,e),n.innerHTML="Running...
     ")},reset:function(){var e=v("qunit-fixture");e&&(e.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 q.objectType(t)===e},objectType:function(e){if("undefined"==typeof e)return"undefined";if(null===e)return"null";var t=j.call(e).match(/^\[object\s(.*)\]$/),n=t&&t[1]||"";switch(n){case"Number":return isNaN(e)?"nan":"number";case"String":case"Boolean":case"Array":case"Date":case"RegExp":case"Function":return n.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 "+o());var s,a,u={module:x.current.module,name:x.current.testName,result:e,message:r,actual:t,expected:n};r=i(r)||(e?"okay":"failed"),r=""+r+"",s=r,e||(n=i(q.jsDump.parse(n)),t=i(q.jsDump.parse(t)),s+="",t!==n&&(s+="",s+=""),a=o(),a&&(u.source=a,s+=""),s+="
    Expected:
    "+n+"
    Result:
    "+t+"
    Diff:
    "+q.diff(n,t)+"
    Source:
    "+i(a)+"
    "),y("log",q,u),x.current.assertions.push({result:!!e,message:s})},pushFailure:function(e,t,n){if(!x.current)throw new Error("pushFailure() assertion outside test context, was "+o(2));var r,s={module:x.current.module,name:x.current.testName,result:!1,message:e};e=i(e)||"error",e=""+e+"",r=e,r+="",n&&(r+=""),t&&(s.source=t,r+=""),r+="
    Result:
    "+i(n)+"
    Source:
    "+i(t)+"
    ",y("log",q,s),x.current.assertions.push({result:!1,message:r})},url:function(t){t=p(p({},q.urlParams),t);var n,r="?";for(n in t)C.call(t,n)&&(r+=encodeURIComponent(n)+"="+encodeURIComponent(t[n])+"&");return e.location.protocol+"//"+e.location.host+e.location.pathname+r.slice(0,-1)},extend:p,id:v,addEvent:f}),p(q.constructor.prototype,{begin:w("begin"),done:w("done"),log:w("log"),testStart:w("testStart"),testDone:w("testDone"),moduleStart:w("moduleStart"),moduleDone:w("moduleDone")}),("undefined"==typeof document||"complete"===document.readyState)&&(x.autorun=!0),q.load=function(){y("begin",q,{});var t,n,r,s,o,a,u,l,c,d,h,g,b,w=0,E="",T="",k=p({},x);for(q.init(),p(x,k),x.blocking=!1,o=x.urlConfig.length,r=0;o>r;r++)d=x.urlConfig[r],"string"==typeof d&&(d={id:d,label:d,tooltip:"[no tooltip available]"}),x[d.id]=q.urlParams[d.id],T+="";E+="",c=v("qunit-userAgent"),c&&(c.innerHTML=navigator.userAgent),t=v("qunit-header"),t&&(t.innerHTML=""+t.innerHTML+" "),l=v("qunit-testrunner-toolbar"),l&&(n=document.createElement("input"),n.type="checkbox",n.id="qunit-filter-pass",f(n,"click",function(){var e,t=document.getElementById("qunit-tests");n.checked?t.className=t.className+" hidepass":(e=" "+t.className.replace(/[\n\t\r]/g," ")+" ",t.className=e.replace(/ hidepass /," ")),L.sessionStorage&&(n.checked?sessionStorage.setItem("qunit-filter-passed-tests","true"):sessionStorage.removeItem("qunit-filter-passed-tests"))}),(x.hidepassed||L.sessionStorage&&sessionStorage.getItem("qunit-filter-passed-tests"))&&(n.checked=!0,u=document.getElementById("qunit-tests"),u.className=u.className+" hidepass"),l.appendChild(n),s=document.createElement("label"),s.setAttribute("for","qunit-filter-pass"),s.setAttribute("title","Only show tests and assertons that fail. Stored in sessionStorage."),s.innerHTML="Hide passed tests",l.appendChild(s),h=document.createElement("span"),h.innerHTML=T,g=h.getElementsByTagName("input"),m(g,"click",function(t){var n={},r=t.target||t.srcElement;n[r.name]=r.checked?!0:void 0,e.location=q.url(n)}),l.appendChild(h),w>1&&(b=document.createElement("span"),b.setAttribute("id","qunit-modulefilter-container"),b.innerHTML=E,f(b.lastChild,"change",function(){var t=b.getElementsByTagName("select")[0],n=decodeURIComponent(t.options[t.selectedIndex].value);e.location=q.url({module:""===n?void 0:n})}),l.appendChild(b))),a=v("qunit-fixture"),a&&(x.fixture=a.innerHTML),x.autostart&&q.start()},f(e,"load",q.load),k=e.onerror,e.onerror=function(e,t,n){var s=!1;if(k&&(s=k(e,t,n)),s!==!0){if(q.config.current){if(q.config.current.ignoreGlobalErrors)return!0;q.pushFailure(e,t+":"+n)}else q.test("global failure",p(function(){q.pushFailure(e,t+":"+n)},{validTest:r}));return!1}return s},q.equiv=function(){function e(e,t,n){var r=q.objectType(e);return r?"function"===q.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"===q.objectType(e)&&t.valueOf()===e.valueOf()},regexp:function(e,t){return"regexp"===q.objectType(e)&&t.source===e.source&&t.global===e.global&&t.ignoreCase===e.ignoreCase&&t.multiline===e.multiline&&t.sticky===e.sticky},"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"!==q.objectType(e))return!1;if(i=n.length,i!==e.length)return!1;for(r.push(n),s=0;i>s;s++){for(a=!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:function(e){return'Error("'+e.message+'")'},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,q.jsDump.parse(e,"functionArgs"),"){"].join(""),n(t,q.jsDump.parse(e,"functionCode"),"}")},array:r,nodelist:r,arguments:r,object:function(e,t){var r,s,o,i,a=[];q.jsDump.up(),r=[];for(s in e)r.push(s);for(r.sort(),i=0;i",i=e.nodeName.toLowerCase(),a=s+i,u=e.attributes;if(u)for(n=0,t=u.length;t>n;n++)r=u[n].nodeValue,r&&"inherit"!==r&&(a+=" "+u[n].nodeName+"="+q.jsDump.parse(r,"attribute"));return a+=o,(3===e.nodeType||4===e.nodeType)&&(a+=e.nodeValue),a+s+"/"+i+o},functionArgs:function(e){var t,n=e.length;if(!n)return"";for(t=new Array(n);n--;)t[n]=String.fromCharCode(97+n);return" "+t.join(", ")+" "},key:e,functionCode:"[code]",attribute:e,string:e,date:e,regexp:t,number:t,"boolean":t},HTML:!1,indentChar:" ",multiline:!0};return o}(),q.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,o="",i=e(""===t?[]:t.split(/\s+/),""===n?[]:n.split(/\s+/)),a=t.match(/\s+/g),u=n.match(/\s+/g);if(null==a?a=[" "]:a.push(" "),null==u?u=[" "]:u.push(" "),0===i.n.length)for(r=0;r"+i.o[r]+a[r]+"";else{if(null==i.n[0].text)for(n=0;n"+i.o[n]+a[n]+"";for(r=0;r"+i.n[r]+u[r]+"";else{for(s="",n=i.n[r].row+1;n"+i.o[n]+a[n]+"";o+=" "+i.n[r].text+u[r]+s}}return o}}(),"undefined"!=typeof exports&&p(exports,q)}(function(){return this}.call());