Posted By

dvdrtrgn on 09/09/08


Tagged

testing unit


Versions (?)

Branch.js


 / Published in: JavaScript
 

URL: http://homepage.mac.com/dr_turgeon/sources/Branch.js

  1. /*---------------------------------------------------------------------------*/
  2. /* expandable generic node object */
  3. function
  4. Branch(N){var T=this;T.P='[object Tree]';T.N=T.I=T.P;if(N){T.N=N;T.I='window["'+T.N+'"]'}};
  5. Branch.prototype.grow=function(N){
  6. if(!N)return;var T=this;var Tt=T[N]=new Branch();
  7. Tt.N=N; Tt.I=''+T.I+'["'+N+'"]'; Tt.P=T};
  8. Branch.prototype.toString=function(){return this.I};
  9. function /* a convenient preparation of a branch */
  10. Tree(str){return window[str]=new Branch(str)}
  11.  
  12. /*---------------------------------------------------------------------------*/
  13. /* test msg */
  14. var t1 = Tree('t1'); t1.grow('b1'); t1.b1.grow('l1');
  15.  
  16. log =
  17. trite(['N' ,'I' ,'P' ])+
  18. trite([ t1.N , t1.I , t1.P ])+
  19. trite([ t1.b1.N , t1.b1.I , t1.b1.P ])+
  20. trite([ t1.b1.l1.N , t1.b1.l1.I , t1.b1.l1.P ]);
  21.  
  22. log = '<table>'+ log +'</table>';
  23.  
  24. /*---------------------------------------------------------------------------*/

Report this snippet  

You need to login to post a comment.