javascriptのthisはよくわからないんですが、(という設定で^^;)
とりあえず、assert関係をちょっと拡張です。
●assert.css
function getProperties( object ) ul#resulter { border: 2px ridge maroon; background-color: #ccffcc; padding: 0.25em 1.5em; margin-left: 0; } li.pass { color: #006400; font-weight:bolder;} li.fail { color: #dc143c; text-decoration: line-through; font-weight:bolder;} li.prop { color: #808000; font-weight:bolder;}●assert.js
まぁ無駄は多いですが、気にせずに。
function getProperties( object ) { var ar = []; for( var pname in object ){ var pvalue = object[ pname ]; ar.push( pname + ' : ' + pvalue + "<" + typeof(pvalue) + ">" ); } return ar; } function assert(bbb, disp) { var resulter = document.getElementById("resulter"); if (!resulter) { resulter = document.createElement('ul'); document.getElementsByTagName('body')[0].appendChild(resulter); resulter.setAttribute('id','resulter'); } var li = document.createElement("li"); li.className = bbb ? "pass" : "fail"; var disper = bbb ? "●" + disp : "×" + disp; li.appendChild(document.createTextNode(disper)); resulter.appendChild(li); } function assertp( disp,bmem) { var resulter = document.getElementById("resulter"); if (!resulter) { resulter = document.createElement('ul'); document.getElementsByTagName('body')[0].appendChild(resulter); resulter.setAttribute('id','resulter'); } var li = document.createElement("li"); li.className = "prop"; var disper = bmem ? "→" + disp : disp; li.appendChild(document.createTextNode(disper)); resulter.appendChild(li); } function assertlist(list,name) { assertp( "------■" + name + "■------",false); for(var w=0;w<list.length;w++){ assertp(list[w],true); } assertp( "--------------------"); } function assertprop(o,name){ if(name == undefined) name = "unknown"; assertlist(getProperties( o ),name); }●つづく
0 件のコメント:
コメントを投稿