mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
2 lines
34 KiB
JavaScript
2 lines
34 KiB
JavaScript
!function(a){function b(){y.autorun=!0,y.previousModule&&t("moduleDone",w,{name:y.previousModule,failed:y.moduleStats.bad,passed:y.moduleStats.all-y.moduleStats.bad,total:y.moduleStats.all}),delete y.previousModule;var b,c,d=r("qunit-banner"),e=r("qunit-tests"),f=+new E-y.started,g=y.stats.all-y.stats.bad,h=["Tests completed in ",f," milliseconds.<br/>","<span class='passed'>",g,"</span> assertions of <span class='total'>",y.stats.all,"</span> passed, <span class='failed'>",y.stats.bad,"</span> failed."].join("");if(d&&(d.className=y.stats.bad?"qunit-fail":"qunit-pass"),e&&(r("qunit-testresult").innerHTML=h),y.altertitle&&G.document&&document.title&&(document.title=[y.stats.bad?"✖":"✔",document.title.replace(/^[\u2714\u2716] /i,"")].join(" ")),y.reorder&&G.sessionStorage&&0===y.stats.bad)for(b=0;b<sessionStorage.length;b++)c=sessionStorage.key(b++),0===c.indexOf("qunit-test-")&&sessionStorage.removeItem(c);a.scrollTo&&a.scrollTo(0,0),t("done",w,{failed:y.stats.bad,passed:g,total:y.stats.all,runtime:f})}function c(a){var b,d=y.filter&&y.filter.toLowerCase(),e=y.module&&y.module.toLowerCase(),f=(a.module+": "+a.testName).toLowerCase();return a.callback&&a.callback.validTest===c?(delete a.callback.validTest,!0):y.testNumber?a.testNumber===y.testNumber:!(e&&(!a.module||a.module.toLowerCase()!==e))&&(!d||(b="!"!==d.charAt(0),b||(d=d.slice(1)),-1!==f.indexOf(d)?b:!b))}function d(a,b){b=void 0===b?3:b;var c,d,e;if(a.stacktrace)return a.stacktrace.split("\n")[b+3];if(a.stack){if(c=a.stack.split("\n"),/^error$/i.test(c[0])&&c.shift(),B){for(d=[],e=b;e<c.length&&-1===c[e].indexOf(B);e++)d.push(c[e]);if(d.length)return d.join("\n")}return c[b]}if(a.sourceURL){if(/qunit.js$/.test(a.sourceURL))return;return a.sourceURL+":"+a.line}}function e(a){try{throw new Error}catch(b){return d(b,a)}}function f(a){return a?(a+="",a.replace(/['"<>&]/g,function(a){switch(a){case"'":return"'";case'"':return""";case"<":return"<";case">":return">";case"&":return"&"}})):""}function g(a,b){y.queue.push(a),y.autorun&&!y.blocking&&h(b)}function h(a){function c(){h(a)}var d=(new E).getTime();for(y.depth=y.depth?y.depth+1:1;y.queue.length&&!y.blocking;){if(!(!G.setTimeout||y.updateRate<=0||(new E).getTime()-d<y.updateRate)){F(c,13);break}y.queue.shift()()}y.depth--,!a||y.blocking||y.queue.length||0!==y.depth||b()}function i(){if(y.pollution=[],y.noglobals)for(var b in a)if(D.call(a,b)){if(/^qunit-test-output/.test(b))continue;y.pollution.push(b)}}function j(){var a,b,c=y.pollution;i(),a=k(y.pollution,c),a.length>0&&w.pushFailure("Introduced global variable(s): "+a.join(", ")),b=k(c,y.pollution),b.length>0&&w.pushFailure("Deleted global variable(s): "+b.join(", "))}function k(a,b){var c,d,e=a.slice();for(c=0;c<e.length;c++)for(d=0;d<b.length;d++)if(e[c]===b[d]){e.splice(c,1),c--;break}return e}function l(b,c){for(var d in c)D.call(c,d)&&("constructor"===d&&b===a||(void 0===c[d]?delete b[d]:b[d]=c[d]));return b}function m(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else{if(!a.attachEvent)throw new Error("addEvent() was called in a context without event listener support");a.attachEvent("on"+b,c)}}function n(a,b,c){for(var d=a.length;d--;)m(a[d],b,c)}function o(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")>-1}function p(a,b){o(a,b)||(a.className+=(a.className?" ":"")+b)}function q(a,b){for(var c=" "+a.className+" ";c.indexOf(" "+b+" ")>-1;)c=c.replace(" "+b+" "," ");a.className="function"==typeof c.trim?c.trim():c.replace(/^\s+|\s+$/g,"")}function r(a){return G.document&&document.getElementById&&document.getElementById(a)}function s(a){return function(b){y[a].push(b)}}function t(a,b,c){var d,e;if(w.hasOwnProperty(a))w[a].call(b,c);else for(e=y[a],d=0;d<e.length;d++)e[d].call(b,c)}function u(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1}function v(a){l(this,a),this.assertions=[],this.testNumber=++v.count}var w,x,y,z,A=0,B=(e(0)||"").replace(/(:\d+)+\)?/,"").replace(/.+\//,""),C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=a.Date,F=a.setTimeout,G={document:void 0!==a.document,setTimeout:void 0!==a.setTimeout,sessionStorage:function(){var a="qunit-test-string";try{return sessionStorage.setItem(a,a),sessionStorage.removeItem(a),!0}catch(a){return!1}}()},H=function(a){var b,c,d=a.toString();return"[object"===d.substring(0,7)?(b=a.name?a.name.toString():"Error",c=a.message?a.message.toString():"",b&&c?b+": "+c:b||(c||"Error")):d},I=function(a){var b,c,d=w.is("array",a)?[]:{};for(b in a)D.call(a,b)&&(c=a[b],d[b]=c===Object(c)?I(c):c);return d};w={module:function(a,b){y.currentModule=a,y.currentModuleTestEnvironment=b,y.modules[a]=!0},asyncTest:function(a,b,c){2===arguments.length&&(c=b,b=null),w.test(a,b,c,!0)},test:function(a,b,d,g){var h,i="<span class='test-name'>"+f(a)+"</span>";2===arguments.length&&(d=b,b=null),y.currentModule&&(i="<span class='module-name'>"+f(y.currentModule)+"</span>: "+i),h=new v({nameHtml:i,testName:a,expected:b,async:g,callback:d,module:y.currentModule,moduleTestEnvironment:y.currentModuleTestEnvironment,stack:e(2)}),c(h)&&h.queue()},expect:function(a){if(1!==arguments.length)return y.current.expected;y.current.expected=a},start:function(a){return void 0===y.semaphore?void w.begin(function(){F(function(){w.start(a)})}):(y.semaphore-=a||1,y.semaphore>0?void 0:y.semaphore<0?(y.semaphore=0,void w.pushFailure("Called start() while already started (QUnit.config.semaphore was 0 already)",null,e(2))):void(G.setTimeout?F(function(){y.semaphore>0||(y.timeout&&clearTimeout(y.timeout),y.blocking=!1,h(!0))},13):(y.blocking=!1,h(!0))))},stop:function(a){y.semaphore+=a||1,y.blocking=!0,y.testTimeout&&G.setTimeout&&(clearTimeout(y.timeout),y.timeout=F(function(){w.ok(!1,"Test timed out"),y.semaphore=1,w.start()},y.testTimeout))}},function(){function a(){}a.prototype=w,w=new a,w.constructor=a}(),y={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:[]},function(){var b,c,d=a.location||{search:"",protocol:"file:"},e=d.search.slice(1).split("&"),f=e.length,g={};if(e[0])for(b=0;b<f;b++)c=e[b].split("="),c[0]=decodeURIComponent(c[0]),c[1]=!c[1]||decodeURIComponent(c[1]),g[c[0]]=c[1];w.urlParams=g,y.filter=g.filter,y.module=g.module,y.testNumber=parseInt(g.testNumber,10)||null,w.isLocal="file:"===d.protocol}(),l(w,{config:y,init:function(){l(y,{stats:{all:0,bad:0},moduleStats:{all:0,bad:0},started:+new E,updateRate:1e3,blocking:!1,autostart:!0,autorun:!1,filter:"",queue:[],semaphore:1});var a,b,c,d=r("qunit");d&&(d.innerHTML="<h1 id='qunit-header'>"+f(document.title)+"</h1><h2 id='qunit-banner'></h2><div id='qunit-testrunner-toolbar'></div><h2 id='qunit-userAgent'></h2><ol id='qunit-tests'></ol>"),a=r("qunit-tests"),b=r("qunit-banner"),c=r("qunit-testresult"),a&&(a.innerHTML=""),b&&(b.className=""),c&&c.parentNode.removeChild(c),a&&(c=document.createElement("p"),c.id="qunit-testresult",c.className="result",a.parentNode.insertBefore(c,a),c.innerHTML="Running...<br/> ")},reset:function(){var a=r("qunit-fixture");a&&(a.innerHTML=y.fixture)},is:function(a,b){return w.objectType(b)===a},objectType:function(a){if(void 0===a)return"undefined";if(null===a)return"null";var b=C.call(a).match(/^\[object\s(.*)\]$/),c=b&&b[1]||"";switch(c){case"Number":return isNaN(a)?"nan":"number";case"String":case"Boolean":case"Array":case"Date":case"RegExp":case"Function":return c.toLowerCase()}return"object"==typeof a?"object":void 0},push:function(a,b,c,d){if(!y.current)throw new Error("assertion outside test context, was "+e());var g,h,i={module:y.current.module,name:y.current.testName,result:a,message:d,actual:b,expected:c};d=f(d)||(a?"okay":"failed"),d="<span class='test-message'>"+d+"</span>",g=d,a||(c=f(w.jsDump.parse(c)),b=f(w.jsDump.parse(b)),g+="<table><tr class='test-expected'><th>Expected: </th><td><pre>"+c+"</pre></td></tr>",b!==c&&(g+="<tr class='test-actual'><th>Result: </th><td><pre>"+b+"</pre></td></tr>",g+="<tr class='test-diff'><th>Diff: </th><td><pre>"+w.diff(c,b)+"</pre></td></tr>"),h=e(),h&&(i.source=h,g+="<tr class='test-source'><th>Source: </th><td><pre>"+f(h)+"</pre></td></tr>"),g+="</table>"),t("log",w,i),y.current.assertions.push({result:!!a,message:g})},pushFailure:function(a,b,c){if(!y.current)throw new Error("pushFailure() assertion outside test context, was "+e(2));var d,g={module:y.current.module,name:y.current.testName,result:!1,message:a};a=f(a)||"error",a="<span class='test-message'>"+a+"</span>",d=a,d+="<table>",c&&(d+="<tr class='test-actual'><th>Result: </th><td><pre>"+f(c)+"</pre></td></tr>"),b&&(g.source=b,d+="<tr class='test-source'><th>Source: </th><td><pre>"+f(b)+"</pre></td></tr>"),d+="</table>",t("log",w,g),y.current.assertions.push({result:!1,message:d})},url:function(b){b=l(l({},w.urlParams),b);var c,d="?";for(c in b)D.call(b,c)&&(d+=encodeURIComponent(c)+"="+encodeURIComponent(b[c])+"&");return a.location.protocol+"//"+a.location.host+a.location.pathname+d.slice(0,-1)},extend:l,id:r,addEvent:m,addClass:p,hasClass:o,removeClass:q}),l(w.constructor.prototype,{begin:s("begin"),done:s("done"),log:s("log"),testStart:s("testStart"),testDone:s("testDone"),moduleStart:s("moduleStart"),moduleDone:s("moduleDone")}),G.document&&"complete"!==document.readyState||(y.autorun=!0),w.load=function(){t("begin",w,{});var b,c,d,e,g,h,i,j,k,o,p,q,s,u=0,v=[],x="",z="",A=l({},y);for(w.init(),l(y,A),y.blocking=!1,g=y.urlConfig.length,d=0;d<g;d++)o=y.urlConfig[d],"string"==typeof o&&(o={id:o,label:o,tooltip:"[no tooltip available]"}),y[o.id]=w.urlParams[o.id],z+="<input id='qunit-urlconfig-"+f(o.id)+"' name='"+f(o.id)+"' type='checkbox'"+(y[o.id]?" checked='checked'":"")+" title='"+f(o.tooltip)+"'><label for='qunit-urlconfig-"+f(o.id)+"' title='"+f(o.tooltip)+"'>"+o.label+"</label>";for(d in y.modules)y.modules.hasOwnProperty(d)&&v.push(d);for(u=v.length,v.sort(function(a,b){return a.localeCompare(b)}),x+="<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' "+(void 0===y.module?"selected='selected'":"")+">< All Modules ></option>",d=0;d<u;d++)x+="<option value='"+f(encodeURIComponent(v[d]))+"' "+(y.module===v[d]?"selected='selected'":"")+">"+f(v[d])+"</option>";x+="</select>",k=r("qunit-userAgent"),k&&(k.innerHTML=navigator.userAgent),b=r("qunit-header"),b&&(b.innerHTML="<a href='"+w.url({filter:void 0,module:void 0,testNumber:void 0})+"'>"+b.innerHTML+"</a> "),j=r("qunit-testrunner-toolbar"),j&&(c=document.createElement("input"),c.type="checkbox",c.id="qunit-filter-pass",m(c,"click",function(){var a,b=r("qunit-tests");c.checked?b.className=b.className+" hidepass":(a=" "+b.className.replace(/[\n\t\r]/g," ")+" ",b.className=a.replace(/ hidepass /," ")),G.sessionStorage&&(c.checked?sessionStorage.setItem("qunit-filter-passed-tests","true"):sessionStorage.removeItem("qunit-filter-passed-tests"))}),(y.hidepassed||G.sessionStorage&&sessionStorage.getItem("qunit-filter-passed-tests"))&&(c.checked=!0,i=r("qunit-tests"),i.className=i.className+" hidepass"),j.appendChild(c),e=document.createElement("label"),e.setAttribute("for","qunit-filter-pass"),e.setAttribute("title","Only show tests and assertions that fail. Stored in sessionStorage."),e.innerHTML="Hide passed tests",j.appendChild(e),p=document.createElement("span"),p.innerHTML=z,q=p.getElementsByTagName("input"),n(q,"click",function(b){var c={},d=b.target||b.srcElement;c[d.name]=!!d.checked||void 0,a.location=w.url(c)}),j.appendChild(p),u>1&&(s=document.createElement("span"),s.setAttribute("id","qunit-modulefilter-container"),s.innerHTML=x,m(s.lastChild,"change",function(){var b=s.getElementsByTagName("select")[0],c=decodeURIComponent(b.options[b.selectedIndex].value);a.location=w.url({module:""===c?void 0:c,filter:void 0,testNumber:void 0})}),j.appendChild(s))),h=r("qunit-fixture"),h&&(y.fixture=h.innerHTML),y.autostart&&w.start()},G.document&&m(a,"load",w.load),z=a.onerror,a.onerror=function(a,b,d){var e=!1;if(z&&(e=z(a,b,d)),!0!==e){if(w.config.current){if(w.config.current.ignoreGlobalErrors)return!0;w.pushFailure(a,b+":"+d)}else w.test("global failure",l(function(){w.pushFailure(a,b+":"+d)},{validTest:c}));return!1}return e},v.count=0,v.prototype={init:function(){var a,b,c,d=r("qunit-tests");d&&(b=document.createElement("strong"),b.innerHTML=this.nameHtml,a=document.createElement("a"),a.innerHTML="Rerun",a.href=w.url({testNumber:this.testNumber}),c=document.createElement("li"),c.appendChild(b),c.appendChild(a),c.className="running",c.id=this.id="qunit-test-output"+A++,d.appendChild(c))},setup:function(){if(this.module===y.previousModule&&D.call(y,"previousModule")||(D.call(y,"previousModule")&&t("moduleDone",w,{name:y.previousModule,failed:y.moduleStats.bad,passed:y.moduleStats.all-y.moduleStats.bad,total:y.moduleStats.all}),y.previousModule=this.module,y.moduleStats={all:0,bad:0},t("moduleStart",w,{name:this.module})),y.current=this,this.testEnvironment=l({setup:function(){},teardown:function(){}},this.moduleTestEnvironment),this.started=+new E,t("testStart",w,{name:this.testName,module:this.module}),w.current_testEnvironment=this.testEnvironment,y.pollution||i(),y.notrycatch)return void this.testEnvironment.setup.call(this.testEnvironment,w.assert);try{this.testEnvironment.setup.call(this.testEnvironment,w.assert)}catch(a){w.pushFailure("Setup failed on "+this.testName+": "+(a.message||a),d(a,1))}},run:function(){y.current=this;var a=r("qunit-testresult");if(a&&(a.innerHTML="Running: <br/>"+this.nameHtml),this.async&&w.stop(),this.callbackStarted=+new E,y.notrycatch)return this.callback.call(this.testEnvironment,w.assert),void(this.callbackRuntime=+new E-this.callbackStarted);try{this.callback.call(this.testEnvironment,w.assert),this.callbackRuntime=+new E-this.callbackStarted}catch(a){this.callbackRuntime=+new E-this.callbackStarted,w.pushFailure("Died on test #"+(this.assertions.length+1)+" "+this.stack+": "+(a.message||a),d(a,0)),i(),y.blocking&&w.start()}},teardown:function(){if(y.current=this,y.notrycatch)return void 0===this.callbackRuntime&&(this.callbackRuntime=+new E-this.callbackStarted),void this.testEnvironment.teardown.call(this.testEnvironment,w.assert);try{this.testEnvironment.teardown.call(this.testEnvironment,w.assert)}catch(a){w.pushFailure("Teardown failed on "+this.testName+": "+(a.message||a),d(a,1))}j()},finish:function(){y.current=this,y.requireExpects&&null===this.expected?w.pushFailure("Expected number of assertions to be defined, but expect() was not called.",this.stack):null!==this.expected&&this.expected!==this.assertions.length?w.pushFailure("Expected "+this.expected+" assertions, but "+this.assertions.length+" were run",this.stack):null!==this.expected||this.assertions.length||w.pushFailure("Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.",this.stack);var b,c,d,e,f,g,h,i=this,j=0,k=0,l=r("qunit-tests");if(this.runtime=+new E-this.started,y.stats.all+=this.assertions.length,y.moduleStats.all+=this.assertions.length,l){for(h=document.createElement("ol"),h.className="qunit-assert-list",b=0;b<this.assertions.length;b++)c=this.assertions[b],g=document.createElement("li"),g.className=c.result?"pass":"fail",g.innerHTML=c.message||(c.result?"okay":"failed"),h.appendChild(g),c.result?j++:(k++,y.stats.bad++,y.moduleStats.bad++);w.config.reorder&&G.sessionStorage&&(k?sessionStorage.setItem("qunit-test-"+this.module+"-"+this.testName,k):sessionStorage.removeItem("qunit-test-"+this.module+"-"+this.testName)),0===k&&p(h,"qunit-collapsed"),e=document.createElement("strong"),e.innerHTML=this.nameHtml+" <b class='counts'>(<b class='failed'>"+k+"</b>, <b class='passed'>"+j+"</b>, "+this.assertions.length+")</b>",m(e,"click",function(){var a=e.parentNode.lastChild;(o(a,"qunit-collapsed")?q:p)(a,"qunit-collapsed")}),m(e,"dblclick",function(b){var c=b&&b.target?b.target:a.event.srcElement;"span"!==c.nodeName.toLowerCase()&&"b"!==c.nodeName.toLowerCase()||(c=c.parentNode),a.location&&"strong"===c.nodeName.toLowerCase()&&(a.location=w.url({testNumber:i.testNumber}))}),f=document.createElement("span"),f.className="runtime",f.innerHTML=this.runtime+" ms",g=r(this.id),g.className=k?"fail":"pass",g.removeChild(g.firstChild),d=g.firstChild,g.appendChild(e),g.appendChild(d),g.appendChild(f),g.appendChild(h)}else for(b=0;b<this.assertions.length;b++)this.assertions[b].result||(k++,y.stats.bad++,y.moduleStats.bad++);t("testDone",w,{name:this.testName,module:this.module,failed:k,passed:this.assertions.length-k,total:this.assertions.length,runtime:this.runtime,duration:this.runtime}),w.reset(),y.current=void 0},queue:function(){function a(){g(function(){c.setup()}),g(function(){c.run()}),g(function(){c.teardown()}),g(function(){c.finish()})}var b,c=this;g(function(){c.init()}),b=w.config.reorder&&G.sessionStorage&&+sessionStorage.getItem("qunit-test-"+this.module+"-"+this.testName),b?a():g(a,!0)}},x=w.assert={ok:function(a,b){if(!y.current)throw new Error("ok() assertion outside test context, was "+e(2));a=!!a,b=b||(a?"okay":"failed");var c,d={module:y.current.module,name:y.current.testName,result:a,message:b};b="<span class='test-message'>"+f(b)+"</span>",a||(c=e(2))&&(d.source=c,b+="<table><tr class='test-source'><th>Source: </th><td><pre>"+f(c)+"</pre></td></tr></table>"),t("log",w,d),y.current.assertions.push({result:a,message:b})},equal:function(a,b,c){w.push(b==a,a,b,c)},notEqual:function(a,b,c){w.push(b!=a,a,b,c)},propEqual:function(a,b,c){a=I(a),b=I(b),w.push(w.equiv(a,b),a,b,c)},notPropEqual:function(a,b,c){a=I(a),b=I(b),w.push(!w.equiv(a,b),a,b,c)},deepEqual:function(a,b,c){w.push(w.equiv(a,b),a,b,c)},notDeepEqual:function(a,b,c){w.push(!w.equiv(a,b),a,b,c)},strictEqual:function(a,b,c){w.push(b===a,a,b,c)},notStrictEqual:function(a,b,c){w.push(b!==a,a,b,c)},throws:function(a,b,c){var d,e=b,f=!1;"string"==typeof b&&(c=b,b=null),y.current.ignoreGlobalErrors=!0;try{a.call(y.current.testEnvironment)}catch(a){d=a}y.current.ignoreGlobalErrors=!1,d?(b?"regexp"===w.objectType(b)?f=b.test(H(d)):d instanceof b?f=!0:!0===b.call({},d)&&(e=null,f=!0):(f=!0,e=null),w.push(f,d,e,c)):w.pushFailure(c,null,"No exception was thrown.")}},l(w.constructor.prototype,x),w.constructor.prototype.raises=function(){w.push(!1,!1,!1,"QUnit.raises has been deprecated since 2012 (fad3c1ea), use QUnit.throws instead")},w.constructor.prototype.equals=function(){w.push(!1,!1,!1,"QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead")},w.constructor.prototype.same=function(){w.push(!1,!1,!1,"QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead")},w.equiv=function(){function a(a,b,c){var d=w.objectType(a);if(d)return"function"===w.objectType(b[d])?b[d].apply(b,c):b[d]}var b,c=[],d=[],e=[],f=Object.getPrototypeOf||function(a){return a.__proto__},g=function(){function a(a,b){return a instanceof b.constructor||b instanceof a.constructor?b==a:b===a}return{string:a,boolean:a,number:a,null:a,undefined:a,nan:function(a){return isNaN(a)},date:function(a,b){return"date"===w.objectType(a)&&b.valueOf()===a.valueOf()},regexp:function(a,b){return"regexp"===w.objectType(a)&&b.source===a.source&&b.global===a.global&&b.ignoreCase===a.ignoreCase&&b.multiline===a.multiline&&b.sticky===a.sticky},function:function(){var a=c[c.length-1];return a!==Object&&void 0!==a},array:function(a,c){var f,g,h,i,j,k;if("array"!==w.objectType(a))return!1;if((h=c.length)!==a.length)return!1;for(d.push(c),e.push(a),f=0;f<h;f++){for(i=!1,g=0;g<d.length;g++)if(j=d[g]===c[f],k=e[g]===a[f],j||k){if(!(c[f]===a[f]||j&&k))return d.pop(),e.pop(),!1;i=!0}if(!i&&!b(c[f],a[f]))return d.pop(),e.pop(),!1}return d.pop(),e.pop(),!0},object:function(a,g){var h,i,j,k,l,m=!0,n=[],o=[];if(g.constructor!==a.constructor&&!(null===f(g)&&f(a)===Object.prototype||null===f(a)&&f(g)===Object.prototype))return!1;c.push(g.constructor),d.push(g),e.push(a);for(h in g){for(j=!1,i=0;i<d.length;i++)if(k=d[i]===g[h],l=e[i]===a[h],k||l){if(!(g[h]===a[h]||k&&l)){m=!1;break}j=!0}if(n.push(h),!j&&!b(g[h],a[h])){m=!1;break}}d.pop(),e.pop(),c.pop();for(h in a)o.push(h);return m&&b(n.sort(),o.sort())}}}();return b=function(){var c=[].slice.apply(arguments);return c.length<2||function(b,c){return b===c||null!==b&&null!==c&&void 0!==b&&void 0!==c&&w.objectType(b)===w.objectType(c)&&a(b,g,[c,b])}(c[0],c[1])&&b.apply(this,c.splice(1,c.length-1))}}(),w.jsDump=function(){function a(a){return'"'+a.toString().replace(/"/g,'\\"')+'"'}function b(a){return a+""}function c(a,b,c){var d=f.separator(),e=f.indent(),g=f.indent(1);return b.join&&(b=b.join(","+d+g)),b?[a,g+b,e+c].join(d):a+c}function d(a,b){var d=a.length,e=new Array(d);for(this.up();d--;)e[d]=this.parse(a[d],void 0,b);return this.down(),c("[",e,"]")}var e=/^function (\w+)/,f={parse:function(a,b,c){c=c||[];var d,e,f=this.parsers[b||this.typeOf(a)];return b=typeof f,d=u(a,c),-1!==d?"recursion("+(d-c.length)+")":"function"===b?(c.push(a),e=f.call(this,a,c),c.pop(),e):"string"===b?f:this.parsers.error},typeOf:function(a){return null===a?"null":void 0===a?"undefined":w.is("regexp",a)?"regexp":w.is("date",a)?"date":w.is("function",a)?"function":void 0!==typeof a.setInterval&&void 0!==a.document&&void 0===a.nodeType?"window":9===a.nodeType?"document":a.nodeType?"node":"[object Array]"===C.call(a)||"number"==typeof a.length&&void 0!==a.item&&(a.length?a.item(0)===a[0]:null===a.item(0)&&void 0===a[0])?"array":a.constructor===Error.prototype.constructor?"error":typeof a},separator:function(){return this.multiline?this.HTML?"<br />":"\n":this.HTML?" ":" "},indent:function(a){if(!this.multiline)return"";var b=this.indentChar;return this.HTML&&(b=b.replace(/\t/g," ").replace(/ /g," ")),new Array(this.depth+(a||0)).join(b)},up:function(a){this.depth+=a||1},down:function(a){this.depth-=a||1},setParser:function(a,b){this.parsers[a]=b},quote:a,literal:b,join:c,depth:1,parsers:{window:"[Window]",document:"[Document]",error:function(a){return'Error("'+a.message+'")'},unknown:"[Unknown]",null:"null",undefined:"undefined",function:function(a){var b="function",d="name"in a?a.name:(e.exec(a)||[])[1];return d&&(b+=" "+d),b+="( ",b=[b,w.jsDump.parse(a,"functionArgs"),"){"].join(""),c(b,w.jsDump.parse(a,"functionCode"),"}")},array:d,nodelist:d,arguments:d,object:function(a,b){var d,e,f,g,h=[];w.jsDump.up(),d=[];for(e in a)d.push(e);for(d.sort(),g=0;g<d.length;g++)e=d[g],f=a[e],h.push(w.jsDump.parse(e,"key")+": "+w.jsDump.parse(f,void 0,b));return w.jsDump.down(),c("{",h,"}")},node:function(a){var b,c,d,e=w.jsDump.HTML?"<":"<",f=w.jsDump.HTML?">":">",g=a.nodeName.toLowerCase(),h=e+g,i=a.attributes;if(i)for(c=0,b=i.length;c<b;c++)(d=i[c].nodeValue)&&"inherit"!==d&&(h+=" "+i[c].nodeName+"="+w.jsDump.parse(d,"attribute"));return h+=f,3!==a.nodeType&&4!==a.nodeType||(h+=a.nodeValue),h+e+"/"+g+f},functionArgs:function(a){var b,c=a.length;if(!c)return"";for(b=new Array(c);c--;)b[c]=String.fromCharCode(97+c);return" "+b.join(", ")+" "},key:a,functionCode:"[code]",attribute:a,string:a,date:a,regexp:b,number:b,boolean:b},HTML:!1,indentChar:" ",multiline:!0};return f}(),w.diff=function(){function a(a,b){var c,d={},e={};for(c=0;c<b.length;c++)D.call(d,b[c])||(d[b[c]]={rows:[],o:null}),d[b[c]].rows.push(c);for(c=0;c<a.length;c++)D.call(e,a[c])||(e[a[c]]={rows:[],n:null}),e[a[c]].rows.push(c);for(c in d)D.call(d,c)&&1===d[c].rows.length&&D.call(e,c)&&1===e[c].rows.length&&(b[d[c].rows[0]]={text:b[d[c].rows[0]],row:e[c].rows[0]},a[e[c].rows[0]]={text:a[e[c].rows[0]],row:d[c].rows[0]});for(c=0;c<b.length-1;c++)null!=b[c].text&&null==b[c+1].text&&b[c].row+1<a.length&&null==a[b[c].row+1].text&&b[c+1]==a[b[c].row+1]&&(b[c+1]={text:b[c+1],row:b[c].row+1},a[b[c].row+1]={text:a[b[c].row+1],row:c+1});for(c=b.length-1;c>0;c--)null!=b[c].text&&null==b[c-1].text&&b[c].row>0&&null==a[b[c].row-1].text&&b[c-1]==a[b[c].row-1]&&(b[c-1]={text:b[c-1],row:b[c].row-1},a[b[c].row-1]={text:a[b[c].row-1],row:c-1});return{o:a,n:b}}return function(b,c){b=b.replace(/\s+$/,""),c=c.replace(/\s+$/,"");var d,e,f="",g=a(""===b?[]:b.split(/\s+/),""===c?[]:c.split(/\s+/)),h=b.match(/\s+/g),i=c.match(/\s+/g);if(null==h?h=[" "]:h.push(" "),null==i?i=[" "]:i.push(" "),0===g.n.length)for(d=0;d<g.o.length;d++)f+="<del>"+g.o[d]+h[d]+"</del>";else{if(null==g.n[0].text)for(c=0;c<g.o.length&&null==g.o[c].text;c++)f+="<del>"+g.o[c]+h[c]+"</del>";for(d=0;d<g.n.length;d++)if(null==g.n[d].text)f+="<ins>"+g.n[d]+i[d]+"</ins>";else{for(e="",c=g.n[d].row+1;c<g.o.length&&null==g.o[c].text;c++)e+="<del>"+g.o[c]+h[c]+"</del>";f+=" "+g.n[d].text+i[d]+e}}return f}}(),void 0!==a&&(l(a,w.constructor.prototype),a.QUnit=w),"undefined"!=typeof module&&module.exports&&(module.exports=w)}(function(){return this}()),function(){this.getInjector=function(){return angular.injector(["ng","sideBySide"])}}.call(this),function(){var a,b,c,d;c={},a={},b={},module("filter",{setup:function(){var b;return b=getInjector(),c=b.get("poems"),a=b.get("filter")}}),d=function(){return b.poe={meta:{Active:!1,Author:"Edgar Allan Poe",Title:"The Raven",Year:"1845",Language:"English",Code:"poe"}},b.vrch={meta:{Active:!1,Author:"Jaroslav Vrchlický",Title:"Havran",Year:"1845",Language:"Czech",Code:"vrch"}},b.muz={meta:{Active:!1,Author:"Augustin Eugen Mužík",Title:"Havran",Year:"1885",Language:"Czech",Code:"muz"}},b.dolu={meta:{Active:!1,Author:"Karel Dostál Lutinov",Title:"Havran",Year:"1918",Language:"Czech",Code:"dolu"}},c.all=[b.poe,b.vrch,b.muz,b.dolu]},test("get filter for poems that share a common property",function(){return d(),b.dolu.meta.Active=!0,b.vrch.meta.Active=!0,b.muz.meta.Active=!0,a.update(),deepEqual(a.getFilter(),{Language:["Czech"]})}),test("get filter for arbitrary poems using shortest key",function(){return d(),b.vrch.meta.Active=!0,b.muz.meta.Active=!0,a.update(),deepEqual(a.getFilter(),{Code:["vrch","muz"]})}),test("set filter",function(){return d(),b.vrch.meta.Active=!0,a.update(),a.setFilter({Language:["English"]}),equal(b.vrch.meta.Active,!1),equal(b.poe.meta.Active,!0),deepEqual(a.getFilter(),{Code:["poe"]})})}.call(this),function(){var a,b;a={},module("poems",{setup:function(){return a=getInjector().get("poems")}}),b=function(){return a.all=[{meta:{Active:!0},content:[{section:"1",text:"one"}]},{meta:{Active:!1},content:[{section:"2",text:"two"}]},{meta:{Active:!0},content:[{section:"3",text:"three"}]},{meta:{},content:[{section:"4",text:"four"}]}]},test("has default content",function(){var b;return b=a.getActive(),equal(b[0].content[0].text,"Please be patient!"),equal(b[0].content[0].section,"Loading...")}),test("gets active",function(){var c;return b(),c=a.getActive(),equal(c[0].content[0].section,"1"),equal(c[1].content[0].section,"3")}),test("gets inactive",function(){var c;return b(),c=a.getInactive(),equal(c[0].content[0].section,"2"),equal(c[1].content[0].section,"4")})}.call(this),function(){var a,b;a={},module("route",{}),b=function(b,c,d){return null==b&&(b="http://example.com"),null==c&&(c="/base:asdf/section:7"),null==d&&(d="#test"),angular.module("sideBySide").service("$location",function(){return this.path=function(){return c},this.url=function(){return c+d},this.absUrl=function(){return b+c+d},this}),a=getInjector().get("route")},test("has app url",function(){return b(),equal(a.appUrl,"http://example.com")}),test("gets parameters",function(){return b(),equal(a.get(),"base:asdf/section:7")}),test("gets base dir",function(){return b(),equal(a.getBaseDir(),"http://example.com/asdf/")}),test("gets more complicated base dir",function(){return b("http://example.com/path/#","/base:test.this",""),equal(a.getBaseDir(),"http://example.com/path/test/this/")}),test("updates parameters",function(){return b(),a.update("base","zxcv"),equal(a.get(),"base:zxcv/section:7")}),test("adds parameter",function(){return b("http://example.com","/base:asdf"),a.update("section","1"),equal(a.get(),"base:asdf/section:1")}),test("processes arrays from url",function(){return b("http://example.com","/display:Language:Czech,English",""),deepEqual(a.params,{base:"",display:{Language:["Czech","English"]}})}),test("adds base before section",function(){return b("http://example.com","/section:7",""),a.update("base","the_raven"),equal(a.get(),"base:the_raven/section:7")}),test("works with hash url",function(){return b("http://example.com/#","/base:asdf",""),deepEqual(a.appUrl,"http://example.com"),deepEqual(a.params,{base:"asdf"})})}.call(this),function(){var a,b,c,d,e;e={},b={},a={},d={},c={},module("transformer",{setup:function(){return e=getInjector().get("transformer"),b={meta:{Title:"Ten Commandments",Author:"God knows"},content:[{section:"1",text:"Thou shalt have no other gods before me"},{section:"2",text:"Thou shalt not take the name of the Lord thy God in vain"},{section:"3",text:"Remember the sabbath day, to keep it holy"}]},a={meta:{Title:"Desatero",Author:"Ví bůh"},content:[{section:"1",text:"V jednoho Boha věřiti budeš."},{section:"2",text:"Nevezmeš jména Božího nadarmo."},{section:"3",text:"Pomni, abys den sváteční světil."}]},d={meta:{Title:"Dekalog",Author:"Bóg wie"},content:[{section:"1",text:"Nie będziesz miał bogów cudzych przede mną."},{section:"2",text:"Nie będziesz wzywał imienia Boga twego nadaremno."},{section:"3",text:"Pamiętaj, abyś dzień święty święcił."}]},c={meta:[{Title:"Ten Commandments",Author:"God knows"},{Title:"Desatero",Author:"Ví bůh"},{Title:"Dekalog",Author:"Bóg wie"}],verses:[[{section:"1",text:"Thou shalt have no other gods before me"},{section:"1",text:"V jednoho Boha věřiti budeš."},{section:"1",text:"Nie będziesz miał bogów cudzych przede mną."}],[{section:"2",text:"Thou shalt not take the name of the Lord thy God in vain"},{section:"2",text:"Nevezmeš jména Božího nadarmo."},{section:"2",text:"Nie będziesz wzywał imienia Boga twego nadaremno."}],[{section:"3",text:"Remember the sabbath day, to keep it holy"},{section:"3",text:"Pomni, abys den sváteční světil."},{section:"3",text:"Pamiętaj, abyś dzień święty święcił."}]]}}}),test("transforms",function(){return deepEqual(e([b,a,d]),c)}),test("transforms with 2 items",function(){return c.meta=c.meta.slice(0,2),c.verses=_.map(c.verses,function(a){return a.slice(0,2)}),deepEqual(e([b,a]),c)}),test("throws error on no param",function(){return throws(function(){return e()},/no poems found/i)}),test("throws error on empty array",function(){return throws(function(){return e([])},/no poems found/i)}),test("throws error on poem being too short",function(){return a.content.pop(),throws(function(){return e([b,a,d])},/missing.*nevezmeš jména/i)}),test("throws error on poem being too long",function(){return a.content.pop(),d.content.pop(),throws(function(){return e([b,a,d])},/superfluous.*sabbath/i)}),test("throws error on poems too short plus different lengths",function(){return a.content.pop(),d.content.pop(),d.content.pop(),throws(function(){return e([b,a,d])},/missing.*bogów cudzych.*nevezmeš/i)})}.call(this),function(){var a;a={},module("reader factory",{setup:function(){return a=getInjector().get("readerFactory")}}),test("reads markdown",function(){return ok(a("somefile.md")),ok(a("otherfile.markdown"))}),test("reads json",function(){return ok(a("fried.json"))}),test("doesn't read doc",function(){return throws(function(){return a("microsoft.doc")},/unknown/i)})}.call(this),function(){var a;a={},module("json reader",{setup:function(){return a=getInjector().get("jsonReader")}}),test("loads poem",function(){
|
|
return deepEqual(a('{\n\tmeta: {\n\t\tTitle: "Test leading text"\n\t},\n\tcontent: [\n\t\t"<p><strong>This</strong> is leading text.</p>",\n\t\t{ section: "I", text: "<p>First section.</p>" },\n\t\t{ section: "II", text: "<p>Second section.</p>" },\n\t\t{ text: "<p>Another section.</p>" },\n\t],\n}'),{meta:{Title:"Test leading text"},content:[{section:"",text:"<p><strong>This</strong> is leading text.</p>"},{section:"I",text:"<p>First section.</p>"},{section:"II",text:"<p>Second section.</p>"},{section:"",text:"<p>Another section.</p>"}]})})}.call(this),function(){var a;a={},module("markdown reader",{setup:function(){return a=getInjector().get("markdownReader")}}),test("loads poem with section numbers, paragraphs, and a list",function(){return deepEqual(a("Title: Universal Declaration of Human Rights\nAuthor: John Peters Humphrey\nDate: 1948\nSource: http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights\n\n## 1\nAll human beings are born *free* and equal in dignity and rights...\n\n## 2\nEveryone is entitled to all the rights and freedoms...\n\nFurthermore, no distinction shall be made on the basis of...\n\n## 11.1\nEveryone charged with a penal offence has the right to be presumed...\n\n## 11.2\nNo one shall be held guilty of any penal offence...\n\n## 13\nEveryone is entitled to:\n\n- sex\n- drugs\n- rock & roll"),{meta:{Title:"Universal Declaration of Human Rights",Author:"John Peters Humphrey",Date:"1948",Source:'<a href="http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights">http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights</a>'},content:[{section:"1",text:"<p>All human beings are born <em>free</em> and equal in dignity and rights…</p>\n"},{section:"2",text:"<p>Everyone is entitled to all the rights and freedoms…</p>\n<p>Furthermore, no distinction shall be made on the basis of…</p>\n"},{section:"11.1",text:"<p>Everyone charged with a penal offence has the right to be presumed…</p>\n"},{section:"11.2",text:"<p>No one shall be held guilty of any penal offence…</p>\n"},{section:"13",text:"<p>Everyone is entitled to:</p>\n<ul>\n<li>sex</li>\n<li>drugs</li>\n<li>rock & roll</li>\n</ul>\n"}]})}),test("loads poem with leading text and mixed separators",function(){return deepEqual(a("Title: Test leading text and mixed separators\n\n**This** is leading text.\n# I\nFirst section.\n\n---\nSecond section."),{meta:{Title:"Test leading text and mixed separators"},content:[{section:"",text:"<p><strong>This</strong> is leading text.</p>\n"},{section:"I",text:"<p>First section.</p>\n"},{section:"",text:"<p>Second section.</p>\n"}]})}),test("loads poem using a custom separator",function(){return deepEqual(a("Title: Separator test\nSeparator: heading\n\n# I\nFirst section.\n\n---\nSecond part.\n\n# II\nSecond section."),{meta:{Title:"Separator test",Separator:"heading"},content:[{section:"I",text:"<p>First section.</p>\n<hr>\n<p>Second part.</p>\n"},{section:"II",text:"<p>Second section.</p>\n"}]})})}.call(this); |