dojo.provide("dojox.widget.DocTester"); dojo.require("dojo.string"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("dojox.form.BusyButton"); dojo.require("dojox.testing.DocTest"); dojo.declare('dojox.widget.DocTester', [dijit._Widget, dijit._Templated], { // summary: A widget to run DocTests inside an HTML page. // templatePath: dojo.moduleUrl('dojox.widget','DocTester/DocTester.html'), widgetsInTemplate: true, _fillContent:function(/*DomNode*/source){ // summary: Overridden from _Templates.js, which actually just takes care of filling the containerNode. var src = source.innerHTML; this.doctests = new dojox.testing.DocTest(); this.tests = this.doctests.getTestsFromString(this._unescapeHtml(src)); var lineNumbers = dojo.map(this.tests, 'return item.line-1'); var lines = src.split("\n"); var actualResultHtml = '
FAILED, actual result was:
'; var content = '
';
			for (var i=0; i0 && index!=-1){
					var evenOdd = index%2 ? "even" : "odd";
					content += actualResultHtml;
 					content += '
';
				}
				content += lines[i].replace(/^\s+/, "")+"\n";
			}
			content += actualResultHtml + '
'; this.containerNode.innerHTML = content; }, postCreate:function(){ this.inherited("postCreate", arguments); dojo.connect(this.runButtonNode, "onClick", dojo.hitch(this, "runTests")); dojo.connect(this.resetButtonNode, "onClick", dojo.hitch(this, "reset")); this.numTestsNode.innerHTML = this.tests.length; }, runTests:function(){ var results = {ok:0, nok:0}; for (var i=0; i"' str = String(str).replace(/&/gm, "&").replace(/</gm, "<") .replace(/>/gm, ">").replace(/"/gm, '"'); return str; // string } } );