Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9036

Show
Ignore:
Timestamp:
03/16/08 18:53:51 (2 years ago)
Author:
tobie
Message:

prototype: Remove usage of the statement from unit tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r9026 r9036  
     1* Remove usage of the `with` statement from unit tests. [Tobie Langel] 
     2 
    13* Complete rewrite of the deprecation helper, now renamed UpdateHelper and useable by third-party libs. [Tobie Langel] 
    24 
  • spinoffs/prototype/trunk/ext/update_helper/prototype_update_helper.html

    r9026 r9036  
    7777   
    7878  new Test.Unit.Runner({ 
    79     testGetStack: function(){ with(this)
    80       assertMatch(/prototype_update_helper\.html:\d+\n$/, prototypeUpdateHelper.getStack()); 
    81     }}
    82  
    83     testDisplay: function(){ with(this)
     79    testGetStack: function()
     80      this.assertMatch(/prototype_update_helper\.html:\d+\n$/, prototypeUpdateHelper.getStack()); 
     81    }
     82 
     83    testDisplay: function()
    8484      Toggle.display('foo'); 
    85       assertInfoNotified('Toggle.display has been deprecated, please use Element.toggle instead.'); 
     85      this.assertInfoNotified('Toggle.display has been deprecated, please use Element.toggle instead.'); 
    8686         
    8787      Element.show('foo', 'bar', 'bla'); 
    88       assertErrorNotified('Passing an arbitrary number of elements to Element.show is no longer supported.\n' + 
     88      this.assertErrorNotified('Passing an arbitrary number of elements to Element.show is no longer supported.\n' + 
    8989        'Use [id_1, id_2, ...].each(Element.show) or $(id_1, id_2, ...).invoke("show") instead.'); 
    9090       
    9191      $('foo', 'bar', 'bla').each(Element.hide); 
    92       assertNotNotified(); 
     92      this.assertNotNotified(); 
    9393       
    9494      Element.show('foo'); 
    95       assertNotNotified(); 
     95      this.assertNotNotified(); 
    9696       
    9797      Element.hide('foo', 'bar', 'bla'); 
    98       assertErrorNotified('Passing an arbitrary number of elements to Element.hide is no longer supported.\n' + 
     98      this.assertErrorNotified('Passing an arbitrary number of elements to Element.hide is no longer supported.\n' + 
    9999        'Use [id_1, id_2, ...].each(Element.hide) or $(id_1, id_2, ...).invoke("hide") instead.'); 
    100100       
    101101      Element.toggle('foo', 'bar', 'bla'); 
    102       assertErrorNotified('Passing an arbitrary number of elements to Element.toggle is no longer supported.\n' + 
     102      this.assertErrorNotified('Passing an arbitrary number of elements to Element.toggle is no longer supported.\n' + 
    103103        'Use [id_1, id_2, ...].each(Element.toggle) or $(id_1, id_2, ...).invoke("toggle") instead.'); 
    104     }}
    105      
    106     testElementStyle: function(){ with(this)
     104    }
     105     
     106    testElementStyle: function()
    107107      Element.setStyle('foo', { 'fontSize': '18px' }); 
    108       assertNotNotified(); 
     108      this.assertNotNotified(); 
    109109       
    110110      Element.setStyle('foo', { 'font-size': '18px' }); 
    111       assertErrorNotified('Use of uncamelized style-property names is no longer supported.\n' +  
     111      this.assertErrorNotified('Use of uncamelized style-property names is no longer supported.\n' +  
    112112        'Use either camelized style-property names or a regular CSS string instead (see online documentation).') 
    113113       
    114114      Element.setStyle('foo', 'font-size: 18px;'); 
    115       assertNotNotified(); 
     115      this.assertNotNotified(); 
    116116       
    117117      $('foo').setStyle({ 'font-size': '18px' }); 
    118       assertErrorNotified('Use of uncamelized style-property names is no longer supported.\n' +  
     118      this.assertErrorNotified('Use of uncamelized style-property names is no longer supported.\n' +  
    119119        'Use either camelized style-property names or a regular CSS string instead (see online documentation).') 
    120     }}
    121  
    122     testClassNames: function(){ with(this)
     120    }
     121 
     122    testClassNames: function()
    123123      new Element.ClassNames('foo'); 
    124       assertInfoNotified('Element.ClassNames has been deprecated.') 
     124      this.assertInfoNotified('Element.ClassNames has been deprecated.') 
    125125       
    126126      $('foo').classNames(); 
    127       assertInfoNotified('Element#classNames has been deprecated.\n' + 
     127      this.assertInfoNotified('Element#classNames has been deprecated.\n' + 
    128128        'If you need to access CSS class names as an array, try: $w(element.classname).') 
    129129 
    130130      Element.getElementsByClassName('foo', 'className'); 
    131       assertInfoNotified('Element#getElementsByClassName has been deprecated, please use Element#select instead.') 
     131      this.assertInfoNotified('Element#getElementsByClassName has been deprecated, please use Element#select instead.') 
    132132       
    133133      document.getElementsByClassName('className'); 
    134       assertInfoNotified('document.getElementsByClassName has been deprecated, please use $$ instead.') 
    135     }}
    136      
    137     testDomSelectors: function(){ with(this)
     134      this.assertInfoNotified('document.getElementsByClassName has been deprecated, please use $$ instead.') 
     135    }
     136     
     137    testDomSelectors: function()
    138138      Element.childOf('foo', 'bar'); 
    139       assertInfoNotified('Element#childOf has been deprecated, please use Element#descendantOf instead.'); 
     139      this.assertInfoNotified('Element#childOf has been deprecated, please use Element#descendantOf instead.'); 
    140140 
    141141      $('foo').immediateDescendants(); 
    142       assertInfoNotified('Element#immediateDescendants has been deprecated, please use Element#childElements instead.'); 
     142      this.assertInfoNotified('Element#immediateDescendants has been deprecated, please use Element#childElements instead.'); 
    143143       
    144144      $('foo').getElementsBySelector('a'); 
    145       assertInfoNotified('Element#getElementsBySelector has been deprecated, please use Element#select instead.'); 
     145      this.assertInfoNotified('Element#getElementsBySelector has been deprecated, please use Element#select instead.'); 
    146146 
    147147      $('foo').select('a'); 
    148       assertNotNotified(); 
    149     }}
    150      
    151     testField: function(){ with(this)
     148      this.assertNotNotified(); 
     149    }
     150     
     151    testField: function()
    152152      Field.clear('foo', 'bar', 'bla'); 
    153       assertErrorNotified('Passing an arbitrary number of elements to Field.clear is no longer supported.\n' + 
     153      this.assertErrorNotified('Passing an arbitrary number of elements to Field.clear is no longer supported.\n' + 
    154154        'Use [id_1, id_2, ...].each(Form.Element.clear) or $(id_1, id_2, ...).invoke("clear") instead.'); 
    155155         
    156156      Field.present('foo', 'bar', 'bla'); 
    157       assertErrorNotified('Passing an arbitrary number of elements to Field.present is no longer supported.\n' + 
     157      this.assertErrorNotified('Passing an arbitrary number of elements to Field.present is no longer supported.\n' + 
    158158        'Use [id_1, id_2, ...].each(Form.Element.present) or $(id_1, id_2, ...).invoke("present") instead.'); 
    159     }}
    160      
    161     testInsertion: function(){ with(this)
     159    }
     160     
     161    testInsertion: function()
    162162      Insertion.Before('foo', 'text'); 
    163       assertInfoNotified('Insertion.Before has been deprecated, please use Element#insert instead.'); 
     163      this.assertInfoNotified('Insertion.Before has been deprecated, please use Element#insert instead.'); 
    164164 
    165165      Insertion.Top('foo', 'text'); 
    166       assertInfoNotified('Insertion.Top has been deprecated, please use Element#insert instead.'); 
     166      this.assertInfoNotified('Insertion.Top has been deprecated, please use Element#insert instead.'); 
    167167 
    168168      Insertion.Bottom('foo', 'text'); 
    169       assertInfoNotified('Insertion.Bottom has been deprecated, please use Element#insert instead.'); 
     169      this.assertInfoNotified('Insertion.Bottom has been deprecated, please use Element#insert instead.'); 
    170170 
    171171      Insertion.After('foo', 'text'); 
    172       assertInfoNotified('Insertion.After has been deprecated, please use Element#insert instead.'); 
    173     }}
    174      
    175     testPosition: function(){ with(this)
     172      this.assertInfoNotified('Insertion.After has been deprecated, please use Element#insert instead.'); 
     173    }
     174     
     175    testPosition: function()
    176176      Position.prepare('foo'); 
    177       assertInfoNotified('Position.prepare has been deprecated.'); 
     177      this.assertInfoNotified('Position.prepare has been deprecated.'); 
    178178 
    179179      Position.within('foo'); 
    180       assertInfoNotified('Position.within has been deprecated.'); 
     180      this.assertInfoNotified('Position.within has been deprecated.'); 
    181181 
    182182      Position.withinIncludingScrolloffsets('foo'); 
    183       assertInfoNotified('Position.withinIncludingScrolloffsets has been deprecated.'); 
     183      this.assertInfoNotified('Position.withinIncludingScrolloffsets has been deprecated.'); 
    184184 
    185185      Position.overlap('foo'); 
    186       assertInfoNotified('Position.overlap has been deprecated.'); 
     186      this.assertInfoNotified('Position.overlap has been deprecated.'); 
    187187 
    188188      Position.cumulativeOffset('foo'); 
    189       assertInfoNotified('Position.cumulativeOffset has been deprecated, please use Element#cumulativeOffset instead.'); 
     189      this.assertInfoNotified('Position.cumulativeOffset has been deprecated, please use Element#cumulativeOffset instead.'); 
    190190 
    191191      Position.positionedOffset('foo'); 
    192       assertInfoNotified('Position.positionedOffset has been deprecated, please use Element#positionedOffset instead.'); 
     192      this.assertInfoNotified('Position.positionedOffset has been deprecated, please use Element#positionedOffset instead.'); 
    193193 
    194194      Position.absolutize('foo'); 
    195       assertInfoNotified('Position.absolutize has been deprecated, please use Element#absolutize instead.'); 
     195      this.assertInfoNotified('Position.absolutize has been deprecated, please use Element#absolutize instead.'); 
    196196 
    197197      Position.relativize('foo'); 
    198       assertInfoNotified('Position.relativize has been deprecated, please use Element#relativize instead.'); 
     198      this.assertInfoNotified('Position.relativize has been deprecated, please use Element#relativize instead.'); 
    199199 
    200200      Position.realOffset('foo'); 
    201       assertInfoNotified('Position.realOffset has been deprecated, please use Element#cumulativeScrollOffset instead.'); 
     201      this.assertInfoNotified('Position.realOffset has been deprecated, please use Element#cumulativeScrollOffset instead.'); 
    202202 
    203203      Position.offsetParent('foo'); 
    204       assertInfoNotified('Position.offsetParent has been deprecated, please use Element#getOffsetParent instead.'); 
     204      this.assertInfoNotified('Position.offsetParent has been deprecated, please use Element#getOffsetParent instead.'); 
    205205 
    206206      Position.page('foo'); 
    207       assertInfoNotified('Position.page has been deprecated, please use Element#viewportOffset instead.'); 
     207      this.assertInfoNotified('Position.page has been deprecated, please use Element#viewportOffset instead.'); 
    208208 
    209209      Position.clone('foo', 'bar'); 
    210       assertInfoNotified('Position.clone has been deprecated, please use Element#clonePosition instead.'); 
    211     }}
    212  
    213     testEvent: function(){ with(this)
     210      this.assertInfoNotified('Position.clone has been deprecated, please use Element#clonePosition instead.'); 
     211    }
     212 
     213    testEvent: function()
    214214      Event.unloadCache(); 
    215       assertErrorNotified('Event.unloadCache has been deprecated.') 
    216     }}
    217      
    218     testHash: function(){ with(this)
     215      this.assertErrorNotified('Event.unloadCache has been deprecated.') 
     216    }
     217     
     218    testHash: function()
    219219      Hash.toQueryString({}); 
    220       assertInfoNotified('Hash.toQueryString has been deprecated.\n' +  
     220      this.assertInfoNotified('Hash.toQueryString has been deprecated.\n' +  
    221221        'Use the instance method Hash#toQueryString or Object.toQueryString instead.'); 
    222222 
    223223     Hash.toJSON({}); 
    224       assertErrorNotified('Hash.toJSON has been removed.\n' +  
     224      this.assertErrorNotified('Hash.toJSON has been removed.\n' +  
    225225        'Use the instance method Hash#toJSON or Object.toJSON instead.'); 
    226226       
     
    228228       
    229229      h.remove('foo'); 
    230       assertErrorNotified('Hash#remove is no longer supported, use Hash#unset instead.\n' +  
     230      this.assertErrorNotified('Hash#remove is no longer supported, use Hash#unset instead.\n' +  
    231231        'Please note that Hash#unset only accepts one argument.'); 
    232232       
    233233      h.merge('foo'); 
    234         assertWarnNotified('Hash#merge is no longer destructive and now operates on a clone of the Hash instance.\n' + 'If you need a destructive merge, use Hash#update instead.'); 
     234        this.assertWarnNotified('Hash#merge is no longer destructive and now operates on a clone of the Hash instance.\n' + 'If you need a destructive merge, use Hash#update instead.'); 
    235235       
    236236      h['foo']; 
    237       assertErrorNotified('Directly accessing a property of an instance of Hash is no longer supported.\n' +  
     237      this.assertErrorNotified('Directly accessing a property of an instance of Hash is no longer supported.\n' +  
    238238        'Please use Hash#get(\'foo\') instead.') 
    239239       
    240240      h.foo = 3; 
    241       assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
     241      this.assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
    242242        'Please use Hash#set(\'foo\', 3) instead.') 
    243243         
    244244      h.bar = 'bar'; 
    245245      h.toJSON(); 
    246       assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
     246      this.assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
    247247        'Please use Hash#set(\'bar\', \'bar\') instead.') 
    248248         
    249249      h.bar; 
    250       assertErrorNotified('Directly accessing a property of an instance of Hash is no longer supported.\n' +  
     250      this.assertErrorNotified('Directly accessing a property of an instance of Hash is no longer supported.\n' +  
    251251        'Please use Hash#get(\'bar\') instead.') 
    252252         
    253253      h.baz = 'baz'; 
    254254      h.bar; 
    255       assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
     255      this.assertErrorNotified('Directly setting a property on an instance of Hash is no longer supported.\n' +  
    256256        'Please use Hash#set(\'baz\', \'baz\') instead.') 
    257257       
    258258      h.set('toJSON', 'arg'); // make sure hash methods are not overwritten 
    259       assertRespondsTo('toJSON', h) 
    260     }}
    261  
    262     testClass: function(){ with(this)
     259      this.assertRespondsTo('toJSON', h) 
     260    }
     261 
     262    testClass: function()
    263263      Class.create(); 
    264       assertInfoNotified('The class API has been fully revised and now allows for mixins and inheritance.\n' +  
     264      this.assertInfoNotified('The class API has been fully revised and now allows for mixins and inheritance.\n' +  
    265265        'You can find more about it here: http://prototypejs.org/learn/class-inheritance'); 
    266266      Class.create({}); 
    267       assertNotNotified(); 
    268     }}
    269      
    270     testLogDeprecationOption: function(){ with(this)
     267      this.assertNotNotified(); 
     268    }
     269     
     270    testLogDeprecationOption: function()
    271271      prototypeUpdateHelper.logLevel = UpdateHelper.Warn; 
    272272      var h = $H({ foo: 2 }); 
    273273       
    274274      h.merge({ foo: 3 }); 
    275       assertWarnNotified('Hash#merge is no longer destructive and now operates on a clone of the Hash instance.\n' + 'If you need a destructive merge, use Hash#update instead.'); 
     275      this.assertWarnNotified('Hash#merge is no longer destructive and now operates on a clone of the Hash instance.\n' + 'If you need a destructive merge, use Hash#update instead.'); 
    276276       
    277277      h.remove('foo'); 
    278       assertErrorNotified('Hash#remove is no longer supported, use Hash#unset instead.\n' +  
     278      this.assertErrorNotified('Hash#remove is no longer supported, use Hash#unset instead.\n' +  
    279279        'Please note that Hash#unset only accepts one argument.'); 
    280280       
    281281      document.getElementsByClassName('className'); 
    282       assertNotNotified(); 
     282      this.assertNotNotified(); 
    283283      prototypeUpdateHelper.logLevel = UpdateHelper.Info; 
    284     }} 
     284    } 
    285285  }); 
    286286   
  • spinoffs/prototype/trunk/test/unit/ajax.html

    r8693 r9036  
    8282   
    8383  new Test.Unit.Runner({ 
    84     setup: function()
     84    setup: function()
    8585      $('content').update(''); 
    8686      $('content2').update(''); 
    8787    }, 
    8888     
    89     teardown: function()
     89    teardown: function()
    9090      // hack to cleanup responders 
    9191      Ajax.Responders.responders = [Ajax.Responders.responders[0]]; 
    9292    }, 
    9393     
    94     testSynchronousRequest: function() {with(this) { 
    95       assertEqual("", $("content").innerHTML); 
    96        
    97       assertEqual(0, Ajax.activeRequestCount); 
     94    testSynchronousRequest: function() { 
     95      this.assertEqual("", $("content").innerHTML); 
     96       
     97      this.assertEqual(0, Ajax.activeRequestCount); 
    9898      new Ajax.Request("fixtures/hello.js", { 
    9999        asynchronous: false, 
     
    101101        evalJS: 'force' 
    102102      }); 
    103       assertEqual(0, Ajax.activeRequestCount); 
     103      this.assertEqual(0, Ajax.activeRequestCount); 
    104104       
    105105      var h2 = $("content").firstChild; 
    106       assertEqual("Hello world!", h2.innerHTML); 
    107     }}
    108      
    109     testAsynchronousRequest: function() {with(this) { 
    110       assertEqual("", $("content").innerHTML); 
     106      this.assertEqual("Hello world!", h2.innerHTML); 
     107    }
     108     
     109    testAsynchronousRequest: function() { 
     110      this.assertEqual("", $("content").innerHTML); 
    111111       
    112112      new Ajax.Request("fixtures/hello.js", { 
     
    115115        evalJS: 'force' 
    116116      }); 
    117       wait(1000, function() { 
     117      this.wait(1000, function() { 
    118118        var h2 = $("content").firstChild; 
    119         assertEqual("Hello world!", h2.innerHTML); 
    120       }); 
    121     }}
    122      
    123     testUpdater: function() {with(this) { 
    124       assertEqual("", $("content").innerHTML); 
     119        this.assertEqual("Hello world!", h2.innerHTML); 
     120      }); 
     121    }
     122     
     123    testUpdater: function() { 
     124      this.assertEqual("", $("content").innerHTML); 
    125125       
    126126      new Ajax.Updater("content", "fixtures/content.html", { method:'get' }); 
    127127       
    128       wait(1000, function() { 
    129         assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
     128      this.wait(1000, function() { 
     129        this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
    130130         
    131131        $('content').update(''); 
    132         assertEqual("", $("content").innerHTML); 
     132        this.assertEqual("", $("content").innerHTML); 
    133133          
    134134        new Ajax.Updater({ success:"content", failure:"content2" }, 
     
    137137        new Ajax.Updater("", "fixtures/content.html", { method:'get', parameters:"pet=monkey" }); 
    138138         
    139         wait(1000, function() { 
    140           assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
    141           assertEqual("", $("content2").innerHTML); 
     139        this.wait(1000, function() { 
     140          this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
     141          this.assertEqual("", $("content2").innerHTML); 
    142142        }); 
    143143      });  
    144     }}
    145      
    146     testUpdaterWithInsertion: function() {with(this) { 
     144    }
     145     
     146    testUpdaterWithInsertion: function() { 
    147147      $('content').update(); 
    148148      new Ajax.Updater("content", "fixtures/content.html", { method:'get', insertion: Insertion.Top }); 
    149       wait(1000, function() { 
    150         assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
     149      this.wait(1000, function() { 
     150        this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
    151151        $('content').update(); 
    152152        new Ajax.Updater("content", "fixtures/content.html", { method:'get', insertion: 'bottom' });       
    153         wait(1000, function() { 
    154           assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
     153        this.wait(1000, function() { 
     154          this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); 
    155155           
    156156          $('content').update(); 
    157157          new Ajax.Updater("content", "fixtures/content.html", { method:'get', insertion: 'after' });       
    158           wait(1000, function() { 
    159             assertEqual('five dozen', $("content").next().innerHTML.strip().toLowerCase()); 
     158          this.wait(1000, function() { 
     159            this.assertEqual('five dozen', $("content").next().innerHTML.strip().toLowerCase()); 
    160160          }); 
    161161        }); 
    162162      }); 
    163     }}
    164      
    165     testUpdaterOptions: function() {with(this) { 
     163    }
     164     
     165    testUpdaterOptions: function() { 
    166166      var options = { 
    167167        method: 'get', 
     
    172172      var request = new Ajax.Updater("content", "fixtures/hello.js", options); 
    173173      request.options.onComplete = function() {}; 
    174       assertIdentical(Prototype.emptyFunction, options.onComplete); 
    175     }}
    176      
    177     testResponders: function(){with(this) { 
     174      this.assertIdentical(Prototype.emptyFunction, options.onComplete); 
     175    }
     176     
     177    testResponders: function(){ 
    178178      // check for internal responder 
    179       assertEqual(1, Ajax.Responders.responders.length); 
     179      this.assertEqual(1, Ajax.Responders.responders.length); 
    180180       
    181181      var dummyResponder = { 
     
    184184       
    185185      Ajax.Responders.register(dummyResponder); 
    186       assertEqual(2, Ajax.Responders.responders.length); 
     186      this.assertEqual(2, Ajax.Responders.responders.length); 
    187187       
    188188      // don't add twice 
    189189      Ajax.Responders.register(dummyResponder); 
    190       assertEqual(2, Ajax.Responders.responders.length); 
     190      this.assertEqual(2, Ajax.Responders.responders.length); 
    191191       
    192192      Ajax.Responders.unregister(dummyResponder); 
    193       assertEqual(1, Ajax.Responders.responders.length); 
     193      this.assertEqual(1, Ajax.Responders.responders.length); 
    194194       
    195195      var responder = { 
     
    200200      Ajax.Responders.register(responder); 
    201201       
    202       assertEqual(0, responderCounter); 
    203       assertEqual(0, Ajax.activeRequestCount); 
     202      this.assertEqual(0, responderCounter); 
     203      this.assertEqual(0, Ajax.activeRequestCount); 
    204204      new Ajax.Request("fixtures/content.html", { method:'get', parameters:"pet=monkey" }); 
    205       assertEqual(1, responderCounter); 
    206       assertEqual(1, Ajax.activeRequestCount); 
    207        
    208       wait(1000,function() { 
    209         assertEqual(3, responderCounter); 
    210         assertEqual(0, Ajax.activeRequestCount); 
    211       }); 
    212     }}
    213      
    214     testEvalResponseShouldBeCalledBeforeOnComplete: function() {with(this) { 
    215       if (isRunningFromRake) { 
    216         assertEqual("", $("content").innerHTML); 
    217        
    218         assertEqual(0, Ajax.activeRequestCount); 
     205      this.assertEqual(1, responderCounter); 
     206      this.assertEqual(1, Ajax.activeRequestCount); 
     207       
     208      this.wait(1000,function() { 
     209        this.assertEqual(3, responderCounter); 
     210        this.assertEqual(0, Ajax.activeRequestCount); 
     211      }); 
     212    }
     213     
     214    testEvalResponseShouldBeCalledBeforeOnComplete: function() { 
     215      if (this.isRunningFromRake) { 
     216        this.assertEqual("", $("content").innerHTML); 
     217       
     218        this.assertEqual(0, Ajax.activeRequestCount); 
    219219        new Ajax.Request("fixtures/hello.js", extendDefault({ 
    220           onComplete: function(response) { assertNotEqual("", $("content").innerHTML) } 
    221         })); 
    222         assertEqual(0, Ajax.activeRequestCount); 
     220          onComplete: function(response) { this.assertNotEqual("", $("content").innerHTML) }.bind(this) 
     221        })); 
     222        this.assertEqual(0, Ajax.activeRequestCount); 
    223223       
    224224        var h2 = $("content").firstChild; 
    225         assertEqual("Hello world!", h2.innerHTML); 
    226       } else { 
    227         info(message); 
    228       } 
    229     }}
    230      
    231     testContentTypeSetForSimulatedVerbs: function() {with(this) { 
    232       if (isRunningFromRake) { 
     225        this.assertEqual("Hello world!", h2.innerHTML); 
     226      } else { 
     227        this.info(message); 
     228      } 
     229    }
     230     
     231    testContentTypeSetForSimulatedVerbs: function() { 
     232      if (this.isRunningFromRake) { 
    233233        new Ajax.Request('/inspect', extendDefault({ 
    234234          method: 'put', 
    235235          contentType: 'application/bogus', 
    236236          onComplete: function(response) { 
    237             assertEqual('application/bogus; charset=UTF-8', response.responseJSON.headers['content-type']); 
    238           } 
    239         })); 
    240       } else { 
    241         info(message); 
    242       } 
    243     }}
    244      
    245     testOnCreateCallback: function() {with(this) { 
     237            this.assertEqual('application/bogus; charset=UTF-8', response.responseJSON.headers['content-type']); 
     238          }.bind(this) 
     239        })); 
     240      } else { 
     241        this.info(message); 
     242      } 
     243    }
     244     
     245    testOnCreateCallback: function() { 
    246246      new Ajax.Request("fixtures/content.html", extendDefault({ 
    247         onCreate: function(transport) { assertEqual(0, transport.readyState) }
    248         onComplete: function(transport) { assertNotEqual(0, transport.readyState) } 
     247        onCreate: function(transport) { this.assertEqual(0, transport.readyState) }.bind(this)
     248        onComplete: function(transport) { this.assertNotEqual(0, transport.readyState) }.bind(this) 
    249249      })); 
    250     }}
    251      
    252     testEvalJS: function() {with(this) { 
    253       if (isRunningFromRake) { 
     250    }
     251     
     252    testEvalJS: function() { 
     253      if (this.isRunningFromRake) { 
    254254         
    255255        $('content').update(); 
     
    258258          onComplete: function(transport) {  
    259259            var h2 = $("content").firstChild; 
    260             assertEqual("Hello world!", h2.innerHTML); 
    261           } 
     260            this.assertEqual("Hello world!", h2.innerHTML); 
     261          }.bind(this) 
    262262        })); 
    263263         
     
    267267          parameters: Fixtures.js, 
    268268          onComplete: function(transport) {  
    269             assertEqual("", $("content").innerHTML); 
    270           } 
    271         })); 
    272       } else { 
    273         info(message); 
     269            this.assertEqual("", $("content").innerHTML); 
     270          }.bind(this) 
     271        })); 
     272      } else { 
     273        this.info(message); 
    274274      } 
    275275       
     
    279279        onComplete: function(transport) {  
    280280          var h2 = $("content").firstChild; 
    281           assertEqual("Hello world!", h2.innerHTML); 
    282         } 
     281          this.assertEqual("Hello world!", h2.innerHTML); 
     282        }.bind(this) 
    283283      })); 
    284     }}
    285  
    286     testCallbacks: function() {with(this) { 
     284    }
     285 
     286    testCallbacks: function() { 
    287287      var options = extendDefault({ 
    288         onCreate: function(transport) { assertInstanceOf(Ajax.Response, transport) } 
     288        onCreate: function(transport) { this.assertInstanceOf(Ajax.Response, transport) }.bind(this) 
    289289      }); 
    290290       
     
    294294 
    295295      new Ajax.Request("fixtures/content.html", options); 
    296     }}
    297  
    298     testResponseText: function() {with(this) { 
     296    }
     297 
     298    testResponseText: function() { 
    299299      new Ajax.Request("fixtures/empty.html", extendDefault({ 
    300         onComplete: function(transport) { assertEqual('', transport.responseText) } 
     300        onComplete: function(transport) { this.assertEqual('', transport.responseText) }.bind(this) 
    301301      })); 
    302302       
    303303      new Ajax.Request("fixtures/content.html", extendDefault({ 
    304         onComplete: function(transport) { assertEqual(sentence, transport.responseText.toLowerCase()) } 
     304        onComplete: function(transport) { this.assertEqual(sentence, transport.responseText.toLowerCase()) }.bind(this) 
    305305      })); 
    306     }}
    307      
    308     testResponseXML: function() {with(this) { 
    309       if (isRunningFromRake) { 
     306    }
     307     
     308    testResponseXML: function() { 
     309      if (this.isRunningFromRake) { 
    310310        new Ajax.Request("/response", extendDefault({ 
    311311          parameters: Fixtures.xml, 
    312312          onComplete: function(transport) {  
    313             assertEqual('foo', transport.responseXML.getElementsByTagName('name')[0].getAttribute('attr')) 
    314           } 
    315         })); 
    316       } else { 
    317         info(message); 
    318       } 
    319     }}
    320          
    321     testResponseJSON: function() {with(this) { 
    322       if (isRunningFromRake) { 
     313            this.assertEqual('foo', transport.responseXML.getElementsByTagName('name')[0].getAttribute('attr')) 
     314          }.bind(this) 
     315        })); 
     316      } else { 
     317        this.info(message); 
     318      } 
     319    }
     320         
     321    testResponseJSON: function() { 
     322      if (this.isRunningFromRake) { 
    323323        new Ajax.Request("/response", extendDefault({ 
    324324          parameters: Fixtures.json, 
    325           onComplete: function(transport) { assertEqual(123, transport.responseJSON.test) } 
     325          onComplete: function(transport) { this.assertEqual(123, transport.responseJSON.test) }.bind(this) 
    326326        })); 
    327327         
     
    331331            'Content-Type': 'application/json' 
    332332          }, 
    333           onComplete: function(transport) { assertNull(transport.responseJSON) } 
     333          onComplete: function(transport) { this.assertNull(transport.responseJSON) }.bind(this) 
    334334        })); 
    335335         
     
    337337          evalJSON: false, 
    338338          parameters: Fixtures.json, 
    339           onComplete: function(transport) { assertNull(transport.responseJSON) } 
     339          onComplete: function(transport) { this.assertNull(transport.responseJSON) }.bind(this) 
    340340        })); 
    341341       
    342342        new Ajax.Request("/response", extendDefault({ 
    343343          parameters: Fixtures.jsonWithoutContentType, 
    344           onComplete: function(transport) { assertNull(transport.responseJSON) } 
     344          onComplete: function(transport) { this.assertNull(transport.responseJSON) }.bind(this) 
    345345        })); 
    346346       
     
    349349          parameters: Fixtures.invalidJson, 
    350350          onException: function(request, error) { 
    351             assert(error.message.include('Badly formed JSON string')); 
    352             assertInstanceOf(Ajax.Request, request); 
    353           } 
    354         })); 
    355       } else { 
    356         info(message); 
     351            this.assert(error.message.include('Badly formed JSON string')); 
     352            this.assertInstanceOf(Ajax.Request, request); 
     353          }.bind(this) 
     354        })); 
     355      } else { 
     356        this.info(message); 
    357357      } 
    358358       
    359359      new Ajax.Request("fixtures/data.json", extendDefault({ 
    360360        evalJSON: 'force', 
    361         onComplete: function(transport) { assertEqual(123, transport.responseJSON.test) } 
     361        onComplete: function(transport) { this.assertEqual(123, transport.responseJSON.test) }.bind(this) 
    362362      })); 
    363     }}
    364      
    365     testHeaderJSON: function() {with(this) { 
    366       if (isRunningFromRake) { 
     363    }
     364     
     365    testHeaderJSON: function() { 
     366      if (this.isRunningFromRake) { 
    367367        new Ajax.Request("/response", extendDefault({ 
    368368          parameters: Fixtures.headerJson, 
    369369          onComplete: function(transport, json) { 
    370             assertEqual('hello #éà', transport.headerJSON.test); 
    371             assertEqual('hello #éà', json.test); 
    372           } 
     370            this.assertEqual('hello #éà', transport.headerJSON.test); 
     371            this.assertEqual('hello #éà', json.test); 
     372          }.bind(this) 
    373373        })); 
    374374       
    375375        new Ajax.Request("/response", extendDefault({ 
    376376          onComplete: function(transport, json) {  
    377             assertNull(transport.headerJSON) 
    378             assertNull(json) 
    379           } 
    380         })); 
    381       } else { 
    382         info(message); 
    383       } 
    384     }}
    385      
    386     testGetHeader: function() {with(this) { 
    387       if (isRunningFromRake) { 
     377            this.assertNull(transport.headerJSON) 
     378            this.assertNull(json) 
     379          }.bind(this) 
     380        })); 
     381      } else { 
     382        this.info(message); 
     383      } 
     384    }
     385     
     386    testGetHeader: function() { 
     387      if (this.isRunningFromRake) { 
    388388       new Ajax.Request("/response", extendDefault({ 
    389389          parameters: { 'X-TEST': 'some value' }, 
    390390          onComplete: function(transport) { 
    391             assertEqual('some value', transport.getHeader('X-Test')); 
    392             assertNull(transport.getHeader('X-Inexistant')); 
    393           } 
    394         })); 
    395       } else { 
    396         info(message); 
    397       } 
    398     }}
    399      
    400     testParametersCanBeHash: function() {with(this) { 
    401       if (isRunningFromRake) { 
     391            this.assertEqual('some value', transport.getHeader('X-Test')); 
     392            this.assertNull(transport.getHeader('X-Inexistant')); 
     393          }.bind(this) 
     394        })); 
     395      } else { 
     396        this.info(message); 
     397      } 
     398    }
     399     
     400    testParametersCanBeHash: function() { 
     401      if (this.isRunningFromRake) { 
    402402        new Ajax.Request("/response", extendDefault({ 
    403403          parameters: $H({ "one": "two", "three": "four" }), 
    404404          onComplete: function(transport) { 
    405             assertEqual("two", transport.getHeader("one")); 
    406             assertEqual("four", transport.getHeader("three")); 
    407             assertNull(transport.getHeader("toObject")); 
    408           } 
    409         })); 
    410       } else { 
    411         info(message); 
    412       } 
    413     }}
    414      
    415     testIsSameOriginMethod: function() {with(this) { 
     405            this.assertEqual("two", transport.getHeader("one")); 
     406            this.assertEqual("four", transport.getHeader("three")); 
     407            this.assertNull(transport.getHeader("toObject")); 
     408          }.bind(this) 
     409        })); 
     410      } else { 
     411        this.info(message); 
     412      } 
     413    }
     414     
     415    testIsSameOriginMethod: function() { 
    416416      var isSameOrigin = Ajax.Request.prototype.isSameOrigin; 
    417       assert(isSameOrigin.call({ url: '/foo/bar.html' }), '/foo/bar.html'); 
    418       assert(isSameOrigin.call({ url: window.location.toString() }), window.location); 
    419       assert(!isSameOrigin.call({ url: 'http://example.com' }), 'http://example.com'); 
    420  
    421       if (isRunningFromRake) { 
     417      this.assert(isSameOrigin.call({ url: '/foo/bar.html' }), '/foo/bar.html'); 
     418      this.assert(isSameOrigin.call({ url: window.location.toString() }), window.location); 
     419      this.assert(!isSameOrigin.call({ url: 'http://example.com' }), 'http://example.com'); 
     420 
     421      if (this.isRunningFromRake) { 
    422422        Ajax.Request.prototype.isSameOrigin = function() { 
    423423          return false 
     
    428428          parameters: Fixtures.js, 
    429429          onComplete: function(transport) {  
    430             assertEqual("same origin policy", $("content").innerHTML); 
    431           } 
     430            this.assertEqual("same origin policy", $("content").innerHTML); 
     431          }.bind(this) 
    432432        })); 
    433433 
     
    435435          parameters: Fixtures.invalidJson, 
    436436          onException: function(request, error) { 
    437             assert(error.message.include('Badly formed JSON string')); 
    438           } 
     437            this.assert(error.message.include('Badly formed JSON string')); 
     438          }.bind(this) 
    439439        })); 
    440440 
     
    442442          parameters: { 'X-JSON': '{});window.attacked = true;({}' }, 
    443443          onException: function(request, error) { 
    444             assert(error.message.include('Badly formed JSON string')); 
    445           } 
     444            this.assert(error.message.include('Badly formed JSON string')); 
     445          }.bind(this) 
    446446        })); 
    447447 
    448448        Ajax.Request.prototype.isSameOrigin = isSameOrigin; 
    449449      } else { 
    450         info(message); 
    451       } 
    452     }} 
     450        this.info(message); 
     451      } 
     452    } 
    453453  }); 
    454454// ]]> 
  • spinoffs/prototype/trunk/test/unit/array.html

    r8572 r9036  
    3333 
    3434  new Test.Unit.Runner({ 
    35     test$A: function(){ with(this) { 
    36       assertEnumEqual([], $A({})); 
    37     }}
    38      
    39     testToArrayOnArguments: function(){ with(this) { 
     35    test$A: function(){ 
     36      this.assertEnumEqual([], $A({})); 
     37    }
     38     
     39    testToArrayOnArguments: function(){ 
    4040      function toArrayOnArguments(){ 
    4141        globalArgsTest = $A(arguments); 
    4242      } 
    4343      toArrayOnArguments(); 
    44       assertEnumEqual([], globalArgsTest); 
     44      this.assertEnumEqual([], globalArgsTest); 
    4545      toArrayOnArguments('foo'); 
    46       assertEnumEqual(['foo'], globalArgsTest); 
     46      this.assertEnumEqual(['foo'], globalArgsTest); 
    4747      toArrayOnArguments('foo','bar'); 
    48       assertEnumEqual(['foo','bar'], globalArgsTest); 
    49     }}
    50      
    51     testToArrayOnNodeList: function(){ with(this) { 
     48      this.assertEnumEqual(['foo','bar'], globalArgsTest); 
     49    }
     50     
     51    testToArrayOnNodeList: function(){ 
    5252      // direct HTML 
    53       assertEqual(3, $A($('test_node').childNodes).length); 
     53      this.assertEqual(3, $A($('test_node').childNodes).length); 
    5454       
    5555      // DOM 
     
    5757      element.appendChild(document.createTextNode('22')); 
    5858      (2).times(function(){ element.appendChild(document.createElement('span')) }); 
    59       assertEqual(3, $A(element.childNodes).length); 
     59      this.assertEqual(3, $A(element.childNodes).length); 
    6060       
    6161      // HTML String 
    6262      element = document.createElement('div'); 
    6363      $(element).update('22<span></span><span></span'); 
    64       assertEqual(3, $A(element.childNodes).length); 
    65     }}
    66      
    67     testClear: function(){ with(this) { 
    68       assertEnumEqual([], [].clear()); 
    69       assertEnumEqual([], [1].clear()); 
    70       assertEnumEqual([], [1,2].clear()); 
    71     }}
    72      
    73     testClone: function(){ with(this) { 
    74       assertEnumEqual([], [].clone()); 
    75       assertEnumEqual([1], [1].clone()); 
    76       assertEnumEqual([1,2], [1,2].clone()); 
    77       assertEnumEqual([0,1,2], [0,1,2].clone()); 
     64      this.assertEqual(3, $A(element.childNodes).length); 
     65    }
     66     
     67    testClear: function(){ 
     68      this.assertEnumEqual([], [].clear()); 
     69      this.assertEnumEqual([], [1].clear()); 
     70      this.assertEnumEqual([], [1,2].clear()); 
     71    }
     72     
     73    testClone: function(){ 
     74      this.assertEnumEqual([], [].clone()); 
     75      this.assertEnumEqual([1], [1].clone()); 
     76      this.assertEnumEqual([1,2], [1,2].clone()); 
     77      this.assertEnumEqual([0,1,2], [0,1,2].clone()); 
    7878      var a = [0,1,2]; 
    7979      var b = a; 
    80       assertIdentical(a, b); 
     80      this.assertIdentical(a, b); 
    8181      b = a.clone(); 
    82       assertNotIdentical(a, b); 
    83     }}
    84      
    85     testFirst: function(){ with(this) { 
    86       assertUndefined([].first()); 
    87       assertEqual(1, [1].first()); 
    88       assertEqual(1, [1,2].first()); 
    89     }}
    90      
    91     testLast: function(){ with(this) { 
    92       assertUndefined([].last()); 
    93       assertEqual(1, [1].last()); 
    94       assertEqual(2, [1,2].last()); 
    95     }}
    96      
    97     testCompact: function(){ with(this) { 
    98       assertEnumEqual([],      [].compact()); 
    99       assertEnumEqual([1,2,3], [1,2,3].compact()); 
    100       assertEnumEqual([0,1,2,3], [0,null,1,2,undefined,3].compact()); 
    101       assertEnumEqual([1,2,3], [null,1,2,3,null].compact()); 
    102     }}
    103      
    104     testFlatten: function(){ with(this) { 
    105       assertEnumEqual([],      [].flatten()); 
    106       assertEnumEqual([1,2,3], [1,2,3].flatten()); 
    107       assertEnumEqual([1,2,3], [1,[[[2,3]]]].flatten()); 
    108       assertEnumEqual([1,2,3], [[1],[2],[3]].flatten()); 
    109       assertEnumEqual([1,2,3], [[[[[[[1]]]]]],2,3].flatten()); 
    110     }}
    111      
    112     testIndexOf: function(){ with(this) { 
    113       assertEqual(-1, [].indexOf(1)); 
    114       assertEqual(-1, [0].indexOf(1)); 
    115       assertEqual(0, [1].indexOf(1)); 
    116       assertEqual(1, [0,1,2].indexOf(1)); 
    117       assertEqual(0, [1,2,1].indexOf(1)); 
    118       assertEqual(2, [1,2,1].indexOf(1, -1)); 
    119       assertEqual(1, [undefined,null].indexOf(null)); 
    120     }}
    121  
    122     testLastIndexOf: function(){ with(this) { 
    123       assertEqual(-1,[].lastIndexOf(1)); 
    124       assertEqual(-1, [0].lastIndexOf(1)); 
    125       assertEqual(0, [1].lastIndexOf(1)); 
    126       assertEqual(2, [0,2,4,6].lastIndexOf(4)); 
    127       assertEqual(3, [4,4,2,4,6].lastIndexOf(4)); 
    128       assertEqual(3, [0,2,4,6].lastIndexOf(6,3)); 
    129       assertEqual(-1, [0,2,4,6].lastIndexOf(6,2)); 
    130       assertEqual(0, [6,2,4,6].lastIndexOf(6,2)); 
     82      this.assertNotIdentical(a, b); 
     83    }
     84     
     85    testFirst: function(){ 
     86      this.assertUndefined([].first()); 
     87      this.assertEqual(1, [1].first()); 
     88      this.assertEqual(1, [1,2].first()); 
     89    }
     90     
     91    testLast: function(){ 
     92      this.assertUndefined([].last()); 
     93      this.assertEqual(1, [1].last()); 
     94      this.assertEqual(2, [1,2].last()); 
     95    }
     96     
     97    testCompact: function(){ 
     98      this.assertEnumEqual([],      [].compact()); 
     99      this.assertEnumEqual([1,2,3], [1,2,3].compact()); 
     100      this.assertEnumEqual([0,1,2,3], [0,null,1,2,undefined,3].compact()); 
     101      this.assertEnumEqual([1,2,3], [null,1,2,3,null].compact()); 
     102    }
     103     
     104    testFlatten: function(){ 
     105      this.assertEnumEqual([],      [].flatten()); 
     106      this.assertEnumEqual([1,2,3], [1,2,3].flatten()); 
     107      this.assertEnumEqual([1,2,3], [1,[[[2,3]]]].flatten()); 
     108      this.assertEnumEqual([1,2,3], [[1],[2],[3]].flatten()); 
     109      this.assertEnumEqual([1,2,3], [[[[[[[1]]]]]],2,3].flatten()); 
     110    }
     111     
     112    testIndexOf: function(){ 
     113      this.assertEqual(-1, [].indexOf(1)); 
     114      this.assertEqual(-1, [0].indexOf(1)); 
     115      this.assertEqual(0, [1].indexOf(1)); 
     116      this.assertEqual(1, [0,1,2].indexOf(1)); 
     117      this.assertEqual(0, [1,2,1].indexOf(1)); 
     118      this.assertEqual(2, [1,2,1].indexOf(1, -1)); 
     119      this.assertEqual(1, [undefined,null].indexOf(null)); 
     120    }
     121 
     122    testLastIndexOf: function(){ 
     123      this.assertEqual(-1,[].lastIndexOf(1)); 
     124      this.assertEqual(-1, [0].lastIndexOf(1)); 
     125      this.assertEqual(0, [1].lastIndexOf(1)); 
     126      this.assertEqual(2, [0,2,4,6].lastIndexOf(4)); 
     127      this.assertEqual(3, [4,4,2,4,6].lastIndexOf(4)); 
     128      this.assertEqual(3, [0,2,4,6].lastIndexOf(6,3)); 
     129      this.assertEqual(-1, [0,2,4,6].lastIndexOf(6,2)); 
     130      this.assertEqual(0, [6,2,4,6].lastIndexOf(6,2)); 
    131131       
    132132      var fixture = [1,2,3,4,3]; 
    133       assertEqual(4, fixture.lastIndexOf(3)); 
    134       assertEnumEqual([1,2,3,4,3],fixture); 
     133      this.assertEqual(4, fixture.lastIndexOf(3)); 
     134      this.assertEnumEqual([1,2,3,4,3],fixture); 
    135135       
    136136      //tests from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:lastIndexOf 
    137137      var array = [2, 5, 9, 2]; 
    138       assertEqual(3,array.lastIndexOf(2)); 
    139       assertEqual(-1,array.lastIndexOf(7)); 
    140       assertEqual(3,array.lastIndexOf(2,3)); 
    141       assertEqual(0,array.lastIndexOf(2,2)); 
    142       assertEqual(0,array.lastIndexOf(2,-2)); 
    143       assertEqual(3,array.lastIndexOf(2,-1)); 
    144     }}
    145      
    146     testInspect: function(){ with(this) { 
    147       assertEqual('[]',[].inspect()); 
    148       assertEqual('[1]',[1].inspect()); 
    149       assertEqual('[\'a\']',['a'].inspect()); 
    150       assertEqual('[\'a\', 1]',['a',1].inspect()); 
    151     }}
    152      
    153     testIntersect: function(){ with(this) { 
    154       assertEnumEqual([1,3], [1,1,3,5].intersect([1,2,3])); 
    155       assertEnumEqual([1], [1,1].intersect([1,1])); 
    156       assertEnumEqual([], [1,1,3,5].intersect([4])); 
    157       assertEnumEqual([], [1].intersect(['1'])); 
    158        
    159       assertEnumEqual( 
     138      this.assertEqual(3,array.lastIndexOf(2)); 
     139      this.assertEqual(-1,array.lastIndexOf(7)); 
     140      this.assertEqual(3,array.lastIndexOf(2,3)); 
     141      this.assertEqual(0,array.lastIndexOf(2,2)); 
     142      this.assertEqual(0,array.lastIndexOf(2,-2)); 
     143      this.assertEqual(3,array.lastIndexOf(2,-1)); 
     144    }
     145     
     146    testInspect: function(){ 
     147      this.assertEqual('[]',[].inspect()); 
     148      this.assertEqual('[1]',[1].inspect()); 
     149      this.assertEqual('[\'a\']',['a'].inspect()); 
     150      this.assertEqual('[\'a\', 1]',['a',1].inspect()); 
     151    }
     152     
     153    testIntersect: function(){ 
     154      this.assertEnumEqual([1,3], [1,1,3,5].intersect([1,2,3])); 
     155      this.assertEnumEqual([1], [1,1].intersect([1,1])); 
     156      this.assertEnumEqual([], [1,1,3,5].intersect([4])); 
     157      this.assertEnumEqual([], [1].intersect(['1'])); 
     158       
     159      this.assertEnumEqual( 
    160160        ['B','C','D'],  
    161161        $R('A','Z').toArray().intersect($R('B','D').toArray()) 
    162162      ); 
    163     }}
    164      
    165     testToJSON: function(){ with(this) { 
    166       assertEqual('[]', [].toJSON()); 
    167       assertEqual('[\"a\"]', ['a'].toJSON()); 
    168       assertEqual('[\"a\", 1]', ['a', 1].toJSON()); 
    169       assertEqual('[\"a\", {\"b\": null}]', ['a', {'b': null}].toJSON()); 
    170     }}
     163    }
     164     
     165    testToJSON: function(){ 
     166      this.assertEqual('[]', [].toJSON()); 
     167      this.assertEqual('[\"a\"]', ['a'].toJSON()); 
     168      this.assertEqual('[\"a\", 1]', ['a', 1].toJSON()); 
     169      this.assertEqual('[\"a\", {\"b\": null}]', ['a', {'b': null}].toJSON()); 
     170    }
    171171         
    172     testReduce: function(){ with(this) { 
    173       assertUndefined([].reduce()); 
    174       assertNull([null].reduce()); 
    175       assertEqual(1, [1].reduce()); 
    176       assertEnumEqual([1,2,3], [1,2,3].reduce()); 
    177       assertEnumEqual([1,null,3], [1,null,3].reduce()); 
    178     }}
    179      
    180     testReverse: function(){ with(this) { 
    181       assertEnumEqual([], [].reverse()); 
    182       assertEnumEqual([1], [1].reverse()); 
    183       assertEnumEqual([2,1], [1,2].reverse()); 
    184       assertEnumEqual([3,2,1], [1,2,3].reverse()); 
    185     }}
    186      
    187     testSize: function(){ with(this) { 
    188       assertEqual(4, [0, 1, 2, 3].size()); 
    189       assertEqual(0, [].size()); 
    190     }}
    191  
    192     testUniq: function(){ with(this) { 
    193       assertEnumEqual([1], [1, 1, 1].uniq()); 
    194       assertEnumEqual([1], [1].uniq()); 
    195       assertEnumEqual([], [].uniq()); 
    196       assertEnumEqual([0, 1, 2, 3], [0, 1, 2, 2, 3, 0, 2].uniq()); 
    197       assertEnumEqual([0, 1, 2, 3], [0, 0, 1, 1, 2, 3, 3, 3].uniq(true)); 
    198     }}
    199      
    200     testWithout: function(){ with(this) { 
    201       assertEnumEqual([], [].without(0)); 
    202       assertEnumEqual([], [0].without(0)); 
    203       assertEnumEqual([1], [0,1].without(0)); 
    204       assertEnumEqual([1,2], [0,1,2].without(0)); 
    205     }}
    206      
    207     test$w: function(){ with(this) { 
    208       assertEnumEqual(['a', 'b', 'c', 'd'], $w('a b c d')); 
    209       assertEnumEqual([], $w(' ')); 
    210       assertEnumEqual([], $w('')); 
    211       assertEnumEqual([], $w(null)); 
    212       assertEnumEqual([], $w(undefined)); 
    213       assertEnumEqual([], $w()); 
    214       assertEnumEqual([], $w(10)); 
    215       assertEnumEqual(['a'], $w('a')); 
    216       assertEnumEqual(['a'], $w('a ')); 
    217       assertEnumEqual(['a'], $w(' a')); 
    218       assertEnumEqual(['a', 'b', 'c', 'd'], $w(' a   b\nc\t\nd\n')); 
    219     }} 
     172    testReduce: function(){ 
     173      this.assertUndefined([].reduce()); 
     174      this.assertNull([null].reduce()); 
     175      this.assertEqual(1, [1].reduce()); 
     176      this.assertEnumEqual([1,2,3], [1,2,3].reduce()); 
     177      this.assertEnumEqual([1,null,3], [1,null,3].reduce()); 
     178    }
     179     
     180    testReverse: function(){ 
     181      this.assertEnumEqual([], [].reverse()); 
     182      this.assertEnumEqual([1], [1].reverse()); 
     183      this.assertEnumEqual([2,1], [1,2].reverse()); 
     184      this.assertEnumEqual([3,2,1], [1,2,3].reverse()); 
     185    }
     186     
     187    testSize: function(){ 
     188      this.assertEqual(4, [0, 1, 2, 3].size()); 
     189      this.assertEqual(0, [].size()); 
     190    }
     191 
     192    testUniq: function(){ 
     193      this.assertEnumEqual([1], [1, 1, 1].uniq()); 
     194      this.assertEnumEqual([1], [1].uniq()); 
     195      this.assertEnumEqual([], [].uniq()); 
     196      this.assertEnumEqual([0, 1, 2, 3], [0, 1, 2, 2, 3, 0, 2].uniq()); 
     197      this.assertEnumEqual([0, 1, 2, 3], [0, 0, 1, 1, 2, 3, 3, 3].uniq(true)); 
     198    }
     199     
     200    testWithout: function(){ 
     201      this.assertEnumEqual([], [].without(0)); 
     202      this.assertEnumEqual([], [0].without(0)); 
     203      this.assertEnumEqual([1], [0,1].without(0)); 
     204      this.assertEnumEqual([1,2], [0,1,2].without(0)); 
     205    }
     206     
     207    test$w: function(){ 
     208      this.assertEnumEqual(['a', 'b', 'c', 'd'], $w('a b c d')); 
     209      this.assertEnumEqual([], $w(' ')); 
     210      this.assertEnumEqual([], $w('')); 
     211      this.assertEnumEqual([], $w(null)); 
     212      this.assertEnumEqual([], $w(undefined)); 
     213      this.assertEnumEqual([], $w()); 
     214      this.assertEnumEqual([], $w(10)); 
     215      this.assertEnumEqual(['a'], $w('a')); 
     216      this.assertEnumEqual(['a'], $w('a ')); 
     217      this.assertEnumEqual(['a'], $w(' a')); 
     218      this.assertEnumEqual(['a', 'b', 'c', 'd'], $w(' a   b\nc\t\nd\n')); 
     219    } 
    220220 
    221221  }); 
  • spinoffs/prototype/trunk/test/unit/base.html

    r8712 r9036  
    141141  new Test.Unit.Runner({ 
    142142     
    143     testFunctionArgumentNames: function() { with(this) { 
    144       assertEnumEqual([], (function() {}).argumentNames()); 
    145       assertEnumEqual(["one"], (function(one) {}).argumentNames()); 
    146       assertEnumEqual(["one", "two", "three"], (function(one, two, three) {}).argumentNames()); 
    147       assertEqual("$super", (function($super) {}).argumentNames().first()); 
     143    testFunctionArgumentNames: function() { 
     144      this.assertEnumEqual([], (function() {}).argumentNames()); 
     145      this.assertEnumEqual(["one"], (function(one) {}).argumentNames()); 
     146      this.assertEnumEqual(["one", "two", "three"], (function(one, two, three) {}).argumentNames()); 
     147      this.assertEqual("$super", (function($super) {}).argumentNames().first()); 
    148148       
    149149      function named1() {}; 
    150       assertEnumEqual([], named1.argumentNames()); 
     150      this.assertEnumEqual([], named1.argumentNames()); 
    151151      function named2(one) {}; 
    152       assertEnumEqual(["one"], named2.argumentNames()); 
     152      this.assertEnumEqual(["one"], named2.argumentNames()); 
    153153      function named3(one, two, three) {}; 
    154       assertEnumEqual(["one", "two", "three"], named3.argumentNames()); 
    155     }}
    156      
    157     testFunctionBind: function() { with(this) { 
     154      this.assertEnumEqual(["one", "two", "three"], named3.argumentNames()); 
     155    }
     156     
     157    testFunctionBind: function() { 
    158158      function methodWithoutArguments() { return this.hi }; 
    159159      function methodWithArguments()    { return this.hi + ',' + $A(arguments).join(',') }; 
    160160      var func = Prototype.emptyFunction; 
    161161 
    162       assertIdentical(func, func.bind()); 
    163       assertIdentical(func, func.bind(undefined)); 
    164       assertNotIdentical(func, func.bind(null)); 
    165  
    166       assertEqual('without', methodWithoutArguments.bind({ hi: 'without' })()); 
    167       assertEqual('with,arg1,arg2', methodWithArguments.bind({ hi: 'with' })('arg1','arg2')); 
    168       assertEqual('withBindArgs,arg1,arg2', 
     162      this.assertIdentical(func, func.bind()); 
     163      this.assertIdentical(func, func.bind(undefined)); 
     164      this.assertNotIdentical(func, func.bind(null)); 
     165 
     166      this.assertEqual('without', methodWithoutArguments.bind({ hi: 'without' })()); 
     167      this.assertEqual('with,arg1,arg2', methodWithArguments.bind({ hi: 'with' })('arg1','arg2')); 
     168      this.assertEqual('withBindArgs,arg1,arg2', 
    169169        methodWithArguments.bind({ hi: 'withBindArgs' }, 'arg1', 'arg2')()); 
    170       assertEqual('withBindArgsAndArgs,arg1,arg2,arg3,arg4', 
     170      this.assertEqual('withBindArgsAndArgs,arg1,arg2,arg3,arg4', 
    171171        methodWithArguments.bind({ hi: 'withBindArgsAndArgs' }, 'arg1', 'arg2')('arg3', 'arg4')); 
    172     }}
    173      
    174     testFunctionCurry: function() { with(this) { 
     172    }
     173     
     174    testFunctionCurry: function() { 
    175175      var split = function(delimiter, string) { return string.split(delimiter); }; 
    176176      var splitOnColons = split.curry(":"); 
    177       assertNotIdentical(split, splitOnColons); 
    178       assertEnumEqual(split(":", "0:1:2:3:4:5"), splitOnColons("0:1:2:3:4:5")); 
    179       assertIdentical(split, split.curry()); 
    180     }}
    181      
    182     testFunctionDelay: function() { with(this) { 
     177      this.assertNotIdentical(split, splitOnColons); 
     178      this.assertEnumEqual(split(":", "0:1:2:3:4:5"), splitOnColons("0:1:2:3:4:5")); 
     179      this.assertIdentical(split, split.curry()); 
     180    }
     181     
     182    testFunctionDelay: function() { 
    183183      window.delayed = undefined; 
    184184      var delayedFunction = function() { window.delayed = true; }; 
     
    186186      delayedFunction.delay(0.8); 
    187187      delayedFunctionWithArgs.delay(0.8, 'hello', 'world'); 
    188       assertUndefined(window.delayed); 
    189       wait(1000, function() { 
    190         assert(window.delayed); 
    191         assertEqual('hello world', window.delayedWithArgs); 
    192       }); 
    193     }}
    194      
    195     testFunctionWrap: function() { with(this) { 
     188      this.assertUndefined(window.delayed); 
     189      this.wait(1000, function() { 
     190        this.assert(window.delayed); 
     191        this.assertEqual('hello world', window.delayedWithArgs); 
     192      }); 
     193    }
     194     
     195    testFunctionWrap: function() { 
    196196      function sayHello(){ 
    197197        return 'hello world'; 
    198198      }; 
    199199       
    200       assertEqual('HELLO WORLD', sayHello.wrap(function(proceed) { 
     200      this.assertEqual('HELLO WORLD', sayHello.wrap(function(proceed) { 
    201201        return proceed().toUpperCase(); 
    202202      })()); 
     
    209209        return proceed(); 
    210210      }); 
    211       assertEqual('Hello world', 'hello world'.capitalize()); 
    212       assertEqual('Hello World', 'hello world'.capitalize(true)); 
    213       assertEqual('Hello', 'hello'.capitalize()); 
     211      this.assertEqual('Hello world', 'hello world'.capitalize()); 
     212      this.assertEqual('Hello World', 'hello world'.capitalize(true)); 
     213      this.assertEqual('Hello', 'hello'.capitalize()); 
    214214      String.prototype.capitalize = temp; 
    215     }}
    216      
    217     testFunctionDefer: function() { with(this) { 
     215    }
     216     
     217    testFunctionDefer: function() { 
    218218      window.deferred = undefined; 
    219219      var deferredFunction = function() { window.deferred = true; }; 
    220220      deferredFunction.defer(); 
    221       assertUndefined(window.deferred);       
    222       wait(50, function() { 
    223         assert(window.deferred); 
     221      this.assertUndefined(window.deferred);       
     222      this.wait(50, function() { 
     223        this.assert(window.deferred); 
    224224         
    225225        window.deferredValue = 0; 
    226226        var deferredFunction2 = function(arg) { window.deferredValue = arg; }; 
    227227        deferredFunction2.defer('test'); 
    228         wait(50, function() { 
    229           assertEqual('test', window.deferredValue); 
     228        this.wait(50, function() { 
     229          this.assertEqual('test', window.deferredValue); 
    230230        }); 
    231231      }); 
    232     }}
    233      
    234     testFunctionMethodize: function() { with(this) { 
     232    }
     233     
     234    testFunctionMethodize: function() { 
    235235      var Foo = { bar: function(baz) { return baz } }; 
    236236      var baz = { quux: Foo.bar.methodize() }; 
    237237       
    238       assertEqual(Foo.bar.methodize(), baz.quux); 
    239       assertEqual(baz, Foo.bar(baz)); 
    240       assertEqual(baz, baz.quux()); 
    241     }}
    242  
    243     testObjectExtend: function() { with(this) { 
     238      this.assertEqual(Foo.bar.methodize(), baz.quux); 
     239      this.assertEqual(baz, Foo.bar(baz)); 
     240      this.assertEqual(baz, baz.quux()); 
     241    }
     242 
     243    testObjectExtend: function() { 
    244244      var object = {foo: 'foo', bar: [1, 2, 3]}; 
    245       assertIdentical(object, Object.extend(object)); 
    246       assertHashEqual({foo: 'foo', bar: [1, 2, 3]}, object); 
    247       assertIdentical(object, Object.extend(object, {bla: 123})); 
    248       assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: 123}, object); 
    249       assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: null}, 
     245      this.assertIdentical(object, Object.extend(object)); 
     246      this.assertHashEqual({foo: 'foo', bar: [1, 2, 3]}, object); 
     247      this.assertIdentical(object, Object.extend(object, {bla: 123})); 
     248      this.assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: 123}, object); 
     249      this.assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: null}, 
    250250        Object.extend(object, {bla: null})); 
    251     }}
    252      
    253     testObjectToQueryString: function() { with(this) { 
    254       assertEqual('a=A&b=B&c=C&d=D%23', Object.toQueryString({a: 'A', b: 'B', c: 'C', d: 'D#'})); 
    255     }}
    256      
    257     testObjectClone: function() { with(this) { 
     251    }
     252     
     253    testObjectToQueryString: function() { 
     254      this.assertEqual('a=A&b=B&c=C&d=D%23', Object.toQueryString({a: 'A', b: 'B', c: 'C', d: 'D#'})); 
     255    }
     256     
     257    testObjectClone: function() { 
    258258      var object = {foo: 'foo', bar: [1, 2, 3]}; 
    259       assertNotIdentical(object, Object.clone(object)); 
    260       assertHashEqual(object, Object.clone(object)); 
    261       assertHashEqual({}, Object.clone()); 
     259      this.assertNotIdentical(object, Object.clone(object)); 
     260      this.assertHashEqual(object, Object.clone(object)); 
     261      this.assertHashEqual({}, Object.clone()); 
    262262      var clone = Object.clone(object); 
    263263      delete clone.bar; 
    264       assertHashEqual({foo: 'foo'}, clone,  
     264      this.assertHashEqual({foo: 'foo'}, clone,  
    265265        "Optimizing Object.clone perf using prototyping doesn't allow properties to be deleted."); 
    266     }}
    267  
    268     testObjectInspect: function() { with(this) { 
    269       assertEqual('undefined', Object.inspect()); 
    270       assertEqual('undefined', Object.inspect(undefined)); 
    271       assertEqual('null', Object.inspect(null)); 
    272       assertEqual("'foo\\\\b\\\'ar'", Object.inspect('foo\\b\'ar')); 
    273       assertEqual('[]', Object.inspect([])); 
    274       assertNothingRaised(function() { Object.inspect(window.Node) }); 
    275     }}
    276      
    277     testObjectToJSON: function() { with(this) { 
    278       assertUndefined(Object.toJSON(undefined)); 
    279       assertUndefined(Object.toJSON(Prototype.K)); 
    280       assertEqual('\"\"', Object.toJSON('')); 
    281       assertEqual('[]', Object.toJSON([])); 
    282       assertEqual('[\"a\"]', Object.toJSON(['a'])); 
    283       assertEqual('[\"a\", 1]', Object.toJSON(['a', 1])); 
    284       assertEqual('[\"a\", {\"b\": null}]', Object.toJSON(['a', {'b': null}])); 
    285       assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'})); 
    286       assertEqual('{}', Object.toJSON({})); 
    287       assertEqual('{}', Object.toJSON({a: undefined, b: undefined, c: Prototype.K})); 
    288       assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
     266    }
     267 
     268    testObjectInspect: function() { 
     269      this.assertEqual('undefined', Object.inspect()); 
     270      this.assertEqual('undefined', Object.inspect(undefined)); 
     271      this.assertEqual('null', Object.inspect(null)); 
     272      this.assertEqual("'foo\\\\b\\\'ar'", Object.inspect('foo\\b\'ar')); 
     273      this.assertEqual('[]', Object.inspect([])); 
     274      this.assertNothingRaised(function() { Object.inspect(window.Node) }); 
     275    }
     276     
     277    testObjectToJSON: function() { 
     278      this.assertUndefined(Object.toJSON(undefined)); 
     279      this.assertUndefined(Object.toJSON(Prototype.K)); 
     280      this.assertEqual('\"\"', Object.toJSON('')); 
     281      this.assertEqual('[]', Object.toJSON([])); 
     282      this.assertEqual('[\"a\"]', Object.toJSON(['a'])); 
     283      this.assertEqual('[\"a\", 1]', Object.toJSON(['a', 1])); 
     284      this.assertEqual('[\"a\", {\"b\": null}]', Object.toJSON(['a', {'b': null}])); 
     285      this.assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'})); 
     286      this.assertEqual('{}', Object.toJSON({})); 
     287      this.assertEqual('{}', Object.toJSON({a: undefined, b: undefined, c: Prototype.K})); 
     288      this.assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    289289        Object.toJSON({'b': [undefined, false, true, undefined], c: {a: 'hello!'}})); 
    290       assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
     290      this.assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    291291        Object.toJSON($H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}))); 
    292       assertEqual('true', Object.toJSON(true)); 
    293       assertEqual('false', Object.toJSON(false)); 
    294       assertEqual('null', Object.toJSON(null)); 
     292      this.assertEqual('true', Object.toJSON(true)); 
     293      this.assertEqual('false', Object.toJSON(false)); 
     294      this.assertEqual('null', Object.toJSON(null)); 
    295295      var sam = new Person('sam'); 
    296       assertEqual('-sam', Object.toJSON(sam)); 
    297       assertEqual('-sam', sam.toJSON()); 
     296      this.assertEqual('-sam', Object.toJSON(sam)); 
     297      this.assertEqual('-sam', sam.toJSON()); 
    298298      var element = $('test'); 
    299       assertUndefined(Object.toJSON(element)); 
     299      this.assertUndefined(Object.toJSON(element)); 
    300300      element.toJSON = function(){return 'I\'m a div with id test'}; 
    301       assertEqual('I\'m a div with id test', Object.toJSON(element)); 
    302     }}
    303      
    304     testObjectToHTML: function() { with(this) { 
    305       assertIdentical('', Object.toHTML()); 
    306       assertIdentical('', Object.toHTML('')); 
    307       assertIdentical('', Object.toHTML(null)); 
    308       assertIdentical('0', Object.toHTML(0)); 
    309       assertIdentical('123', Object.toHTML(123)); 
    310       assertEqual('hello world', Object.toHTML('hello world')); 
    311       assertEqual('hello world', Object.toHTML({toHTML: function() { return 'hello world' }})); 
    312     }}
    313      
    314     testObjectIsArray: function() { with(this) { 
    315       assert(Object.isArray([])); 
    316       assert(Object.isArray([0])); 
    317       assert(Object.isArray([0, 1])); 
    318       assert(!Object.isArray({})); 
    319       assert(!Object.isArray($('list').childNodes)); 
    320       assert(!Object.isArray()); 
    321       assert(!Object.isArray('')); 
    322       assert(!Object.isArray('foo')); 
    323       assert(!Object.isArray(0)); 
    324       assert(!Object.isArray(1)); 
    325       assert(!Object.isArray(null)); 
    326       assert(!Object.isArray(true)); 
    327       assert(!Object.isArray(false)); 
    328       assert(!Object.isArray(undefined)); 
    329     }}
    330      
    331     testObjectIsHash: function() { with(this) { 
    332       assert(Object.isHash($H())); 
    333       assert(Object.isHash(new Hash())); 
    334       assert(!Object.isHash({})); 
    335     }}
    336      
    337     testObjectIsElement: function() { with(this) { 
    338       assert(Object.isElement(document.createElement('div'))); 
    339       assert(Object.isElement(new Element('div'))); 
    340       assert(Object.isElement($('testlog'))); 
    341       assert(!Object.isElement(document.createTextNode('bla'))); 
    342     }}
    343      
    344     testObjectIsFunction: function() { with(this) { 
    345       assert(Object.isFunction(function() { })); 
    346       assert(Object.isFunction(Class.create())); 
    347       assert(!Object.isFunction("a string")); 
    348       assert(!Object.isFunction($("testlog"))); 
    349       assert(!Object.isFunction([])); 
    350       assert(!Object.isFunction({})); 
    351       assert(!Object.isFunction(0)); 
    352       assert(!Object.isFunction(false)); 
    353       assert(!Object.isFunction(undefined)); 
    354     }}
    355      
    356     testObjectIsString: function() { with(this) { 
    357       assert(!Object.isString(function() { })); 
    358       assert(Object.isString("a string")); 
    359       assert(!Object.isString(0)); 
    360       assert(!Object.isString([])); 
    361       assert(!Object.isString({})); 
    362       assert(!Object.isString(false)); 
    363       assert(!Object.isString(undefined)); 
    364     }}
    365      
    366     testObjectIsNumber: function() { with(this) { 
    367       assert(Object.isNumber(0)); 
    368       assert(Object.isNumber(1.0)); 
    369       assert(!Object.isNumber(function() { })); 
    370       assert(!Object.isNumber("a string")); 
    371       assert(!Object.isNumber([])); 
    372       assert(!Object.isNumber({})); 
    373       assert(!Object.isNumber(false)); 
    374       assert(!Object.isNumber(undefined)); 
    375     }}
    376      
    377     testObjectIsUndefined: function() { with(this) { 
    378       assert(Object.isUndefined(undefined)); 
    379       assert(!Object.isUndefined(null)); 
    380       assert(!Object.isUndefined(false)); 
    381       assert(!Object.isUndefined(0)); 
    382       assert(!Object.isUndefined("")); 
    383       assert(!Object.isUndefined(function() { })); 
    384       assert(!Object.isUndefined([])); 
    385       assert(!Object.isUndefined({})); 
    386     }}
     301      this.assertEqual('I\'m a div with id test', Object.toJSON(element)); 
     302    }
     303     
     304    testObjectToHTML: function() { 
     305      this.assertIdentical('', Object.toHTML()); 
     306      this.assertIdentical('', Object.toHTML('')); 
     307      this.assertIdentical('', Object.toHTML(null)); 
     308      this.assertIdentical('0', Object.toHTML(0)); 
     309      this.assertIdentical('123', Object.toHTML(123)); 
     310      this.assertEqual('hello world', Object.toHTML('hello world')); 
     311      this.assertEqual('hello world', Object.toHTML({toHTML: function() { return 'hello world' }})); 
     312    }
     313     
     314    testObjectIsArray: function() { 
     315      this.assert(Object.isArray([])); 
     316      this.assert(Object.isArray([0])); 
     317      this.assert(Object.isArray([0, 1])); 
     318      this.assert(!Object.isArray({})); 
     319      this.assert(!Object.isArray($('list').childNodes)); 
     320      this.assert(!Object.isArray()); 
     321      this.assert(!Object.isArray('')); 
     322      this.assert(!Object.isArray('foo')); 
     323      this.assert(!Object.isArray(0)); 
     324      this.assert(!Object.isArray(1)); 
     325      this.assert(!Object.isArray(null)); 
     326      this.assert(!Object.isArray(true)); 
     327      this.assert(!Object.isArray(false)); 
     328      this.assert(!Object.isArray(undefined)); 
     329    }
     330     
     331    testObjectIsHash: function() { 
     332      this.assert(Object.isHash($H())); 
     333      this.assert(Object.isHash(new Hash())); 
     334      this.assert(!Object.isHash({})); 
     335    }
     336     
     337    testObjectIsElement: function() { 
     338      this.assert(Object.isElement(document.createElement('div'))); 
     339      this.assert(Object.isElement(new Element('div'))); 
     340      this.assert(Object.isElement($('testlog'))); 
     341      this.assert(!Object.isElement(document.createTextNode('bla'))); 
     342    }
     343     
     344    testObjectIsFunction: function() { 
     345      this.assert(Object.isFunction(function() { })); 
     346      this.assert(Object.isFunction(Class.create())); 
     347      this.assert(!Object.isFunction("a string")); 
     348      this.assert(!Object.isFunction($("testlog"))); 
     349      this.assert(!Object.isFunction([])); 
     350      this.assert(!Object.isFunction({})); 
     351      this.assert(!Object.isFunction(0)); 
     352      this.assert(!Object.isFunction(false)); 
     353      this.assert(!Object.isFunction(undefined)); 
     354    }
     355     
     356    testObjectIsString: function() { 
     357      this.assert(!Object.isString(function() { })); 
     358      this.assert(Object.isString("a string")); 
     359      this.assert(!Object.isString(0)); 
     360      this.assert(!Object.isString([])); 
     361      this.assert(!Object.isString({})); 
     362      this.assert(!Object.isString(false)); 
     363      this.assert(!Object.isString(undefined)); 
     364    }
     365     
     366    testObjectIsNumber: function() { 
     367      this.assert(Object.isNumber(0)); 
     368      this.assert(Object.isNumber(1.0)); 
     369      this.assert(!Object.isNumber(function() { })); 
     370      this.assert(!Object.isNumber("a string")); 
     371      this.assert(!Object.isNumber([])); 
     372      this.assert(!Object.isNumber({})); 
     373      this.assert(!Object.isNumber(false)); 
     374      this.assert(!Object.isNumber(undefined)); 
     375    }
     376     
     377    testObjectIsUndefined: function() { 
     378      this.assert(Object.isUndefined(undefined)); 
     379      this.assert(!Object.isUndefined(null)); 
     380      this.assert(!Object.isUndefined(false)); 
     381      this.assert(!Object.isUndefined(0)); 
     382      this.assert(!Object.isUndefined("")); 
     383      this.assert(!Object.isUndefined(function() { })); 
     384      this.assert(!Object.isUndefined([])); 
     385      this.assert(!Object.isUndefined({})); 
     386    }
    387387     
    388388    // sanity check 
    389     testDoesntExtendObjectPrototype: function() {with(this) { 
     389    testDoesntExtendObjectPrototype: function() { 
    390390      // for-in is supported with objects 
    391391      var iterations = 0, obj = { a: 1, b: 2, c: 3 }; 
    392392      for(property in obj) iterations++; 
    393       assertEqual(3, iterations); 
     393      this.assertEqual(3, iterations); 
    394394       
    395395      // for-in is not supported with arrays 
     
    397397      var arr = [1,2,3]; 
    398398      for(property in arr) iterations++; 
    399       assert(iterations > 3); 
    400     }}
    401      
    402     testPeriodicalExecuterStop: function() {with(this) { 
     399      this.assert(iterations > 3); 
     400    }
     401     
     402    testPeriodicalExecuterStop: function() { 
    403403      var peEventCount = 0; 
    404404      function peEventFired(pe) { 
     
    409409      new PeriodicalExecuter(peEventFired, 0.05); 
    410410       
    411       wait(600, function() { 
    412         assertEqual(3, peEventCount); 
    413       }); 
    414     }}
     411      this.wait(600, function() { 
     412        this.assertEqual(3, peEventCount); 
     413      }); 
     414    }
    415415 
    416416    testBindAsEventListener: function() { 
     
    430430    }, 
    431431     
    432     testDateToJSON: function() {with(this) { 
    433       assertEqual('\"1970-01-01T00:00:00Z\"', new Date(Date.UTC(1970, 0, 1)).toJSON()); 
    434     }}
    435      
    436     testRegExpEscape: function() {with(this) { 
    437       assertEqual('word', RegExp.escape('word')); 
    438       assertEqual('\\/slashes\\/', RegExp.escape('/slashes/')); 
    439       assertEqual('\\\\backslashes\\\\', RegExp.escape('\\backslashes\\')); 
    440       assertEqual('\\\\border of word', RegExp.escape('\\border of word')); 
    441        
    442       assertEqual('\\(\\?\\:non-capturing\\)', RegExp.escape('(?:non-capturing)')); 
    443       assertEqual('non-capturing', new RegExp(RegExp.escape('(?:') + '([^)]+)').exec('(?:non-capturing)')[1]); 
    444        
    445       assertEqual('\\(\\?\\=positive-lookahead\\)', RegExp.escape('(?=positive-lookahead)')); 
    446       assertEqual('positive-lookahead', new RegExp(RegExp.escape('(?=') + '([^)]+)').exec('(?=positive-lookahead)')[1]); 
    447        
    448       assertEqual('\\(\\?<\\=positive-lookbehind\\)', RegExp.escape('(?<=positive-lookbehind)')); 
    449       assertEqual('positive-lookbehind', new RegExp(RegExp.escape('(?<=') + '([^)]+)').exec('(?<=positive-lookbehind)')[1]); 
    450        
    451       assertEqual('\\(\\?\\!negative-lookahead\\)', RegExp.escape('(?!negative-lookahead)')); 
    452       assertEqual('negative-lookahead', new RegExp(RegExp.escape('(?!') + '([^)]+)').exec('(?!negative-lookahead)')[1]); 
    453        
    454       assertEqual('\\(\\?<\\!negative-lookbehind\\)', RegExp.escape('(?<!negative-lookbehind)')); 
    455       assertEqual('negative-lookbehind', new RegExp(RegExp.escape('(?<!') + '([^)]+)').exec('(?<!negative-lookbehind)')[1]); 
    456        
    457       assertEqual('\\[\\\\w\\]\\+', RegExp.escape('[\\w]+')); 
    458       assertEqual('character class', new RegExp(RegExp.escape('[') + '([^\\]]+)').exec('[character class]')[1]);       
    459        
    460       assertEqual('<div>', new RegExp(RegExp.escape('<div>')).exec('<td><div></td>')[0]);       
    461        
    462       assertEqual('false', RegExp.escape(false)); 
    463       assertEqual('undefined', RegExp.escape()); 
    464       assertEqual('null', RegExp.escape(null)); 
    465       assertEqual('42', RegExp.escape(42)); 
    466        
    467       assertEqual('\\\\n\\\\r\\\\t', RegExp.escape('\\n\\r\\t')); 
    468       assertEqual('\n\r\t', RegExp.escape('\n\r\t')); 
    469       assertEqual('\\{5,2\\}', RegExp.escape('{5,2}')); 
    470        
    471       assertEqual( 
     432    testDateToJSON: function() { 
     433      this.assertEqual('\"1970-01-01T00:00:00Z\"', new Date(Date.UTC(1970, 0, 1)).toJSON()); 
     434    }
     435     
     436    testRegExpEscape: function() { 
     437      this.assertEqual('word', RegExp.escape('word')); 
     438      this.assertEqual('\\/slashes\\/', RegExp.escape('/slashes/')); 
     439      this.assertEqual('\\\\backslashes\\\\', RegExp.escape('\\backslashes\\')); 
     440      this.assertEqual('\\\\border of word', RegExp.escape('\\border of word')); 
     441       
     442      this.assertEqual('\\(\\?\\:non-capturing\\)', RegExp.escape('(?:non-capturing)')); 
     443      this.assertEqual('non-capturing', new RegExp(RegExp.escape('(?:') + '([^)]+)').exec('(?:non-capturing)')[1]); 
     444       
     445      this.assertEqual('\\(\\?\\=positive-lookahead\\)', RegExp.escape('(?=positive-lookahead)')); 
     446      this.assertEqual('positive-lookahead', new RegExp(RegExp.escape('(?=') + '([^)]+)').exec('(?=positive-lookahead)')[1]); 
     447       
     448      this.assertEqual('\\(\\?<\\=positive-lookbehind\\)', RegExp.escape('(?<=positive-lookbehind)')); 
     449      this.assertEqual('positive-lookbehind', new RegExp(RegExp.escape('(?<=') + '([^)]+)').exec('(?<=positive-lookbehind)')[1]); 
     450       
     451      this.assertEqual('\\(\\?\\!negative-lookahead\\)', RegExp.escape('(?!negative-lookahead)')); 
     452      this.assertEqual('negative-lookahead', new RegExp(RegExp.escape('(?!') + '([^)]+)').exec('(?!negative-lookahead)')[1]); 
     453       
     454      this.assertEqual('\\(\\?<\\!negative-lookbehind\\)', RegExp.escape('(?<!negative-lookbehind)')); 
     455      this.assertEqual('negative-lookbehind', new RegExp(RegExp.escape('(?<!') + '([^)]+)').exec('(?<!negative-lookbehind)')[1]); 
     456       
     457      this.assertEqual('\\[\\\\w\\]\\+', RegExp.escape('[\\w]+')); 
     458      this.assertEqual('character class', new RegExp(RegExp.escape('[') + '([^\\]]+)').exec('[character class]')[1]);       
     459       
     460      this.assertEqual('<div>', new RegExp(RegExp.escape('<div>')).exec('<td><div></td>')[0]);       
     461       
     462      this.assertEqual('false', RegExp.escape(false)); 
     463      this.assertEqual('undefined', RegExp.escape()); 
     464      this.assertEqual('null', RegExp.escape(null)); 
     465      this.assertEqual('42', RegExp.escape(42)); 
     466       
     467      this.assertEqual('\\\\n\\\\r\\\\t', RegExp.escape('\\n\\r\\t')); 
     468      this.assertEqual('\n\r\t', RegExp.escape('\n\r\t')); 
     469      this.assertEqual('\\{5,2\\}', RegExp.escape('{5,2}')); 
     470       
     471      this.assertEqual( 
    472472        '\\/\\(\\[\\.\\*\\+\\?\\^\\=\\!\\:\\$\\{\\}\\(\\)\\|\\[\\\\\\]\\\\\\\/\\\\\\\\\\]\\)\\/g', 
    473473        RegExp.escape('/([.*+?^=!:${}()|[\\]\\/\\\\])/g') 
    474474      ); 
    475     }}
    476      
    477     testBrowserDetection: function() {with(this) { 
     475    }
     476     
     477    testBrowserDetection: function() { 
    478478      var results = $H(Prototype.Browser).map(function(engine){ 
    479479        return engine; 
     
    483483      var trues = results[0], falses = results[1]; 
    484484       
    485       info('User agent string is: ' + navigator.userAgent); 
    486        
    487       assert(trues.size() == 0 || trues.size() == 1,  
     485      this.info('User agent string is: ' + navigator.userAgent); 
     486       
     487      this.assert(trues.size() == 0 || trues.size() == 1,  
    488488        'There should be only one or no browser detected.'); 
    489489       
    490490      // we should have definite trues or falses here 
    491       trues.each(function(result)
    492         assert(result[1] === true); 
    493       }); 
    494       falses.each(function(result)
    495         assert(result[1] === false); 
    496       }); 
     491      trues.each(function(result)
     492        this.assert(result[1] === true); 
     493      }, this); 
     494      falses.each(function(result)
     495        this.assert(result[1] === false); 
     496      }, this); 
    497497       
    498498      if(navigator.userAgent.indexOf('AppleWebKit/') > -1) { 
    499         info('Running on WebKit'); 
    500         assert(Prototype.Browser.WebKit); 
     499        this.info('Running on WebKit'); 
     500        this.assert(Prototype.Browser.WebKit); 
    501501      } 
    502502       
    503503      if(!!window.opera) { 
    504         info('Running on Opera'); 
    505         assert(Prototype.Browser.Opera); 
     504        this.info('Running on Opera'); 
     505        this.assert(Prototype.Browser.Opera); 
    506506      } 
    507507       
    508508      if(!!(window.attachEvent && !window.opera)) { 
    509         info('Running on IE'); 
    510         assert(Prototype.Browser.IE); 
     509        this.info('Running on IE'); 
     510        this.assert(Prototype.Browser.IE); 
    511511      } 
    512512       
    513513      if(navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1) { 
    514         info('Running on Gecko'); 
    515         assert(Prototype.Browser.Gecko); 
     514        this.info('Running on Gecko'); 
     515        this.assert(Prototype.Browser.Gecko); 
    516516      }  
    517     }}
    518      
    519     testClassCreate: function() { with(this) {  
    520       assert(Object.isFunction(Animal), 'Animal is not a constructor'); 
    521       assertEnumEqual([Cat, Mouse, Dog, Ox], Animal.subclasses); 
     517    }
     518     
     519    testClassCreate: function() {  
     520      this.assert(Object.isFunction(Animal), 'Animal is not a constructor'); 
     521      this.assertEnumEqual([Cat, Mouse, Dog, Ox], Animal.subclasses); 
    522522      Animal.subclasses.each(function(subclass) { 
    523         assertEqual(Animal, subclass.superclass); 
    524       }); 
     523        this.assertEqual(Animal, subclass.superclass); 
     524      }, this); 
    525525 
    526526      var Bird = Class.create(Animal); 
    527       assertEqual(Bird, Animal.subclasses.last()); 
     527      this.assertEqual(Bird, Animal.subclasses.last()); 
    528528      // for..in loop (for some reason) doesn't iterate over the constructor property in top-level classes 
    529       assertEnumEqual(Object.keys(new Animal).sort(), Object.keys(new Bird).without('constructor').sort()); 
    530     }}
    531  
    532     testClassInstantiation: function() { with(this) {  
     529      this.assertEnumEqual(Object.keys(new Animal).sort(), Object.keys(new Bird).without('constructor').sort()); 
     530    }
     531 
     532    testClassInstantiation: function() {  
    533533      var pet = new Animal("Nibbles"); 
    534       assertEqual("Nibbles", pet.name, "property not initialized"); 
    535       assertEqual('Nibbles: Hi!', pet.say('Hi!')); 
    536       assertEqual(Animal, pet.constructor, "bad constructor reference"); 
    537       assertUndefined(pet.superclass); 
     534      this.assertEqual("Nibbles", pet.name, "property not initialized"); 
     535      this.assertEqual('Nibbles: Hi!', pet.say('Hi!')); 
     536      this.assertEqual(Animal, pet.constructor, "bad constructor reference"); 
     537      this.assertUndefined(pet.superclass); 
    538538 
    539539      var Empty = Class.create(); 
    540       assert('object', typeof new Empty); 
    541     }}
    542  
    543     testInheritance: function() { with(this) { 
     540      this.assert('object', typeof new Empty); 
     541    }
     542 
     543    testInheritance: function() { 
    544544      var tom = new Cat('Tom'); 
    545       assertEqual(Cat, tom.constructor, "bad constructor reference"); 
    546       assertEqual(Animal, tom.constructor.superclass, 'bad superclass reference'); 
    547       assertEqual('Tom', tom.name); 
    548       assertEqual('Tom: meow', tom.say('meow')); 
    549       assertEqual('Tom: Yuk! I only eat mice.', tom.eat(new Animal)); 
    550     }}
    551  
    552     testSuperclassMethodCall: function() { with(this) { 
     545      this.assertEqual(Cat, tom.constructor, "bad constructor reference"); 
     546      this.assertEqual(Animal, tom.constructor.superclass, 'bad superclass reference'); 
     547      this.assertEqual('Tom', tom.name); 
     548      this.assertEqual('Tom: meow', tom.say('meow')); 
     549      this.assertEqual('Tom: Yuk! I only eat mice.', tom.eat(new Animal)); 
     550    }
     551 
     552    testSuperclassMethodCall: function() { 
    553553      var tom = new Cat('Tom'); 
    554       assertEqual('Tom: Yum!', tom.eat(new Mouse)); 
     554      this.assertEqual('Tom: Yum!', tom.eat(new Mouse)); 
    555555 
    556556      // augment the constructor and test 
     
    567567 
    568568      var gonzo = new Dodo('Gonzo'); 
    569       assertEqual('Gonzo', gonzo.name); 
    570       assert(gonzo.extinct, 'Dodo birds should be extinct'); 
    571       assertEqual("Gonzo: hello honk honk", gonzo.say("hello")); 
    572     }}
    573  
    574     testClassAddMethods: function() { with(this) { 
     569      this.assertEqual('Gonzo', gonzo.name); 
     570      this.assert(gonzo.extinct, 'Dodo birds should be extinct'); 
     571      this.assertEqual("Gonzo: hello honk honk", gonzo.say("hello")); 
     572    }
     573 
     574    testClassAddMethods: function() { 
    575575      var tom   = new Cat('Tom'); 
    576576      var jerry = new Mouse('Jerry'); 
     
    591591      }); 
    592592       
    593       assertEqual('Tom: ZZZ', tom.sleep(), "added instance method not available to subclass"); 
    594       assertEqual("Jerry: ZZZ ... no, can't sleep! Gotta steal cheese!", jerry.sleep()); 
    595       assertEqual("Jerry: (from a mousehole) Take that, Tom!", jerry.escape(tom)); 
     593      this.assertEqual('Tom: ZZZ', tom.sleep(), "added instance method not available to subclass"); 
     594      this.assertEqual("Jerry: ZZZ ... no, can't sleep! Gotta steal cheese!", jerry.sleep()); 
     595      this.assertEqual("Jerry: (from a mousehole) Take that, Tom!", jerry.escape(tom)); 
    596596      // insure that a method has not propagated *up* the prototype chain: 
    597       assertUndefined(tom.escape); 
    598       assertUndefined(new Animal().escape); 
     597      this.assertUndefined(tom.escape); 
     598      this.assertUndefined(new Animal().escape); 
    599599       
    600600      Animal.addMethods({ 
     
    604604      }); 
    605605       
    606       assertEqual("Jerry: zZzZ ... no, can't sleep! Gotta steal cheese!", jerry.sleep()); 
    607     }}
    608      
    609     testBaseClassWithMixin: function() { with(this) { 
     606      this.assertEqual("Jerry: zZzZ ... no, can't sleep! Gotta steal cheese!", jerry.sleep()); 
     607    }
     608     
     609    testBaseClassWithMixin: function() { 
    610610      var grass = new Plant('grass', 3); 
    611       assertRespondsTo('getValue', grass);       
    612       assertEqual('#<Plant: grass>', grass.inspect()); 
    613     }}
    614      
    615     testSubclassWithMixin: function() { with(this) { 
     611      this.assertRespondsTo('getValue', grass);       
     612      this.assertEqual('#<Plant: grass>', grass.inspect()); 
     613    }
     614     
     615    testSubclassWithMixin: function() { 
    616616      var snoopy = new Dog('Snoopy', 12, 'male'); 
    617       assertRespondsTo('reproduce', snoopy);       
    618    }}, 
     617      this.assertRespondsTo('reproduce', snoopy);       
     618    }, 
    619619    
    620    testSubclassWithMixins: function() { with(this) { 
     620    testSubclassWithMixins: function() { 
    621621      var cow = new Ox('cow', 400, 'female'); 
    622       assertEqual('#<Ox: cow>', cow.inspect()); 
    623       assertRespondsTo('reproduce', cow); 
    624       assertRespondsTo('getValue', cow); 
    625    }}, 
     622      this.assertEqual('#<Ox: cow>', cow.inspect()); 
     623      this.assertRespondsTo('reproduce', cow); 
     624      this.assertRespondsTo('getValue', cow); 
     625    }, 
    626626    
    627    testClassWithToStringAndValueOfMethods: function() { with(this) { 
    628      var Foo = Class.create({ 
    629        toString: function() { 
    630          return "toString"; 
    631        }, 
    632         
    633        valueOf: function() { 
    634          return "valueOf"; 
    635        } 
    636      }); 
    637       
    638      assertEqual("toString", new Foo().toString()); 
    639      assertEqual("valueOf", new Foo().valueOf()); 
    640    }} 
    641  
     627    testClassWithToStringAndValueOfMethods: function() { 
     628      var Foo = Class.create({ 
     629        toString: function() { return "toString" }, 
     630        valueOf: function() { return "valueOf" } 
     631      }); 
     632       
     633      this.assertEqual("toString", new Foo().toString()); 
     634      this.assertEqual("valueOf", new Foo().valueOf()); 
     635    } 
    642636  }); 
    643637 
  • spinoffs/prototype/trunk/test/unit/dom.html

    r9001 r9036  
    448448      this.properties.each(function(prop) { 
    449449        if (eval(prop)) props[prop] = eval(prop); 
    450       }); 
     450      }, this); 
    451451      return props; 
    452452    } 
     
    455455  new Test.Unit.Runner({ 
    456456 
    457     testDollarFunction: function() { with(this) { 
    458       assertUndefined($()); 
    459        
    460       assertNull(document.getElementById('noWayThisIDExists')); 
    461       assertNull($('noWayThisIDExists')); 
    462        
    463       assertIdentical(document.getElementById('testdiv'), $('testdiv')); 
    464       assertEnumEqual([ $('testdiv'), $('container') ], $('testdiv', 'container')); 
    465       assertEnumEqual([ $('testdiv'), undefined, $('container') ], 
     457    testDollarFunction: function() { 
     458      this.assertUndefined($()); 
     459       
     460      this.assertNull(document.getElementById('noWayThisIDExists')); 
     461      this.assertNull($('noWayThisIDExists')); 
     462       
     463      this.assertIdentical(document.getElementById('testdiv'), $('testdiv')); 
     464      this.assertEnumEqual([ $('testdiv'), $('container') ], $('testdiv', 'container')); 
     465      this.assertEnumEqual([ $('testdiv'), undefined, $('container') ], 
    466466        $('testdiv', 'noWayThisIDExists', 'container')); 
    467467      var elt = $('testdiv'); 
    468       assertIdentical(elt, $(elt)); 
    469       assertRespondsTo('hide', elt); 
    470       assertRespondsTo('childOf', elt); 
    471     }}
    472      
    473     testGetElementsByClassName: function() {with(this) { 
     468      this.assertIdentical(elt, $(elt)); 
     469      this.assertRespondsTo('hide', elt); 
     470      this.assertRespondsTo('childOf', elt); 
     471    }
     472     
     473    testGetElementsByClassName: function() { 
    474474      if (document.getElementsByClassName.toString().include('[native code]')) { 
    475         info("browser uses native getElementsByClassName; skipping tests"); 
     475        this.info("browser uses native getElementsByClassName; skipping tests"); 
    476476        return; 
    477477      }  
     
    480480      var div = $('class_names'), list = $('class_names_ul'); 
    481481       
    482       assertElementsMatch(document.getElementsByClassName('A'), 'p.A', 'ul#class_names_ul.A', 'li.A.C'); 
     482      this.assertElementsMatch(document.getElementsByClassName('A'), 'p.A', 'ul#class_names_ul.A', 'li.A.C'); 
    483483       
    484484      if (Prototype.Browser.IE) 
    485         assertUndefined(document.getElementById('unextended').show); 
    486        
    487       assertElementsMatch(div.getElementsByClassName('B'), 'ul#class_names_ul.A.B', 'div.B.C.D'); 
    488       assertElementsMatch(div.getElementsByClassName('D C B'), 'div.B.C.D'); 
    489       assertElementsMatch(div.getElementsByClassName(' D\nC\tB '), 'div.B.C.D'); 
    490       assertElementsMatch(div.getElementsByClassName($w('D C B'))); 
    491       assertElementsMatch(list.getElementsByClassName('A'), 'li.A.C'); 
    492       assertElementsMatch(list.getElementsByClassName(' A '), 'li.A.C'); 
    493       assertElementsMatch(list.getElementsByClassName('C A'), 'li.A.C'); 
    494       assertElementsMatch(list.getElementsByClassName("C\nA "), 'li.A.C'); 
    495       assertElementsMatch(list.getElementsByClassName('B')); 
    496       assertElementsMatch(list.getElementsByClassName('1'), 'li.1'); 
    497       assertElementsMatch(list.getElementsByClassName([1]), 'li.1'); 
    498       assertElementsMatch(list.getElementsByClassName(['1 junk'])); 
    499       assertElementsMatch(list.getElementsByClassName('')); 
    500       assertElementsMatch(list.getElementsByClassName(' ')); 
    501       assertElementsMatch(list.getElementsByClassName([''])); 
    502       assertElementsMatch(list.getElementsByClassName([' ', ''])); 
    503       assertElementsMatch(list.getElementsByClassName({})); 
     485        this.assertUndefined(document.getElementById('unextended').show); 
     486       
     487      this.assertElementsMatch(div.getElementsByClassName('B'), 'ul#class_names_ul.A.B', 'div.B.C.D'); 
     488      this.assertElementsMatch(div.getElementsByClassName('D C B'), 'div.B.C.D'); 
     489      this.assertElementsMatch(div.getElementsByClassName(' D\nC\tB '), 'div.B.C.D'); 
     490      this.assertElementsMatch(div.getElementsByClassName($w('D C B'))); 
     491      this.assertElementsMatch(list.getElementsByClassName('A'), 'li.A.C'); 
     492      this.assertElementsMatch(list.getElementsByClassName(' A '), 'li.A.C'); 
     493      this.assertElementsMatch(list.getElementsByClassName('C A'), 'li.A.C'); 
     494      this.assertElementsMatch(list.getElementsByClassName("C\nA "), 'li.A.C'); 
     495      this.assertElementsMatch(list.getElementsByClassName('B')); 
     496      this.assertElementsMatch(list.getElementsByClassName('1'), 'li.1'); 
     497      this.assertElementsMatch(list.getElementsByClassName([1]), 'li.1'); 
     498      this.assertElementsMatch(list.getElementsByClassName(['1 junk'])); 
     499      this.assertElementsMatch(list.getElementsByClassName('')); 
     500      this.assertElementsMatch(list.getElementsByClassName(' ')); 
     501      this.assertElementsMatch(list.getElementsByClassName([''])); 
     502      this.assertElementsMatch(list.getElementsByClassName([' ', ''])); 
     503      this.assertElementsMatch(list.getElementsByClassName({})); 
    504504       
    505505      // those lookups shouldn't have extended all nodes in document 
    506       if (Prototype.Browser.IE) assertUndefined(document.getElementById('unextended')['show']); 
    507     }}
    508  
    509     testElementInsertWithHTML: function() {with(this) { 
     506      if (Prototype.Browser.IE) this.assertUndefined(document.getElementById('unextended')['show']); 
     507    }
     508 
     509    testElementInsertWithHTML: function() { 
    510510      Element.insert('insertions-main', {before:'<p><em>before</em> text</p><p>more testing</p>'}); 
    511       assert(getInnerHTML('insertions-container').startsWith('<p><em>before</em> text</p><p>more testing</p>')); 
     511      this.assert(getInnerHTML('insertions-container').startsWith('<p><em>before</em> text</p><p>more testing</p>')); 
    512512      Element.insert('insertions-main', {after:'<p><em>after</em> text</p><p>more testing</p>'}); 
    513       assert(getInnerHTML('insertions-container').endsWith('<p><em>after</em> text</p><p>more testing</p>')); 
     513      this.assert(getInnerHTML('insertions-container').endsWith('<p><em>after</em> text</p><p>more testing</p>')); 
    514514      Element.insert('insertions-main', {top:'<p><em>top</em> text.</p><p>more testing</p>'}); 
    515       assert(getInnerHTML('insertions-main').startsWith('<p><em>top</em> text.</p><p>more testing</p>')); 
     515      this.assert(getInnerHTML('insertions-main').startsWith('<p><em>top</em> text.</p><p>more testing</p>')); 
    516516      Element.insert('insertions-main', {bottom:'<p><em>bottom</em> text.</p><p>more testing</p>'}); 
    517       assert(getInnerHTML('insertions-main').endsWith('<p><em>bottom</em> text.</p><p>more testing</p>')); 
    518     }}
    519  
    520     testElementInsertWithDOMNode: function() {with(this) { 
     517      this.assert(getInnerHTML('insertions-main').endsWith('<p><em>bottom</em> text.</p><p>more testing</p>')); 
     518    }
     519 
     520    testElementInsertWithDOMNode: function() { 
    521521      Element.insert('insertions-node-main', {before: createParagraph('node before')}); 
    522       assert(getInnerHTML('insertions-node-container').startsWith('<p>node before</p>')); 
     522      this.assert(getInnerHTML('insertions-node-container').startsWith('<p>node before</p>')); 
    523523      Element.insert('insertions-node-main', {after: createParagraph('node after')}); 
    524       assert(getInnerHTML('insertions-node-container').endsWith('<p>node after</p>')); 
     524      this.assert(getInnerHTML('insertions-node-container').endsWith('<p>node after</p>')); 
    525525      Element.insert('insertions-node-main', {top:createParagraph('node top')}); 
    526       assert(getInnerHTML('insertions-node-main').startsWith('<p>node top</p>')); 
     526      this.assert(getInnerHTML('insertions-node-main').startsWith('<p>node top</p>')); 
    527527      Element.insert('insertions-node-main', {bottom:createParagraph('node bottom')}); 
    528       assert(getInnerHTML('insertions-node-main').endsWith('<p>node bottom</p>')); 
    529       assertEqual($('insertions-node-main'), $('insertions-node-main').insert(document.createElement('p'))); 
    530     }}
    531      
    532     testElementInsertWithToElementMethod: function() {with(this) { 
     528      this.assert(getInnerHTML('insertions-node-main').endsWith('<p>node bottom</p>')); 
     529      this.assertEqual($('insertions-node-main'), $('insertions-node-main').insert(document.createElement('p'))); 
     530    }
     531     
     532    testElementInsertWithToElementMethod: function() { 
    533533      Element.insert('insertions-node-main', {toElement: createParagraph.curry('toElement') }); 
    534       assert(getInnerHTML('insertions-node-main').endsWith('<p>toelement</p>')); 
     534      this.assert(getInnerHTML('insertions-node-main').endsWith('<p>toelement</p>')); 
    535535      Element.insert('insertions-node-main', {bottom: {toElement: createParagraph.curry('bottom toElement') }}); 
    536       assert(getInnerHTML('insertions-node-main').endsWith('<p>bottom toelement</p>')); 
    537     }}
    538      
    539     testElementInsertWithToHTMLMethod: function() {with(this) { 
     536      this.assert(getInnerHTML('insertions-node-main').endsWith('<p>bottom toelement</p>')); 
     537    }
     538     
     539    testElementInsertWithToHTMLMethod: function() { 
    540540      Element.insert('insertions-node-main', {toHTML: function() { return '<p>toHTML</p>'} }); 
    541       assert(getInnerHTML('insertions-node-main').endsWith('<p>tohtml</p>')); 
     541      this.assert(getInnerHTML('insertions-node-main').endsWith('<p>tohtml</p>')); 
    542542      Element.insert('insertions-node-main', {bottom: {toHTML: function() { return '<p>bottom toHTML</p>'} }}); 
    543       assert(getInnerHTML('insertions-node-main').endsWith('<p>bottom tohtml</p>')); 
    544     }}
    545      
    546     testElementInsertWithNonString: function() {with(this) { 
     543      this.assert(getInnerHTML('insertions-node-main').endsWith('<p>bottom tohtml</p>')); 
     544    }
     545     
     546    testElementInsertWithNonString: function() { 
    547547      Element.insert('insertions-main', {bottom:3}); 
    548       assert(getInnerHTML('insertions-main').endsWith('3')); 
    549     }}
    550  
    551     testElementInsertInTables: function() {with(this) { 
     548      this.assert(getInnerHTML('insertions-main').endsWith('3')); 
     549    }
     550 
     551    testElementInsertInTables: function() { 
    552552      Element.insert('second_row', {after:'<tr id="third_row"><td>Third Row</td></tr>'}); 
    553       assert($('second_row').descendantOf('table')); 
     553      this.assert($('second_row').descendantOf('table')); 
    554554       
    555555      $('a_cell').insert({top:'hello world'}); 
    556       assert($('a_cell').innerHTML.startsWith('hello world')); 
     556      this.assert($('a_cell').innerHTML.startsWith('hello world')); 
    557557      $('a_cell').insert({after:'<td>hi planet</td>'}); 
    558       assertEqual('hi planet', $('a_cell').next().innerHTML); 
     558      this.assertEqual('hi planet', $('a_cell').next().innerHTML); 
    559559      $('table_for_insertions').insert('<tr><td>a cell!</td></tr>'); 
    560       assert($('table_for_insertions').innerHTML.gsub('\r\n', '').toLowerCase().include('<tr><td>a cell!</td></tr>')); 
     560      this.assert($('table_for_insertions').innerHTML.gsub('\r\n', '').toLowerCase().include('<tr><td>a cell!</td></tr>')); 
    561561      $('row_1').insert({after:'<tr></tr><tr></tr><tr><td>last</td></tr>'}); 
    562       assertEqual('last', $A($('table_for_row_insertions').getElementsByTagName('tr')).last().lastChild.innerHTML); 
    563     }}
    564      
    565     testElementInsertInSelect: function() {with(this) { 
     562      this.assertEqual('last', $A($('table_for_row_insertions').getElementsByTagName('tr')).last().lastChild.innerHTML); 
     563    }
     564     
     565    testElementInsertInSelect: function() { 
    566566      var selectTop = $('select_for_insert_top'), selectBottom = $('select_for_insert_bottom'); 
    567567      selectBottom.insert('<option value="33">option 33</option><option selected="selected">option 45</option>'); 
    568       assertEqual('option 45', selectBottom.getValue()); 
     568      this.assertEqual('option 45', selectBottom.getValue()); 
    569569      selectTop.insert({top:'<option value="A">option A</option><option value="B" selected="selected">option B</option>'}); 
    570       assertEqual(4, selectTop.options.length); 
    571     }}
     570      this.assertEqual(4, selectTop.options.length); 
     571    }
    572572         
    573     testElementMethodInsert: function() {with(this) { 
     573    testElementMethodInsert: function() { 
    574574      $('element-insertions-main').insert({before:'some text before'}); 
    575       assert(getInnerHTML('element-insertions-container').startsWith('some text before')); 
     575      this.assert(getInnerHTML('element-insertions-container').startsWith('some text before')); 
    576576      $('element-insertions-main').insert({after:'some text after'}); 
    577       assert(getInnerHTML('element-insertions-container').endsWith('some text after')); 
     577      this.assert(getInnerHTML('element-insertions-container').endsWith('some text after')); 
    578578      $('element-insertions-main').insert({top:'some text top'}); 
    579       assert(getInnerHTML('element-insertions-main').startsWith('some text top')); 
     579      this.assert(getInnerHTML('element-insertions-main').startsWith('some text top')); 
    580580      $('element-insertions-main').insert({bottom:'some text bottom'}); 
    581       assert(getInnerHTML('element-insertions-main').endsWith('some text bottom')); 
     581      this.assert(getInnerHTML('element-insertions-main').endsWith('some text bottom')); 
    582582       
    583583      $('element-insertions-main').insert('some more text at the bottom'); 
    584       assert(getInnerHTML('element-insertions-main').endsWith('some more text at the bottom')); 
     584      this.assert(getInnerHTML('element-insertions-main').endsWith('some more text at the bottom')); 
    585585       
    586586      $('element-insertions-main').insert({TOP:'some text uppercase top'}); 
    587       assert(getInnerHTML('element-insertions-main').startsWith('some text uppercase top')); 
     587      this.assert(getInnerHTML('element-insertions-main').startsWith('some text uppercase top')); 
    588588       
    589589      $('element-insertions-multiple-main').insert({ 
    590590        top:'1', bottom:2, before: new Element('p').update('3'), after:'4' 
    591591      }); 
    592       assert(getInnerHTML('element-insertions-multiple-main').startsWith('1')); 
    593       assert(getInnerHTML('element-insertions-multiple-main').endsWith('2')); 
    594       assert(getInnerHTML('element-insertions-multiple-container').startsWith('<p>3</p>')); 
    595       assert(getInnerHTML('element-insertions-multiple-container').endsWith('4')); 
     592      this.assert(getInnerHTML('element-insertions-multiple-main').startsWith('1')); 
     593      this.assert(getInnerHTML('element-insertions-multiple-main').endsWith('2')); 
     594      this.assert(getInnerHTML('element-insertions-multiple-container').startsWith('<p>3</p>')); 
     595      this.assert(getInnerHTML('element-insertions-multiple-container').endsWith('4')); 
    596596       
    597597      $('element-insertions-main').update('test'); 
    598598      $('element-insertions-main').insert(null); 
    599599      $('element-insertions-main').insert({bottom:null}); 
    600       assertEqual('test', getInnerHTML('element-insertions-main')); 
     600      this.assertEqual('test', getInnerHTML('element-insertions-main')); 
    601601      $('element-insertions-main').insert(1337); 
    602       assertEqual('test1337', getInnerHTML('element-insertions-main')); 
    603     }}
    604      
    605     testNewElementInsert: function() {with(this) { 
     602      this.assertEqual('test1337', getInnerHTML('element-insertions-main')); 
     603    }
     604     
     605    testNewElementInsert: function() { 
    606606      var container = new Element('div'); 
    607607      element = new Element('div'); 
     
    609609       
    610610      element.insert({ before: '<p>a paragraph</p>' }); 
    611       assertEqual('<p>a paragraph</p><div></div>', getInnerHTML(container)); 
     611      this.assertEqual('<p>a paragraph</p><div></div>', getInnerHTML(container)); 
    612612      element.insert({ after: 'some text' }); 
    613       assertEqual('<p>a paragraph</p><div></div>some text', getInnerHTML(container)); 
     613      this.assertEqual('<p>a paragraph</p><div></div>some text', getInnerHTML(container)); 
    614614       
    615615      element.insert({ top: '<p>a paragraph</p>' }); 
    616       assertEqual('<p>a paragraph</p>', getInnerHTML(element)); 
     616      this.assertEqual('<p>a paragraph</p>', getInnerHTML(element)); 
    617617      element.insert('some text'); 
    618       assertEqual('<p>a paragraph</p>some text', getInnerHTML(element)); 
    619     }}
    620      
    621     testInsertionBackwardsCompatibility: function() {with(this) { 
     618      this.assertEqual('<p>a paragraph</p>some text', getInnerHTML(element)); 
     619    }
     620     
     621    testInsertionBackwardsCompatibility: function() { 
    622622      new Insertion.Before('element-insertions-main', 'some backward-compatibility testing before'); 
    623       assert(getInnerHTML('element-insertions-container').include('some backward-compatibility testing before')); 
     623      this.assert(getInnerHTML('element-insertions-container').include('some backward-compatibility testing before')); 
    624624      new Insertion.After('element-insertions-main', 'some backward-compatibility testing after'); 
    625       assert(getInnerHTML('element-insertions-container').include('some backward-compatibility testing after')); 
     625      this.assert(getInnerHTML('element-insertions-container').include('some backward-compatibility testing after')); 
    626626      new Insertion.Top('element-insertions-main', 'some backward-compatibility testing top'); 
    627       assert(getInnerHTML('element-insertions-main').startsWith('some backward-compatibility testing top')); 
     627      this.assert(getInnerHTML('element-insertions-main').startsWith('some backward-compatibility testing top')); 
    628628      new Insertion.Bottom('element-insertions-main', 'some backward-compatibility testing bottom'); 
    629       assert(getInnerHTML('element-insertions-main').endsWith('some backward-compatibility testing bottom')); 
    630     }}
    631      
    632     testElementWrap: function() {with(this) { 
     629      this.assert(getInnerHTML('element-insertions-main').endsWith('some backward-compatibility testing bottom')); 
     630    }
     631     
     632    testElementWrap: function() { 
    633633      var element = $('wrap'), parent = document.createElement('div'); 
    634634      element.wrap(); 
    635       assert(getInnerHTML('wrap-container').startsWith('<div><p')); 
     635      this.assert(getInnerHTML('wrap-container').startsWith('<div><p')); 
    636636      element.wrap('div'); 
    637       assert(getInnerHTML('wrap-container').startsWith('<div><div><p')); 
     637      this.assert(getInnerHTML('wrap-container').startsWith('<div><div><p')); 
    638638       
    639639      element.wrap(parent); 
    640       assert(Object.isFunction(parent.setStyle)); 
    641       assert(getInnerHTML('wrap-container').startsWith('<div><div><div><p')); 
     640      this.assert(Object.isFunction(parent.setStyle)); 
     641      this.assert(getInnerHTML('wrap-container').startsWith('<div><div><div><p')); 
    642642       
    643643      element.wrap('div', {className: 'wrapper'}); 
    644       assert(element.up().hasClassName('wrapper'));       
     644      this.assert(element.up().hasClassName('wrapper'));       
    645645      element.wrap({className: 'other-wrapper'}); 
    646       assert(element.up().hasClassName('other-wrapper')); 
     646      this.assert(element.up().hasClassName('other-wrapper')); 
    647647      element.wrap(new Element('div'), {className: 'yet-other-wrapper'}); 
    648       assert(element.up().hasClassName('yet-other-wrapper')); 
     648      this.assert(element.up().hasClassName('yet-other-wrapper')); 
    649649       
    650650      var orphan = new Element('p'), div = new Element('div'); 
    651651      orphan.wrap(div); 
    652       assertEqual(orphan.parentNode, div); 
    653     }}
    654      
    655     testElementWrapReturnsWrapper: function() {with(this) { 
     652      this.assertEqual(orphan.parentNode, div); 
     653    }
     654     
     655    testElementWrapReturnsWrapper: function() { 
    656656      var element = new Element("div"); 
    657657      var wrapper = element.wrap("div"); 
    658       assertNotEqual(element, wrapper); 
    659       assertEqual(element.up(), wrapper); 
    660     }}
    661      
    662     testElementVisible: function(){with(this) { 
    663       assertNotEqual('none', $('test-visible').style.display); 
    664       assertEqual('none', $('test-hidden').style.display); 
    665     }}
    666      
    667     testElementToggle: function(){with(this) { 
     658      this.assertNotEqual(element, wrapper); 
     659      this.assertEqual(element.up(), wrapper); 
     660    }
     661     
     662    testElementVisible: function(){ 
     663      this.assertNotEqual('none', $('test-visible').style.display); 
     664      this.assertEqual('none', $('test-hidden').style.display); 
     665    }
     666     
     667    testElementToggle: function(){ 
    668668      $('test-toggle-visible').toggle(); 
    669       assert(!$('test-toggle-visible').visible()); 
     669      this.assert(!$('test-toggle-visible').visible()); 
    670670      $('test-toggle-visible').toggle(); 
    671       assert($('test-toggle-visible').visible()); 
     671      this.assert($('test-toggle-visible').visible()); 
    672672      $('test-toggle-hidden').toggle(); 
    673       assert($('test-toggle-hidden').visible()); 
     673      this.assert($('test-toggle-hidden').visible()); 
    674674      $('test-toggle-hidden').toggle(); 
    675       assert(!$('test-toggle-hidden').visible()); 
    676     }}
    677      
    678     testElementShow: function(){with(this) { 
     675      this.assert(!$('test-toggle-hidden').visible()); 
     676    }
     677     
     678    testElementShow: function(){ 
    679679      $('test-show-visible').show(); 
    680       assert($('test-show-visible').visible()); 
     680      this.assert($('test-show-visible').visible()); 
    681681      $('test-show-hidden').show(); 
    682       assert($('test-show-hidden').visible()); 
    683     }}
    684      
    685     testElementHide: function(){with(this) { 
     682      this.assert($('test-show-hidden').visible()); 
     683    }
     684     
     685    testElementHide: function(){ 
    686686      $('test-hide-visible').hide(); 
    687       assert(!$('test-hide-visible').visible()); 
     687      this.assert(!$('test-hide-visible').visible()); 
    688688      $('test-hide-hidden').hide(); 
    689       assert(!$('test-hide-hidden').visible()); 
    690     }},  
    691      
    692     testElementRemove: function(){with(this) { 
     689      this.assert(!$('test-hide-hidden').visible()); 
     690    },  
     691     
     692    testElementRemove: function(){ 
    693693      $('removable').remove(); 
    694       assert($('removable-container').empty()); 
    695     }},   
     694      this.assert($('removable-container').empty()); 
     695    },   
    696696      
    697     testElementUpdate: function() {with(this) { 
     697    testElementUpdate: function() { 
    698698      $('testdiv').update('hello from div!'); 
    699       assertEqual('hello from div!', $('testdiv').innerHTML); 
     699      this.assertEqual('hello from div!', $('testdiv').innerHTML); 
    700700       
    701701      Element.update('testdiv', 'another hello from div!'); 
    702       assertEqual('another hello from div!', $('testdiv').innerHTML); 
     702      this.assertEqual('another hello from div!', $('testdiv').innerHTML); 
    703703       
    704704      Element.update('testdiv', 123); 
    705       assertEqual('123', $('testdiv').innerHTML); 
     705      this.assertEqual('123', $('testdiv').innerHTML); 
    706706       
    707707      Element.update('testdiv'); 
    708       assertEqual('', $('testdiv').innerHTML); 
     708      this.assertEqual('', $('testdiv').innerHTML); 
    709709       
    710710      Element.update('testdiv', '&nbsp;'); 
    711       assert(!$('testdiv').innerHTML.empty()); 
    712     }}
    713  
    714     testElementUpdateWithScript: function() {with(this) { 
     711      this.assert(!$('testdiv').innerHTML.empty()); 
     712    }
     713 
     714    testElementUpdateWithScript: function() { 
    715715      $('testdiv').update('hello from div!<script>\ntestVar="hello!";\n</'+'script>'); 
    716       assertEqual('hello from div!',$('testdiv').innerHTML); 
    717       wait(100,function(){ 
    718         assertEqual('hello!',testVar); 
     716      this.assertEqual('hello from div!',$('testdiv').innerHTML); 
     717      this.wait(100,function(){ 
     718        this.assertEqual('hello!',testVar); 
    719719         
    720720        Element.update('testdiv','another hello from div!\n<script>testVar="another hello!"</'+'script>\nhere it goes'); 
    721721         
    722722        // note: IE normalizes whitespace (like line breaks) to single spaces, thus the match test 
    723         assertMatch(/^another hello from div!\s+here it goes$/,$('testdiv').innerHTML); 
    724         wait(100,function(){ 
    725           assertEqual('another hello!',testVar); 
     723        this.assertMatch(/^another hello from div!\s+here it goes$/,$('testdiv').innerHTML); 
     724        this.wait(100,function(){ 
     725          this.assertEqual('another hello!',testVar); 
    726726           
    727727          Element.update('testdiv','a\n<script>testVar="a"\ntestVar="b"</'+'script>'); 
    728           wait(100,function(){ 
    729             assertEqual('b', testVar); 
     728          this.wait(100,function(){ 
     729            this.assertEqual('b', testVar); 
    730730             
    731731            Element.update('testdiv', 
    732732              'x<script>testVar2="a"</'+'script>\nblah\n'+ 
    733733              'x<script>testVar2="b"</'+'script>'); 
    734             wait(100,function(){ 
    735               assertEqual('b', testVar2); 
     734            this.wait(100,function(){ 
     735              this.assertEqual('b', testVar2); 
    736736            }); 
    737737          }); 
    738738        }); 
    739739      }); 
    740     }}
    741      
    742     testElementUpdateInTableRow: function() {with(this) { 
     740    }
     741     
     742    testElementUpdateInTableRow: function() { 
    743743      $('second_row').update('<td id="i_am_a_td">test</td>'); 
    744       assertEqual('test',$('i_am_a_td').innerHTML); 
     744      this.assertEqual('test',$('i_am_a_td').innerHTML); 
    745745 
    746746      Element.update('second_row','<td id="i_am_a_td">another <span>test</span></td>'); 
    747       assertEqual('another <span>test</span>',$('i_am_a_td').innerHTML.toLowerCase()); 
    748     }}
    749      
    750     testElementUpdateInTableCell: function() {with(this) { 
     747      this.assertEqual('another <span>test</span>',$('i_am_a_td').innerHTML.toLowerCase()); 
     748    }
     749     
     750    testElementUpdateInTableCell: function() { 
    751751      Element.update('a_cell','another <span>test</span>'); 
    752       assertEqual('another <span>test</span>',$('a_cell').innerHTML.toLowerCase()); 
    753     }}
    754      
    755     testElementUpdateInTable: function() {with(this) { 
     752      this.assertEqual('another <span>test</span>',$('a_cell').innerHTML.toLowerCase()); 
     753    }
     754     
     755    testElementUpdateInTable: function() { 
    756756      Element.update('table','<tr><td>boo!</td></tr>'); 
    757       assertMatch(/^<tr>\s*<td>boo!<\/td><\/tr>$/,$('table').innerHTML.toLowerCase()); 
    758     }}
    759      
    760     testElementUpdateInSelect: function() {with(this) { 
     757      this.assertMatch(/^<tr>\s*<td>boo!<\/td><\/tr>$/,$('table').innerHTML.toLowerCase()); 
     758    }
     759     
     760    testElementUpdateInSelect: function() { 
    761761      var select = $('select_for_update'); 
    762762      select.update('<option value="3">option 3</option><option selected="selected">option 4</option>'); 
    763       assertEqual('option 4', select.getValue()); 
    764     }}
    765  
    766     testElementUpdateWithDOMNode: function() {with(this) { 
     763      this.assertEqual('option 4', select.getValue()); 
     764    }
     765 
     766    testElementUpdateWithDOMNode: function() { 
    767767      $('testdiv').update(new Element('div').insert('bla')); 
    768       assertEqual('<div>bla</div>', getInnerHTML('testdiv')); 
    769     }}
    770      
    771     testElementUpdateWithToElementMethod: function() {with(this) { 
     768      this.assertEqual('<div>bla</div>', getInnerHTML('testdiv')); 
     769    }
     770     
     771    testElementUpdateWithToElementMethod: function() { 
    772772      $('testdiv').update({toElement: createParagraph.curry('foo')}); 
    773       assertEqual('<p>foo</p>', getInnerHTML('testdiv')); 
    774     }}
    775      
    776     testElementUpdateWithToHTMLMethod: function() {with(this) { 
     773      this.assertEqual('<p>foo</p>', getInnerHTML('testdiv')); 
     774    }
     775     
     776    testElementUpdateWithToHTMLMethod: function() { 
    777777      $('testdiv').update({toHTML: function() { return 'hello world' }}); 
    778       assertEqual('hello world', getInnerHTML('testdiv')); 
    779     }}
    780      
    781     testElementReplace: function() {with(this) { 
     778      this.assertEqual('hello world', getInnerHTML('testdiv')); 
     779    }
     780     
     781    testElementReplace: function() { 
    782782      $('testdiv-replace-1').replace('hello from div!'); 
    783       assertEqual('hello from div!', $('testdiv-replace-container-1').innerHTML); 
     783      this.assertEqual('hello from div!', $('testdiv-replace-container-1').innerHTML); 
    784784       
    785785      $('testdiv-replace-2').replace(123); 
    786       assertEqual('123', $('testdiv-replace-container-2').innerHTML); 
     786      this.assertEqual('123', $('testdiv-replace-container-2').innerHTML); 
    787787       
    788788      $('testdiv-replace-3').replace(); 
    789       assertEqual('', $('testdiv-replace-container-3').innerHTML); 
     789      this.assertEqual('', $('testdiv-replace-container-3').innerHTML); 
    790790       
    791791      $('testrow-replace').replace('<tr><td>hello</td></tr>'); 
    792       assert(getInnerHTML('testrow-replace-container').include('<tr><td>hello</td></tr>')); 
     792      this.assert(getInnerHTML('testrow-replace-container').include('<tr><td>hello</td></tr>')); 
    793793       
    794794      $('testoption-replace').replace('<option>hello</option>'); 
    795       assert($('testoption-replace-container').innerHTML.include('hello')); 
     795      this.assert($('testoption-replace-container').innerHTML.include('hello')); 
    796796            
    797797      $('testinput-replace').replace('<p>hello world</p>'); 
    798       assertEqual('<p>hello world</p>', getInnerHTML('testform-replace')); 
     798      this.assertEqual('<p>hello world</p>', getInnerHTML('testform-replace')); 
    799799 
    800800      $('testform-replace').replace('<form></form>'); 
    801       assertEqual('<p>some text</p><form></form><p>some text</p>', getInnerHTML('testform-replace-container')); 
    802     }}
    803      
    804     testElementReplaceWithScript: function() {with(this) { 
     801      this.assertEqual('<p>some text</p><form></form><p>some text</p>', getInnerHTML('testform-replace-container')); 
     802    }
     803     
     804    testElementReplaceWithScript: function() { 
    805805      $('testdiv-replace-4').replace('hello from div!<script>testVarReplace="hello!"</'+'script>'); 
    806       assertEqual('hello from div!', $('testdiv-replace-container-4').innerHTML); 
    807       wait(100,function(){ 
    808         assertEqual('hello!',testVarReplace); 
     806      this.assertEqual('hello from div!', $('testdiv-replace-container-4').innerHTML); 
     807      this.wait(100,function(){ 
     808        this.assertEqual('hello!',testVarReplace); 
    809809         
    810810        $('testdiv-replace-5').replace('another hello from div!\n<script>testVarReplace="another hello!"</'+'script>\nhere it goes'); 
    811811         
    812812        // note: IE normalizes whitespace (like line breaks) to single spaces, thus the match test 
    813         assertMatch(/^another hello from div!\s+here it goes$/,$('testdiv-replace-container-5').innerHTML); 
    814         wait(100,function(){ 
    815           assertEqual('another hello!',testVarReplace); 
     813        this.assertMatch(/^another hello from div!\s+here it goes$/,$('testdiv-replace-container-5').innerHTML); 
     814        this.wait(100,function(){ 
     815          this.assertEqual('another hello!',testVarReplace); 
    816816        }); 
    817817      }); 
    818     }}
    819  
    820     testElementReplaceWithDOMNode: function() {with(this) { 
     818    }
     819 
     820    testElementReplaceWithDOMNode: function() { 
    821821      $('testdiv-replace-element').replace(createParagraph('hello')); 
    822       assertEqual('<p>hello</p>', getInnerHTML('testdiv-replace-container-element')); 
    823     }}
    824      
    825     testElementReplaceWithToElementMethod: function() {with(this) { 
     822      this.assertEqual('<p>hello</p>', getInnerHTML('testdiv-replace-container-element')); 
     823    }
     824     
     825    testElementReplaceWithToElementMethod: function() { 
    826826      $('testdiv-replace-toelement').replace({toElement: createParagraph.curry('hello')}); 
    827       assertEqual('<p>hello</p>', getInnerHTML('testdiv-replace-container-toelement')); 
    828     }}
    829      
    830     testElementReplaceWithToHTMLMethod: function() {with(this) { 
     827      this.assertEqual('<p>hello</p>', getInnerHTML('testdiv-replace-container-toelement')); 
     828    }
     829     
     830    testElementReplaceWithToHTMLMethod: function() { 
    831831      $('testdiv-replace-tohtml').replace({toHTML: function() { return 'hello' }}); 
    832       assertEqual('hello', getInnerHTML('testdiv-replace-container-tohtml')); 
    833     }}
     832      this.assertEqual('hello', getInnerHTML('testdiv-replace-container-tohtml')); 
     833    }
    834834         
    835     testElementSelectorMethod: function() {with(this) {       
    836       ['getElementsBySelector','select'].each(function(method)
     835    testElementSelectorMethod: function() {       
     836      ['getElementsBySelector','select'].each(function(method)
    837837        var testSelector = $('container')[method]('p.test'); 
    838         assertEqual(testSelector.length, 4); 
    839         assertEqual(testSelector[0], $('intended')); 
    840         assertEqual(testSelector[0], $$('#container p.test')[0]);         
    841       }); 
    842     }}
    843      
    844     testElementAdjacent: function() {with(this) { 
     838        this.assertEqual(testSelector.length, 4); 
     839        this.assertEqual(testSelector[0], $('intended')); 
     840        this.assertEqual(testSelector[0], $$('#container p.test')[0]);         
     841      }, this); 
     842    }
     843     
     844    testElementAdjacent: function() { 
    845845      var elements = $('intended').adjacent('p'); 
    846       assertEqual(elements.length, 3); 
     846      this.assertEqual(elements.length, 3); 
    847847      elements.each(function(element){ 
    848         assert(element != $('intended')); 
    849       }); 
    850     }}
    851      
    852     testElementIdentify: function() {with(this) { 
     848        this.assert(element != $('intended')); 
     849      }, this); 
     850    }
     851     
     852    testElementIdentify: function() { 
    853853      var parent = $('identification'); 
    854       assertEqual(parent.down().identify(), 'predefined_id'); 
    855       assertEqual(parent.down(1).identify(), 'anonymous_element_1'); 
    856       assertEqual(parent.down(2).identify(), 'anonymous_element_2'); 
    857       assertEqual(parent.down(3).identify(), 'anonymous_element_4'); 
    858     }}
     854      this.assertEqual(parent.down().identify(), 'predefined_id'); 
     855      this.assertEqual(parent.down(1).identify(), 'anonymous_element_1'); 
     856      this.assertEqual(parent.down(2).identify(), 'anonymous_element_2'); 
     857      this.assertEqual(parent.down(3).identify(), 'anonymous_element_4'); 
     858    }
    859859        
    860     testElementClassNameMethod: function() {with(this) { 
     860    testElementClassNameMethod: function() { 
    861861      var testClassNames = $('container').getElementsByClassName('test'); 
    862862      var testSelector = $('container').getElementsBySelector('p.test'); 
    863       assertEqual(testClassNames[0], $('intended')); 
    864       assertEqual(testClassNames.length, 4); 
    865       assertEqual(testSelector[3], testClassNames[3]); 
    866       assertEqual(testClassNames.length, testSelector.length); 
    867     }}
    868      
    869     testElementAncestors: function() {with(this) { 
     863      this.assertEqual(testClassNames[0], $('intended')); 
     864      this.assertEqual(testClassNames.length, 4); 
     865      this.assertEqual(testSelector[3], testClassNames[3]); 
     866      this.assertEqual(testClassNames.length, testSelector.length); 
     867    }
     868     
     869    testElementAncestors: function() { 
    870870      var ancestors = $('navigation_test_f').ancestors(); 
    871       assertElementsMatch(ancestors, 'ul', 'li', 'ul#navigation_test', 
     871      this.assertElementsMatch(ancestors, 'ul', 'li', 'ul#navigation_test', 
    872872        'div#nav_tests_isolator', 'body', 'html'); 
    873       assertElementsMatch(ancestors.last().ancestors()); 
     873      this.assertElementsMatch(ancestors.last().ancestors()); 
    874874       
    875875      var dummy = $(document.createElement('DIV')); 
    876876      dummy.innerHTML = '<div></div>'.times(3); 
    877       assert(typeof $(dummy.childNodes[0]).ancestors()[0]['setStyle'] == 'function'); 
    878     }}
    879      
    880     testElementDescendants: function() {with(this) { 
    881       assertElementsMatch($('navigation_test').descendants(),  
     877      this.assert(typeof $(dummy.childNodes[0]).ancestors()[0]['setStyle'] == 'function'); 
     878    }
     879     
     880    testElementDescendants: function() { 
     881      this.assertElementsMatch($('navigation_test').descendants(),  
    882882        'li', 'em', 'li', 'em.dim', 'li', 'em', 'ul', 'li', 
    883883        'em.dim', 'li#navigation_test_f', 'em', 'li', 'em'); 
    884       assertElementsMatch($('navigation_test_f').descendants(), 'em'); 
     884      this.assertElementsMatch($('navigation_test_f').descendants(), 'em'); 
    885885       
    886886      var dummy = $(document.createElement('DIV')); 
    887887      dummy.innerHTML = '<div></div>'.times(3); 
    888       assert(typeof dummy.descendants()[0].setStyle == 'function'); 
    889     }}
    890      
    891     testElementFirstDescendant: function() {with(this) { 
    892       assertElementMatches($('navigation_test').firstDescendant(), 'li.first'); 
    893       assertNull($('navigation_test_next_sibling').firstDescendant()); 
    894     }}
    895      
    896     testElementChildElements: function() {with(this) { 
    897       assertElementsMatch($('navigation_test').childElements(), 
     888      this.assert(typeof dummy.descendants()[0].setStyle == 'function'); 
     889    }
     890     
     891    testElementFirstDescendant: function() { 
     892      this.assertElementMatches($('navigation_test').firstDescendant(), 'li.first'); 
     893      this.assertNull($('navigation_test_next_sibling').firstDescendant()); 
     894    }
     895     
     896    testElementChildElements: function() { 
     897      this.assertElementsMatch($('navigation_test').childElements(), 
    898898        'li.first', 'li', 'li#navigation_test_c', 'li.last'); 
    899       assertNotEqual(0, $('navigation_test_next_sibling').childNodes.length); 
    900       assertEnumEqual([], $('navigation_test_next_sibling').childElements()); 
     899      this.assertNotEqual(0, $('navigation_test_next_sibling').childNodes.length); 
     900      this.assertEnumEqual([], $('navigation_test_next_sibling').childElements()); 
    901901       
    902902      var dummy = $(document.createElement('DIV')); 
    903903      dummy.innerHTML = '<div></div>'.times(3); 
    904       assert(typeof dummy.childElements()[0].setStyle == 'function'); 
    905     }}
    906  
    907     testElementImmediateDescendants: function() {with(this) { 
    908       assertIdentical(Element.Methods.childElements, Element.Methods.immediateDescendants); 
    909     }},   
     904      this.assert(typeof dummy.childElements()[0].setStyle == 'function'); 
     905    }
     906 
     907    testElementImmediateDescendants: function() { 
     908      this.assertIdentical(Element.Methods.childElements, Element.Methods.immediateDescendants); 
     909    },   
    910910         
    911     testElementPreviousSiblings: function() {with(this) { 
    912       assertElementsMatch($('navigation_test').previousSiblings(), 
     911    testElementPreviousSiblings: function() { 
     912      this.assertElementsMatch($('navigation_test').previousSiblings(), 
    913913        'span#nav_test_prev_sibling', 'p.test', 'div', 'div#nav_test_first_sibling'); 
    914       assertElementsMatch($('navigation_test_f').previousSiblings(), 'li'); 
     914      this.assertElementsMatch($('navigation_test_f').previousSiblings(), 'li'); 
    915915       
    916916      var dummy = $(document.createElement('DIV')); 
    917917      dummy.innerHTML = '<div></div>'.times(3); 
    918       assert(typeof $(dummy.childNodes[1]).previousSiblings()[0].setStyle == 'function'); 
    919     }}
    920      
    921     testElementNextSiblings: function() {with(this) { 
    922       assertElementsMatch($('navigation_test').nextSiblings(), 
     918      this.assert(typeof $(dummy.childNodes[1]).previousSiblings()[0].setStyle == 'function'); 
     919    }
     920     
     921    testElementNextSiblings: function() { 
     922      this.assertElementsMatch($('navigation_test').nextSiblings(), 
    923923        'div#navigation_test_next_sibling', 'p'); 
    924       assertElementsMatch($('navigation_test_f').nextSiblings()); 
     924      this.assertElementsMatch($('navigation_test_f').nextSiblings()); 
    925925       
    926926      var dummy = $(document.createElement('DIV')); 
    927927      dummy.innerHTML = '<div></div>'.times(3); 
    928       assert(typeof $(dummy.childNodes[0]).nextSiblings()[0].setStyle == 'function'); 
    929     }}
    930      
    931     testElementSiblings: function() {with(this) { 
    932       assertElementsMatch($('navigation_test').siblings(), 
     928      this.assert(typeof $(dummy.childNodes[0]).nextSiblings()[0].setStyle == 'function'); 
     929    }
     930     
     931    testElementSiblings: function() { 
     932      this.assertElementsMatch($('navigation_test').siblings(), 
    933933        'div#nav_test_first_sibling', 'div', 'p.test', 
    934934        'span#nav_test_prev_sibling', 'div#navigation_test_next_sibling', 'p'); 
     
    936936      var dummy = $(document.createElement('DIV')); 
    937937      dummy.innerHTML = '<div></div>'.times(3); 
    938       assert(typeof $(dummy.childNodes[0]).siblings()[0].setStyle == 'function'); 
    939     }}
    940      
    941     testElementUp: function() {with(this) { 
     938      this.assert(typeof $(dummy.childNodes[0]).siblings()[0].setStyle == 'function'); 
     939    }
     940     
     941    testElementUp: function() { 
    942942      var element = $('navigation_test_f'); 
    943       assertElementMatches(element.up(), 'ul'); 
    944       assertElementMatches(element.up(0), 'ul'); 
    945       assertElementMatches(element.up(1), 'li'); 
    946       assertElementMatches(element.up(2), 'ul#navigation_test'); 
    947       assertElementsMatch(element.up('li').siblings(), 'li.first', 'li', 'li.last'); 
    948       assertElementMatches(element.up('ul', 1), 'ul#navigation_test'); 
    949       assertEqual(undefined, element.up('garbage')); 
    950       assertEqual(undefined, element.up(6)); 
    951       assertElementMatches(element.up('.non-existant, ul'), 'ul'); 
     943      this.assertElementMatches(element.up(), 'ul'); 
     944      this.assertElementMatches(element.up(0), 'ul'); 
     945      this.assertElementMatches(element.up(1), 'li'); 
     946      this.assertElementMatches(element.up(2), 'ul#navigation_test'); 
     947      this.assertElementsMatch(element.up('li').siblings(), 'li.first', 'li', 'li.last'); 
     948      this.assertElementMatches(element.up('ul', 1), 'ul#navigation_test'); 
     949      this.assertEqual(undefined, element.up('garbage')); 
     950      this.assertEqual(undefined, element.up(6)); 
     951      this.assertElementMatches(element.up('.non-existant, ul'), 'ul'); 
    952952       
    953953      var dummy = $(document.createElement('DIV')); 
    954954      dummy.innerHTML = '<div></div>'.times(3); 
    955       assert(typeof $(dummy.childNodes[0]).up().setStyle == 'function'); 
    956     }}
    957      
    958     testElementDown: function() {with(this) { 
     955      this.assert(typeof $(dummy.childNodes[0]).up().setStyle == 'function'); 
     956    }
     957     
     958    testElementDown: function() { 
    959959      var element = $('navigation_test'); 
    960       assertElementMatches(element.down(), 'li.first'); 
    961       assertElementMatches(element.down(0), 'li.first'); 
    962       assertElementMatches(element.down(1), 'em'); 
    963       assertElementMatches(element.down('li', 5), 'li.last'); 
    964       assertElementMatches(element.down('ul').down('li', 1), 'li#navigation_test_f'); 
    965       assertElementMatches(element.down('.non-existant, .first'), 'li.first'); 
     960      this.assertElementMatches(element.down(), 'li.first'); 
     961      this.assertElementMatches(element.down(0), 'li.first'); 
     962      this.assertElementMatches(element.down(1), 'em'); 
     963      this.assertElementMatches(element.down('li', 5), 'li.last'); 
     964      this.assertElementMatches(element.down('ul').down('li', 1), 'li#navigation_test_f'); 
     965      this.assertElementMatches(element.down('.non-existant, .first'), 'li.first'); 
    966966       
    967967      var dummy = $(document.createElement('DIV')); 
    968968      dummy.innerHTML = '<div></div>'.times(3); 
    969       assert(typeof dummy.down().setStyle == 'function'); 
    970     }}
    971      
    972     testElementPrevious: function() {with(this) { 
     969      this.assert(typeof dummy.down().setStyle == 'function'); 
     970    }
     971     
     972    testElementPrevious: function() { 
    973973      var element = $('navigation_test').down('li.last'); 
    974       assertElementMatches(element.previous(), 'li#navigation_test_c'); 
    975       assertElementMatches(element.previous(1), 'li'); 
    976       assertElementMatches(element.previous('.first'), 'li.first'); 
    977       assertEqual(undefined, element.previous(3)); 
    978       assertEqual(undefined, $('navigation_test').down().previous()); 
    979       assertElementMatches(element.previous('.non-existant, .first'), 'li.first'); 
     974      this.assertElementMatches(element.previous(), 'li#navigation_test_c'); 
     975      this.assertElementMatches(element.previous(1), 'li'); 
     976      this.assertElementMatches(element.previous('.first'), 'li.first'); 
     977      this.assertEqual(undefined, element.previous(3)); 
     978      this.assertEqual(undefined, $('navigation_test').down().previous()); 
     979      this.assertElementMatches(element.previous('.non-existant, .first'), 'li.first'); 
    980980       
    981981      var dummy = $(document.createElement('DIV')); 
    982982      dummy.innerHTML = '<div></div>'.times(3); 
    983       assert(typeof $(dummy.childNodes[1]).previous().setStyle == 'function'); 
    984     }}
    985      
    986     testElementNext: function() {with(this) { 
     983      this.assert(typeof $(dummy.childNodes[1]).previous().setStyle == 'function'); 
     984    }
     985     
     986    testElementNext: function() { 
    987987      var element = $('navigation_test').down('li.first'); 
    988       assertElementMatches(element.next(), 'li'); 
    989       assertElementMatches(element.next(1), 'li#navigation_test_c'); 
    990       assertElementMatches(element.next(2), 'li.last'); 
    991       assertElementMatches(element.next('.last'), 'li.last'); 
    992       assertEqual(undefined, element.next(3)); 
    993       assertEqual(undefined, element.next(2).next()); 
    994       assertElementMatches(element.next('.non-existant, .last'), 'li.last'); 
     988      this.assertElementMatches(element.next(), 'li'); 
     989      this.assertElementMatches(element.next(1), 'li#navigation_test_c'); 
     990      this.assertElementMatches(element.next(2), 'li.last'); 
     991      this.assertElementMatches(element.next('.last'), 'li.last'); 
     992      this.assertEqual(undefined, element.next(3)); 
     993      this.assertEqual(undefined, element.next(2).next()); 
     994      this.assertElementMatches(element.next('.non-existant, .last'), 'li.last'); 
    995995       
    996996      var dummy = $(document.createElement('DIV')); 
    997997      dummy.innerHTML = '<div></div>'.times(3); 
    998       assert(typeof $(dummy.childNodes[0]).next().setStyle == 'function'); 
    999     }}
    1000      
    1001     testElementInspect: function() {with(this) { 
    1002       assertEqual('<ul id="navigation_test">', $('navigation_test').inspect()); 
    1003       assertEqual('<li class="first">', $('navigation_test').down().inspect()); 
    1004       assertEqual('<em>', $('navigation_test').down(1).inspect()); 
    1005     }}
    1006      
    1007     testElementMakeClipping: function() {with(this) { 
     998      this.assert(typeof $(dummy.childNodes[0]).next().setStyle == 'function'); 
     999    }
     1000     
     1001    testElementInspect: function() { 
     1002      this.assertEqual('<ul id="navigation_test">', $('navigation_test').inspect()); 
     1003      this.assertEqual('<li class="first">', $('navigation_test').down().inspect()); 
     1004      this.assertEqual('<em>', $('navigation_test').down(1).inspect()); 
     1005    }
     1006     
     1007    testElementMakeClipping: function() { 
    10081008      var chained = Element.extend(document.createElement('DIV')); 
    1009       assertEqual(chained, chained.makeClipping()); 
    1010       assertEqual(chained, chained.makeClipping()); 
    1011       assertEqual(chained, chained.makeClipping().makeClipping()); 
    1012        
    1013       assertEqual(chained, chained.undoClipping()); 
    1014       assertEqual(chained, chained.undoClipping()); 
    1015       assertEqual(chained, chained.undoClipping().makeClipping()); 
     1009      this.assertEqual(chained, chained.makeClipping()); 
     1010      this.assertEqual(chained, chained.makeClipping()); 
     1011      this.assertEqual(chained, chained.makeClipping().makeClipping()); 
     1012       
     1013      this.assertEqual(chained, chained.undoClipping()); 
     1014      this.assertEqual(chained, chained.undoClipping()); 
     1015      this.assertEqual(chained, chained.undoClipping().makeClipping()); 
    10161016       
    10171017      ['hidden','visible','scroll'].each( function(overflowValue) { 
    10181018        var element = $('element_with_'+overflowValue+'_overflow'); 
    10191019         
    1020         assertEqual(overflowValue, element.getStyle('overflow')); 
     1020        this.assertEqual(overflowValue, element.getStyle('overflow')); 
    10211021        element.makeClipping(); 
    1022         assertEqual('hidden', element.getStyle('overflow')); 
     1022        this.assertEqual('hidden', element.getStyle('overflow')); 
    10231023        element.undoClipping(); 
    1024         assertEqual(overflowValue, element.getStyle('overflow')); 
    1025       }); 
    1026     }}
    1027      
    1028     testElementExtend: function() {with(this) { 
     1024        this.assertEqual(overflowValue, element.getStyle('overflow')); 
     1025      }, this); 
     1026    }
     1027     
     1028    testElementExtend: function() { 
    10291029      var element = $('element_extend_test'); 
    1030       assertRespondsTo('show', element); 
     1030      this.assertRespondsTo('show', element); 
    10311031       
    10321032      var XHTML_TAGS = $w( 
     
    10421042      XHTML_TAGS.each(function(tag) { 
    10431043        var element = document.createElement(tag); 
    1044         assertEqual(element, Element.extend(element)); 
    1045         assertRespondsTo('show', element); 
    1046       }); 
     1044        this.assertEqual(element, Element.extend(element)); 
     1045        this.assertRespondsTo('show', element); 
     1046      }, this); 
    10471047       
    10481048      [null,'','a','aa'].each(function(content) { 
    10491049        var textnode = document.createTextNode(content); 
    1050         assertEqual(textnode, Element.extend(textnode)); 
    1051         assert(typeof textnode['show'] == 'undefined'); 
    1052       }); 
    1053     }}
    1054      
    1055     testElementExtendReextendsDiscardedNodes: function() {with(this) { 
    1056       assertRespondsTo('show', $('discard_1')); 
     1050        this.assertEqual(textnode, Element.extend(textnode)); 
     1051        this.assert(typeof textnode['show'] == 'undefined'); 
     1052      }, this); 
     1053    }
     1054     
     1055    testElementExtendReextendsDiscardedNodes: function() { 
     1056      this.assertRespondsTo('show', $('discard_1')); 
    10571057      $('element_reextend_test').innerHTML += '<div id="discard_2"></div>'; 
    1058       assertRespondsTo('show', $('discard_1')); 
    1059     }}
    1060      
    1061     testElementCleanWhitespace: function() {with(this) { 
     1058      this.assertRespondsTo('show', $('discard_1')); 
     1059    }
     1060     
     1061    testElementCleanWhitespace: function() { 
    10621062      Element.cleanWhitespace("test_whitespace"); 
    1063       assertEqual(3, $("test_whitespace").childNodes.length); 
    1064        
    1065       assertEqual(1, $("test_whitespace").firstChild.nodeType); 
    1066       assertEqual('SPAN', $("test_whitespace").firstChild.tagName); 
    1067        
    1068       assertEqual(1, $("test_whitespace").firstChild.nextSibling.nodeType); 
    1069       assertEqual('DIV', $("test_whitespace").firstChild.nextSibling.tagName); 
    1070        
    1071       assertEqual(1, $("test_whitespace").firstChild.nextSibling.nextSibling.nodeType); 
    1072       assertEqual('SPAN', $("test_whitespace").firstChild.nextSibling.nextSibling.tagName); 
     1063      this.assertEqual(3, $("test_whitespace").childNodes.length); 
     1064       
     1065      this.assertEqual(1, $("test_whitespace").firstChild.nodeType); 
     1066      this.assertEqual('SPAN', $("test_whitespace").firstChild.tagName); 
     1067       
     1068      this.assertEqual(1, $("test_whitespace").firstChild.nextSibling.nodeType); 
     1069      this.assertEqual('DIV', $("test_whitespace").firstChild.nextSibling.tagName); 
     1070       
     1071      this.assertEqual(1, $("test_whitespace").firstChild.nextSibling.nextSibling.nodeType); 
     1072      this.assertEqual('SPAN', $("test_whitespace").firstChild.nextSibling.nextSibling.tagName); 
    10731073       
    10741074      var element = document.createElement('DIV'); 
    10751075      element.appendChild(document.createTextNode('')); 
    10761076      element.appendChild(document.createTextNode('')); 
    1077       assertEqual(2, element.childNodes.length); 
     1077      this.assertEqual(2, element.childNodes.length); 
    10781078      Element.cleanWhitespace(element); 
    1079       assertEqual(0, element.childNodes.length); 
    1080     }}
    1081      
    1082     testElementEmpty: function() {with(this) { 
    1083       assert($('test-empty').empty()); 
    1084       assert($('test-empty-but-contains-whitespace').empty()); 
    1085       assert(!$('test-full').empty()); 
    1086     }}
    1087  
    1088     testDescendantOf: function() {with(this) { 
    1089       assert($('child').descendantOf('ancestor')); 
    1090       assert($('child').descendantOf($('ancestor'))); 
    1091        
    1092       assert(!$('ancestor').descendantOf($('child'))); 
    1093  
    1094       assert($('great-grand-child').descendantOf('ancestor'), 'great-grand-child < ancestor'); 
    1095       assert($('grand-child').descendantOf('ancestor'), 'grand-child < ancestor'); 
    1096       assert($('great-grand-child').descendantOf('grand-child'), 'great-grand-child < grand-child'); 
    1097       assert($('grand-child').descendantOf('child'), 'grand-child < child'); 
    1098       assert($('great-grand-child').descendantOf('child'), 'great-grand-child < child'); 
    1099        
    1100       assert($('sibling').descendantOf('ancestor'), 'sibling < ancestor'); 
    1101       assert($('grand-sibling').descendantOf('sibling'), 'grand-sibling < sibling'); 
    1102       assert($('grand-sibling').descendantOf('ancestor'), 'grand-sibling < ancestor'); 
    1103        
    1104       assert($('grand-sibling').descendantOf(document.body), 'grand-sibling < body');       
    1105        
    1106       assert(!$('great-grand-child').descendantOf('great-grand-child'), 'great-grand-child < great-grand-child'); 
    1107       assert(!$('great-grand-child').descendantOf('sibling'), 'great-grand-child < sibling'); 
    1108       assert(!$('sibling').descendantOf('child'), 'sibling < child'); 
    1109       assert(!$('great-grand-child').descendantOf('not-in-the-family'), 'great-grand-child < not-in-the-family'); 
    1110       assert(!$('child').descendantOf('not-in-the-family'), 'child < not-in-the-family'); 
    1111        
    1112       assert(!$(document.body).descendantOf('great-grand-child')); 
     1079      this.assertEqual(0, element.childNodes.length); 
     1080    }
     1081     
     1082    testElementEmpty: function() { 
     1083      this.assert($('test-empty').empty()); 
     1084      this.assert($('test-empty-but-contains-whitespace').empty()); 
     1085      this.assert(!$('test-full').empty()); 
     1086    }
     1087 
     1088    testDescendantOf: function() { 
     1089      this.assert($('child').descendantOf('ancestor')); 
     1090      this.assert($('child').descendantOf($('ancestor'))); 
     1091       
     1092      this.assert(!$('ancestor').descendantOf($('child'))); 
     1093 
     1094      this.assert($('great-grand-child').descendantOf('ancestor'), 'great-grand-child < ancestor'); 
     1095      this.assert($('grand-child').descendantOf('ancestor'), 'grand-child < ancestor'); 
     1096      this.assert($('great-grand-child').descendantOf('grand-child'), 'great-grand-child < grand-child'); 
     1097      this.assert($('grand-child').descendantOf('child'), 'grand-child < child'); 
     1098      this.assert($('great-grand-child').descendantOf('child'), 'great-grand-child < child'); 
     1099       
     1100      this.assert($('sibling').descendantOf('ancestor'), 'sibling < ancestor'); 
     1101      this.assert($('grand-sibling').descendantOf('sibling'), 'grand-sibling < sibling'); 
     1102      this.assert($('grand-sibling').descendantOf('ancestor'), 'grand-sibling < ancestor'); 
     1103       
     1104      this.assert($('grand-sibling').descendantOf(document.body), 'grand-sibling < body');       
     1105       
     1106      this.assert(!$('great-grand-child').descendantOf('great-grand-child'), 'great-grand-child < great-grand-child'); 
     1107      this.assert(!$('great-grand-child').descendantOf('sibling'), 'great-grand-child < sibling'); 
     1108      this.assert(!$('sibling').descendantOf('child'), 'sibling < child'); 
     1109      this.assert(!$('great-grand-child').descendantOf('not-in-the-family'), 'great-grand-child < not-in-the-family'); 
     1110      this.assert(!$('child').descendantOf('not-in-the-family'), 'child < not-in-the-family'); 
     1111       
     1112      this.assert(!$(document.body).descendantOf('great-grand-child')); 
    11131113 
    11141114      // dynamically-created elements 
    11151115      $('ancestor').insert(new Element('div', { id: 'weird-uncle' })); 
    1116       assert($('weird-uncle').descendantOf('ancestor')); 
     1116      this.assert($('weird-uncle').descendantOf('ancestor')); 
    11171117       
    11181118      $(document.body).insert(new Element('div', { id: 'impostor' })); 
    1119       assert(!$('impostor').descendantOf('ancestor')); 
    1120     }},   
    1121      
    1122     testChildOf: function() {with(this) { 
    1123       assert($('child').childOf('ancestor')); 
    1124       assert($('child').childOf($('ancestor'))); 
    1125       assert($('great-grand-child').childOf('ancestor')); 
    1126       assert(!$('great-grand-child').childOf('not-in-the-family')); 
    1127       assertIdentical(Element.Methods.childOf, Element.Methods.descendantOf); 
    1128     }},     
    1129      
    1130     testElementSetStyle: function() { with(this) { 
     1119      this.assert(!$('impostor').descendantOf('ancestor')); 
     1120    },   
     1121     
     1122    testChildOf: function() { 
     1123      this.assert($('child').childOf('ancestor')); 
     1124      this.assert($('child').childOf($('ancestor'))); 
     1125      this.assert($('great-grand-child').childOf('ancestor')); 
     1126      this.assert(!$('great-grand-child').childOf('not-in-the-family')); 
     1127      this.assertIdentical(Element.Methods.childOf, Element.Methods.descendantOf); 
     1128    },     
     1129     
     1130    testElementSetStyle: function() { 
    11311131      Element.setStyle('style_test_3',{ 'left': '2px' }); 
    1132       assertEqual('2px', $('style_test_3').style.left); 
     1132      this.assertEqual('2px', $('style_test_3').style.left); 
    11331133       
    11341134      Element.setStyle('style_test_3',{ marginTop: '1px' }); 
    1135       assertEqual('1px', $('style_test_3').style.marginTop); 
     1135      this.assertEqual('1px', $('style_test_3').style.marginTop); 
    11361136       
    11371137      $('style_test_3').setStyle({ marginTop: '2px', left: '-1px' }); 
    1138       assertEqual('-1px', $('style_test_3').style.left); 
    1139       assertEqual('2px', $('style_test_3').style.marginTop); 
    1140        
    1141       assertEqual('none', $('style_test_3').getStyle('float')); 
     1138      this.assertEqual('-1px', $('style_test_3').style.left); 
     1139      this.assertEqual('2px', $('style_test_3').style.marginTop); 
     1140       
     1141      this.assertEqual('none', $('style_test_3').getStyle('float')); 
    11421142      $('style_test_3').setStyle({ 'float': 'left' }); 
    1143       assertEqual('left', $('style_test_3').getStyle('float')); 
     1143      this.assertEqual('left', $('style_test_3').getStyle('float')); 
    11441144       
    11451145      $('style_test_3').setStyle({ cssFloat: 'none' }); 
    1146       assertEqual('none', $('style_test_3').getStyle('float')); 
    1147        
    1148       assertEqual(1, $('style_test_3').getStyle('opacity')); 
     1146      this.assertEqual('none', $('style_test_3').getStyle('float')); 
     1147       
     1148      this.assertEqual(1, $('style_test_3').getStyle('opacity')); 
    11491149       
    11501150      $('style_test_3').setStyle({ opacity: 0.5 }); 
    1151       assertEqual(0.5, $('style_test_3').getStyle('opacity')); 
     1151      this.assertEqual(0.5, $('style_test_3').getStyle('opacity')); 
    11521152       
    11531153      $('style_test_3').setStyle({ opacity: '' }); 
    1154       assertEqual(1, $('style_test_3').getStyle('opacity')); 
     1154      this.assertEqual(1, $('style_test_3').getStyle('opacity')); 
    11551155       
    11561156      $('style_test_3').setStyle({ opacity: 0 }); 
    1157       assertEqual(0, $('style_test_3').getStyle('opacity')); 
     1157      this.assertEqual(0, $('style_test_3').getStyle('opacity')); 
    11581158 
    11591159      $('test_csstext_1').setStyle('font-size: 15px'); 
    1160       assertEqual('15px', $('test_csstext_1').getStyle('font-size')); 
     1160      this.assertEqual('15px', $('test_csstext_1').getStyle('font-size')); 
    11611161       
    11621162      $('test_csstext_2').setStyle({height: '40px'}); 
    11631163      $('test_csstext_2').setStyle('font-size: 15px'); 
    1164       assertEqual('15px', $('test_csstext_2').getStyle('font-size')); 
    1165       assertEqual('40px', $('test_csstext_2').getStyle('height')); 
     1164      this.assertEqual('15px', $('test_csstext_2').getStyle('font-size')); 
     1165      this.assertEqual('40px', $('test_csstext_2').getStyle('height')); 
    11661166       
    11671167      $('test_csstext_3').setStyle('font-size: 15px'); 
    1168       assertEqual('15px', $('test_csstext_3').getStyle('font-size')); 
    1169       assertEqual('1px', $('test_csstext_3').getStyle('border-top-width')); 
     1168      this.assertEqual('15px', $('test_csstext_3').getStyle('font-size')); 
     1169      this.assertEqual('1px', $('test_csstext_3').getStyle('border-top-width')); 
    11701170       
    11711171      $('test_csstext_4').setStyle('font-size: 15px'); 
    1172       assertEqual('15px', $('test_csstext_4').getStyle('font-size')); 
     1172      this.assertEqual('15px', $('test_csstext_4').getStyle('font-size')); 
    11731173       
    11741174      $('test_csstext_4').setStyle('float: right; font-size: 10px'); 
    1175       assertEqual('right', $('test_csstext_4').getStyle('float')); 
    1176       assertEqual('10px', $('test_csstext_4').getStyle('font-size')); 
     1175      this.assertEqual('right', $('test_csstext_4').getStyle('float')); 
     1176      this.assertEqual('10px', $('test_csstext_4').getStyle('font-size')); 
    11771177       
    11781178      $('test_csstext_5').setStyle('float: left; opacity: .5; font-size: 10px'); 
    1179       assertEqual(parseFloat('0.5'), parseFloat($('test_csstext_5').getStyle('opacity'))); 
    1180    }}
    1181      
    1182     testElementSetStyleCamelized: function() { with(this) { 
    1183       assertNotEqual('30px', $('style_test_3').style.marginTop); 
     1179      this.assertEqual(parseFloat('0.5'), parseFloat($('test_csstext_5').getStyle('opacity'))); 
     1180   }
     1181     
     1182    testElementSetStyleCamelized: function() { 
     1183      this.assertNotEqual('30px', $('style_test_3').style.marginTop); 
    11841184      $('style_test_3').setStyle({ marginTop: '30px'}, true); 
    1185       assertEqual('30px', $('style_test_3').style.marginTop); 
    1186     }}
    1187      
    1188     testElementSetOpacity: function() { with(this) { 
     1185      this.assertEqual('30px', $('style_test_3').style.marginTop); 
     1186    }
     1187     
     1188    testElementSetOpacity: function() { 
    11891189      [0,0.1,0.5,0.999].each(function(opacity){ 
    11901190        $('style_test_3').setOpacity(opacity); 
     
    11951195        // opera rounds off to two significant digits, so we check for a 
    11961196        // ballpark figure 
    1197         assert((Number(realOpacity) - opacity) <= 0.002, 'setting opacity to ' + opacity);         
    1198       }); 
    1199        
    1200       assertEqual(0, 
     1197        this.assert((Number(realOpacity) - opacity) <= 0.002, 'setting opacity to ' + opacity);         
     1198      }, this); 
     1199       
     1200      this.assertEqual(0, 
    12011201        $('style_test_3').setOpacity(0.0000001).getStyle('opacity')); 
    12021202       
    12031203      // for Firefox, we don't set to 1, because of flickering 
    1204       assert( 
     1204      this.assert( 
    12051205        $('style_test_3').setOpacity(0.9999999).getStyle('opacity') > 0.999 
    12061206      ); 
    12071207      if (Prototype.Browser.IE) { 
    1208         assert($('style_test_4').setOpacity(0.5).currentStyle.hasLayout); 
    1209         assert(2, $('style_test_5').setOpacity(0.5).getStyle('zoom')); 
    1210         assert(0.5, new Element('div').setOpacity(0.5).getOpacity()); 
    1211         assert(2, new Element('div').setOpacity(0.5).setStyle('zoom: 2;').getStyle('zoom')); 
    1212         assert(2, new Element('div').setStyle('zoom: 2;').setOpacity(0.5).getStyle('zoom')); 
     1208        this.assert($('style_test_4').setOpacity(0.5).currentStyle.hasLayout); 
     1209        this.assert(2, $('style_test_5').setOpacity(0.5).getStyle('zoom')); 
     1210        this.assert(0.5, new Element('div').setOpacity(0.5).getOpacity()); 
     1211        this.assert(2, new Element('div').setOpacity(0.5).setStyle('zoom: 2;').getStyle('zoom')); 
     1212        this.assert(2, new Element('div').setStyle('zoom: 2;').setOpacity(0.5).getStyle('zoom')); 
    12131213      } 
    1214     }}
    1215      
    1216     testElementGetStyle: function() { with(this) { 
    1217       assertEqual("none", 
     1214    }
     1215     
     1216    testElementGetStyle: function() { 
     1217      this.assertEqual("none", 
    12181218        $('style_test_1').getStyle('display')); 
    12191219       
    12201220      // not displayed, so "null" ("auto" is tranlated to "null") 
    1221       assertNull(Element.getStyle('style_test_1', 'width'), 'elements that are hidden should return null on getStyle("width")'); 
     1221      this.assertNull(Element.getStyle('style_test_1', 'width'), 'elements that are hidden should return null on getStyle("width")'); 
    12221222       
    12231223      $('style_test_1').show(); 
    12241224       
    12251225      // from id rule 
    1226       assertEqual("pointer", 
     1226      this.assertEqual("pointer", 
    12271227        Element.getStyle('style_test_1','cursor')); 
    12281228       
    1229       assertEqual("block", 
     1229      this.assertEqual("block", 
    12301230        Element.getStyle('style_test_2','display')); 
    12311231       
     
    12331233      // firefox and safari automatically send the correct value, 
    12341234      // IE is special-cased to do the same 
    1235       assertEqual($('style_test_2').offsetWidth+'px', Element.getStyle('style_test_2','width')); 
    1236        
    1237       assertEqual("static",Element.getStyle('style_test_1','position')); 
     1235      this.assertEqual($('style_test_2').offsetWidth+'px', Element.getStyle('style_test_2','width')); 
     1236       
     1237      this.assertEqual("static",Element.getStyle('style_test_1','position')); 
    12381238      // from style 
    1239       assertEqual("11px", 
     1239      this.assertEqual("11px", 
    12401240        Element.getStyle('style_test_2','font-size')); 
    12411241      // from class 
    1242       assertEqual("1px", 
     1242      this.assertEqual("1px", 
    12431243        Element.getStyle('style_test_2','margin-left')); 
    12441244       
    1245       ['not_floating_none','not_floating_style','not_floating_inline'].each(function(element)
    1246         assertEqual('none', $(element).getStyle('float')); 
    1247         assertEqual('none', $(element).getStyle('cssFloat')); 
    1248       }); 
    1249        
    1250       ['floating_style','floating_inline'].each(function(element)
    1251         assertEqual('left', $(element).getStyle('float')); 
    1252         assertEqual('left', $(element).getStyle('cssFloat')); 
    1253       }); 
    1254  
    1255       assertEqual(0.5, $('op1').getStyle('opacity')); 
    1256       assertEqual(0.5, $('op2').getStyle('opacity')); 
    1257       assertEqual(1.0, $('op3').getStyle('opacity')); 
     1245      ['not_floating_none','not_floating_style','not_floating_inline'].each(function(element)
     1246        this.assertEqual('none', $(element).getStyle('float')); 
     1247        this.assertEqual('none', $(element).getStyle('cssFloat')); 
     1248      }, this); 
     1249       
     1250      ['floating_style','floating_inline'].each(function(element)
     1251        this.assertEqual('left', $(element).getStyle('float')); 
     1252        this.assertEqual('left', $(element).getStyle('cssFloat')); 
     1253      }, this); 
     1254 
     1255      this.assertEqual(0.5, $('op1').getStyle('opacity')); 
     1256      this.assertEqual(0.5, $('op2').getStyle('opacity')); 
     1257      this.assertEqual(1.0, $('op3').getStyle('opacity')); 
    12581258       
    12591259      $('op1').setStyle({opacity: '0.3'}); 
     
    12611261      $('op3').setStyle({opacity: '0.3'}); 
    12621262       
    1263       assertEqual(0.3, $('op1').getStyle('opacity')); 
    1264       assertEqual(0.3, $('op2').getStyle('opacity')); 
    1265       assertEqual(0.3, $('op3').getStyle('opacity')); 
     1263      this.assertEqual(0.3, $('op1').getStyle('opacity')); 
     1264      this.assertEqual(0.3, $('op2').getStyle('opacity')); 
     1265      this.assertEqual(0.3, $('op3').getStyle('opacity')); 
    12661266       
    12671267      $('op3').setStyle({opacity: 0}); 
    1268       assertEqual(0, $('op3').getStyle('opacity')); 
     1268      this.assertEqual(0, $('op3').getStyle('opacity')); 
    12691269       
    12701270      if(navigator.appVersion.match(/MSIE/)) { 
    1271         assertEqual('alpha(opacity=30)', $('op1').getStyle('filter')); 
    1272         assertEqual('progid:DXImageTransform.Microsoft.Blur(strength=10)alpha(opacity=30)', $('op2').getStyle('filter')); 
     1271        this.assertEqual('alpha(opacity=30)', $('op1').getStyle('filter')); 
     1272        this.assertEqual('progid:DXImageTransform.Microsoft.Blur(strength=10)alpha(opacity=30)', $('op2').getStyle('filter')); 
    12731273        $('op2').setStyle({opacity:''}); 
    1274         assertEqual('progid:DXImageTransform.Microsoft.Blur(strength=10)', $('op2').getStyle('filter')); 
    1275         assertEqual('alpha(opacity=0)', $('op3').getStyle('filter')); 
    1276         assertEqual(0.3, $('op4-ie').getStyle('opacity')); 
     1274        this.assertEqual('progid:DXImageTransform.Microsoft.Blur(strength=10)', $('op2').getStyle('filter')); 
     1275        this.assertEqual('alpha(opacity=0)', $('op3').getStyle('filter')); 
     1276        this.assertEqual(0.3, $('op4-ie').getStyle('opacity')); 
    12771277      } 
    12781278      // verify that value is still found when using camelized 
    12791279      // strings (function previously used getPropertyValue() 
    12801280      // which expected non-camelized strings) 
    1281       assertEqual("12px", $('style_test_1').getStyle('fontSize')); 
     1281      this.assertEqual("12px", $('style_test_1').getStyle('fontSize')); 
    12821282       
    12831283      // getStyle on width/height should return values according to 
     
    12871287      // to calculate this properly (clientWidth/Height returns 0) 
    12881288      if(!navigator.appVersion.match(/MSIE/)) { 
    1289         assertEqual("14px", $('style_test_dimensions').getStyle('width')); 
    1290         assertEqual("17px", $('style_test_dimensions').getStyle('height')); 
     1289        this.assertEqual("14px", $('style_test_dimensions').getStyle('width')); 
     1290        this.assertEqual("17px", $('style_test_dimensions').getStyle('height')); 
    12911291      } 
    1292     }}
    1293      
    1294     testElementGetOpacity: function() {with(this) { 
    1295       assertEqual(0.45, $('op1').setOpacity(0.45).getOpacity()); 
    1296     }}
    1297      
    1298     testElementReadAttribute: function() {with(this) { 
    1299       assertEqual('test.html' , $('attributes_with_issues_1').readAttribute('href')); 
    1300       assertEqual('L' , $('attributes_with_issues_1').readAttribute('accesskey')); 
    1301       assertEqual('50' , $('attributes_with_issues_1').readAttribute('tabindex')); 
    1302       assertEqual('a link' , $('attributes_with_issues_1').readAttribute('title')); 
     1292    }
     1293     
     1294    testElementGetOpacity: function() { 
     1295      this.assertEqual(0.45, $('op1').setOpacity(0.45).getOpacity()); 
     1296    }
     1297     
     1298    testElementReadAttribute: function() { 
     1299      this.assertEqual('test.html' , $('attributes_with_issues_1').readAttribute('href')); 
     1300      this.assertEqual('L' , $('attributes_with_issues_1').readAttribute('accesskey')); 
     1301      this.assertEqual('50' , $('attributes_with_issues_1').readAttribute('tabindex')); 
     1302      this.assertEqual('a link' , $('attributes_with_issues_1').readAttribute('title')); 
    13031303       
    13041304      $('cloned_element_attributes_issue').readAttribute('foo') 
    13051305      var clone = $('cloned_element_attributes_issue').cloneNode(true); 
    13061306      clone.writeAttribute('foo', 'cloned'); 
    1307       assertEqual('cloned', clone.readAttribute('foo')); 
    1308       assertEqual('original', $('cloned_element_attributes_issue').readAttribute('foo')); 
    1309        
    1310       ['href', 'accesskey', 'accesskey', 'title'].each(function(attr)
    1311         assertEqual('' , $('attributes_with_issues_2').readAttribute(attr)); 
    1312       }); 
    1313        
    1314       ['checked','disabled','readonly','multiple'].each(function(attr)
    1315         assertEqual(attr, $('attributes_with_issues_'+attr).readAttribute(attr)); 
    1316       }); 
    1317        
    1318       assertEqual("alert('hello world');", $('attributes_with_issues_1').readAttribute('onclick')); 
    1319       assertNull($('attributes_with_issues_1').readAttribute('onmouseover')); 
     1307      this.assertEqual('cloned', clone.readAttribute('foo')); 
     1308      this.assertEqual('original', $('cloned_element_attributes_issue').readAttribute('foo')); 
     1309       
     1310      ['href', 'accesskey', 'accesskey', 'title'].each(function(attr)
     1311        this.assertEqual('' , $('attributes_with_issues_2').readAttribute(attr)); 
     1312      }, this); 
     1313       
     1314      ['checked','disabled','readonly','multiple'].each(function(attr)
     1315        this.assertEqual(attr, $('attributes_with_issues_'+attr).readAttribute(attr)); 
     1316      }, this); 
     1317       
     1318      this.assertEqual("alert('hello world');", $('attributes_with_issues_1').readAttribute('onclick')); 
     1319      this.assertNull($('attributes_with_issues_1').readAttribute('onmouseover')); 
    13201320      
    1321       assertEqual('date', $('attributes_with_issues_type').readAttribute('type')); 
    1322       assertEqual('text', $('attributes_with_issues_readonly').readAttribute('type')); 
     1321      this.assertEqual('date', $('attributes_with_issues_type').readAttribute('type')); 
     1322      this.assertEqual('text', $('attributes_with_issues_readonly').readAttribute('type')); 
    13231323       
    13241324      var elements = $('custom_attributes').immediateDescendants(); 
    1325       assertEnumEqual(['1', '2'], elements.invoke('readAttribute', 'foo')); 
    1326       assertEnumEqual(['2', null], elements.invoke('readAttribute', 'bar')); 
     1325      this.assertEnumEqual(['1', '2'], elements.invoke('readAttribute', 'foo')); 
     1326      this.assertEnumEqual(['2', null], elements.invoke('readAttribute', 'bar')); 
    13271327 
    13281328      var table = $('write_attribute_table'); 
    1329       assertEqual('4', table.readAttribute('cellspacing')); 
    1330       assertEqual('6', table.readAttribute('cellpadding')); 
    1331     }}
    1332      
    1333     testElementWriteAttribute: function() {with(this) { 
     1329      this.assertEqual('4', table.readAttribute('cellspacing')); 
     1330      this.assertEqual('6', table.readAttribute('cellpadding')); 
     1331    }
     1332     
     1333    testElementWriteAttribute: function() { 
    13341334      var element = Element.extend(document.body.appendChild(document.createElement('p'))); 
    1335       assertRespondsTo('writeAttribute', element); 
    1336       assertEqual(element, element.writeAttribute('id', 'write_attribute_test')); 
    1337       assertEqual('write_attribute_test', element.id); 
    1338       assertEqual('http://prototypejs.org/', $('write_attribute_link'). 
     1335      this.assertRespondsTo('writeAttribute', element); 
     1336      this.assertEqual(element, element.writeAttribute('id', 'write_attribute_test')); 
     1337      this.assertEqual('write_attribute_test', element.id); 
     1338      this.assertEqual('http://prototypejs.org/', $('write_attribute_link'). 
    13391339        writeAttribute({href: 'http://prototypejs.org/', title: 'Home of Prototype'}).href); 
    1340       assertEqual('Home of Prototype', $('write_attribute_link').title); 
     1340      this.assertEqual('Home of Prototype', $('write_attribute_link').title); 
    13411341       
    13421342      var element2 = Element.extend(document.createElement('p')); 
    13431343      element2.writeAttribute('id', 'write_attribute_without_hash'); 
    1344       assertEqual('write_attribute_without_hash', element2.id); 
     1344      this.assertEqual('write_attribute_without_hash', element2.id); 
    13451345      element2.writeAttribute('animal', 'cat'); 
    1346       assertEqual('cat', element2.readAttribute('animal')); 
    1347     }}
    1348      
    1349     testElementWriteAttributeWithBooleans: function() {with(this) { 
     1346      this.assertEqual('cat', element2.readAttribute('animal')); 
     1347    }
     1348     
     1349    testElementWriteAttributeWithBooleans: function() { 
    13501350      var input = $('write_attribute_input'), 
    13511351        select = $('write_attribute_select'), 
    13521352        checkbox = $('write_attribute_checkbox'), 
    13531353        checkedCheckbox = $('write_attribute_checked_checkbox'); 
    1354       assert( input.          writeAttribute('readonly').            hasAttribute('readonly')); 
    1355       assert(!input.          writeAttribute('readonly', false).     hasAttribute('readonly')); 
    1356       assert( input.          writeAttribute('readonly', true).      hasAttribute('readonly')); 
    1357       assert(!input.          writeAttribute('readonly', null).      hasAttribute('readonly')); 
    1358       assert( input.          writeAttribute('readonly', 'readonly').hasAttribute('readonly')); 
    1359       assert( select.         writeAttribute('multiple').            hasAttribute('multiple')); 
    1360       assert( input.          writeAttribute('disabled').            hasAttribute('disabled')); 
    1361       assert( checkbox.       writeAttribute('checked').             checked); 
    1362       assert(!checkedCheckbox.writeAttribute('checked', false).      checked); 
    1363     }}
    1364  
    1365     testElementWriteAttributeWithIssues: function() {with(this) { 
     1354      this.assert( input.          writeAttribute('readonly').            hasAttribute('readonly')); 
     1355      this.assert(!input.          writeAttribute('readonly', false).     hasAttribute('readonly')); 
     1356      this.assert( input.          writeAttribute('readonly', true).      hasAttribute('readonly')); 
     1357      this.assert(!input.          writeAttribute('readonly', null).      hasAttribute('readonly')); 
     1358      this.assert( input.          writeAttribute('readonly', 'readonly').hasAttribute('readonly')); 
     1359      this.assert( select.         writeAttribute('multiple').            hasAttribute('multiple')); 
     1360      this.assert( input.          writeAttribute('disabled').            hasAttribute('disabled')); 
     1361      this.assert( checkbox.       writeAttribute('checked').             checked); 
     1362      this.assert(!checkedCheckbox.writeAttribute('checked', false).      checked); 
     1363    }
     1364 
     1365    testElementWriteAttributeWithIssues: function() { 
    13661366      var input = $('write_attribute_input').writeAttribute({maxlength: 90, tabindex: 10}), 
    13671367        td = $('write_attribute_td').writeAttribute({valign: 'bottom', colspan: 2, rowspan: 2}); 
    1368       assertEqual(90, input.readAttribute('maxlength')); 
    1369       assertEqual(10, input.readAttribute('tabindex')); 
    1370       assertEqual(2,  td.readAttribute('colspan')); 
    1371       assertEqual(2,  td.readAttribute('rowspan')); 
    1372       assertEqual('bottom', td.readAttribute('valign')); 
     1368      this.assertEqual(90, input.readAttribute('maxlength')); 
     1369      this.assertEqual(10, input.readAttribute('tabindex')); 
     1370      this.assertEqual(2,  td.readAttribute('colspan')); 
     1371      this.assertEqual(2,  td.readAttribute('rowspan')); 
     1372      this.assertEqual('bottom', td.readAttribute('valign')); 
    13731373       
    13741374      var p = $('write_attribute_para'), label = $('write_attribute_label'); 
    1375       assertEqual('some-class',     p.    writeAttribute({'class':   'some-class'}).    readAttribute('class')); 
    1376       assertEqual('some-className', p.    writeAttribute({className: 'some-className'}).readAttribute('class')); 
    1377       assertEqual('some-id',        label.writeAttribute({'for':     'some-id'}).       readAttribute('for')); 
    1378       assertEqual('some-other-id',  label.writeAttribute({htmlFor:   'some-other-id'}). readAttribute('for')); 
    1379        
    1380       assert(p.writeAttribute({style: 'width: 5px;'}).readAttribute('style').toLowerCase().include('width'));       
     1375      this.assertEqual('some-class',     p.    writeAttribute({'class':   'some-class'}).    readAttribute('class')); 
     1376      this.assertEqual('some-className', p.    writeAttribute({className: 'some-className'}).readAttribute('class')); 
     1377      this.assertEqual('some-id',        label.writeAttribute({'for':     'some-id'}).       readAttribute('for')); 
     1378      this.assertEqual('some-other-id',  label.writeAttribute({htmlFor:   'some-other-id'}). readAttribute('for')); 
     1379       
     1380      this.assert(p.writeAttribute({style: 'width: 5px;'}).readAttribute('style').toLowerCase().include('width'));       
    13811381 
    13821382      var table = $('write_attribute_table'); 
    13831383      table.writeAttribute('cellspacing', '2') 
    13841384      table.writeAttribute('cellpadding', '3') 
    1385       assertEqual('2', table.readAttribute('cellspacing')); 
    1386       assertEqual('3', table.readAttribute('cellpadding')); 
     1385      this.assertEqual('2', table.readAttribute('cellspacing')); 
     1386      this.assertEqual('3', table.readAttribute('cellpadding')); 
    13871387 
    13881388      var iframe = new Element('iframe', { frameborder: 0 }); 
    1389       assertIdentical(0, parseInt(iframe.readAttribute('frameborder'))); 
    1390     }}
    1391      
    1392     testElementWriteAttributeWithCustom: function() {with(this) { 
     1389      this.assertIdentical(0, parseInt(iframe.readAttribute('frameborder'))); 
     1390    }
     1391     
     1392    testElementWriteAttributeWithCustom: function() { 
    13931393      var p = $('write_attribute_para').writeAttribute({name: 'martin', location: 'stockholm', age: 26}); 
    1394       assertEqual('martin',    p.readAttribute('name')); 
    1395       assertEqual('stockholm', p.readAttribute('location')); 
    1396       assertEqual('26',        p.readAttribute('age')); 
    1397     }}
    1398      
    1399     testNewElement: function() {with(this) { 
    1400       assert(new Element('h1')); 
     1394      this.assertEqual('martin',    p.readAttribute('name')); 
     1395      this.assertEqual('stockholm', p.readAttribute('location')); 
     1396      this.assertEqual('26',        p.readAttribute('age')); 
     1397    }
     1398     
     1399    testNewElement: function() { 
     1400      this.assert(new Element('h1')); 
    14011401       
    14021402      var XHTML_TAGS = $w( 
     
    14121412      XHTML_TAGS.each(function(tag, index) { 
    14131413        var id = tag + '_' + index, element = document.body.appendChild(new Element(tag, {id: id})); 
    1414         assertEqual(tag, element.tagName.toLowerCase()); 
    1415         assertEqual(element, document.body.lastChild); 
    1416         assertEqual(id, element.id); 
    1417       }); 
    1418        
    1419        
    1420       assertRespondsTo('update', new Element('div')); 
     1414        this.assertEqual(tag, element.tagName.toLowerCase()); 
     1415        this.assertEqual(element, document.body.lastChild); 
     1416        this.assertEqual(id, element.id); 
     1417      }, this); 
     1418       
     1419       
     1420      this.assertRespondsTo('update', new Element('div')); 
    14211421      Element.addMethods({ 
    14221422        cheeseCake: function(){ 
     
    14251425      }); 
    14261426       
    1427       assertRespondsTo('cheeseCake', new Element('div')); 
     1427      this.assertRespondsTo('cheeseCake', new Element('div')); 
    14281428       
    14291429      /* window.ElementOld = function(tagName, attributes) {  
     
    14351435      }; 
    14361436       
    1437       benchmark(function(){ 
    1438         XHTML_TAGS.each(function(tagName){new Element(tagName)}); 
     1437      this.benchmark(function(){ 
     1438        XHTML_TAGS.each(function(tagName) { new Element(tagName) }); 
    14391439      }, 5); 
    14401440       
    1441       benchmark(function(){ 
    1442         XHTML_TAGS.each(function(tagName){new ElementOld(tagName)}); 
     1441      this.benchmark(function(){ 
     1442        XHTML_TAGS.each(function(tagName) { new ElementOld(tagName) }); 
    14431443      }, 5); */ 
    14441444       
    1445       assertEqual('foobar', new Element('a', {custom: 'foobar'}).readAttribute('custom')); 
     1445      this.assertEqual('foobar', new Element('a', {custom: 'foobar'}).readAttribute('custom')); 
    14461446      var input = document.body.appendChild(new Element('input',  
    14471447        {id: 'my_input_field_id', name: 'my_input_field'})); 
    1448       assertEqual(input, document.body.lastChild); 
    1449       assertEqual('my_input_field', $(document.body.lastChild).name); 
     1448      this.assertEqual(input, document.body.lastChild); 
     1449      this.assertEqual('my_input_field', $(document.body.lastChild).name); 
    14501450      if (Prototype.Browser.IE) 
    1451         assertMatch(/name=["']?my_input_field["']?/, $('my_input_field').outerHTML); 
     1451        this.assertMatch(/name=["']?my_input_field["']?/, $('my_input_field').outerHTML); 
    14521452       
    14531453      if (originalElement && Prototype.BrowserFeatures.ElementExtensions) { 
    14541454        Element.prototype.fooBar = Prototype.emptyFunction 
    1455         assertRespondsTo('fooBar', new Element('div')); 
     1455        this.assertRespondsTo('fooBar', new Element('div')); 
    14561456      } 
    1457     }}
    1458  
    1459     testElementGetHeight: function() {with(this) { 
    1460       assertIdentical(100, $('dimensions-visible').getHeight()); 
    1461       assertIdentical(100, $('dimensions-display-none').getHeight()); 
    1462     }}
    1463      
    1464     testElementGetWidth: function() {with(this) { 
    1465       assertIdentical(200, $('dimensions-visible').getWidth()); 
    1466       assertIdentical(200, $('dimensions-display-none').getWidth()); 
    1467     }}
    1468      
    1469     testElementGetDimensions: function() {with(this) { 
    1470       assertIdentical(100, $('dimensions-visible').getDimensions().height); 
    1471       assertIdentical(200, $('dimensions-visible').getDimensions().width); 
    1472       assertIdentical(100, $('dimensions-display-none').getDimensions().height); 
    1473       assertIdentical(200, $('dimensions-display-none').getDimensions().width); 
    1474        
    1475       assertIdentical(100, $('dimensions-visible-pos-rel').getDimensions().height); 
    1476       assertIdentical(200, $('dimensions-visible-pos-rel').getDimensions().width); 
    1477       assertIdentical(100, $('dimensions-display-none-pos-rel').getDimensions().height); 
    1478       assertIdentical(200, $('dimensions-display-none-pos-rel').getDimensions().width); 
    1479        
    1480       assertIdentical(100, $('dimensions-visible-pos-abs').getDimensions().height); 
    1481       assertIdentical(200, $('dimensions-visible-pos-abs').getDimensions().width); 
    1482       assertIdentical(100, $('dimensions-display-none-pos-abs').getDimensions().height); 
    1483       assertIdentical(200, $('dimensions-display-none-pos-abs').getDimensions().width); 
     1457    }
     1458 
     1459    testElementGetHeight: function() { 
     1460      this.assertIdentical(100, $('dimensions-visible').getHeight()); 
     1461      this.assertIdentical(100, $('dimensions-display-none').getHeight()); 
     1462    }
     1463     
     1464    testElementGetWidth: function() { 
     1465      this.assertIdentical(200, $('dimensions-visible').getWidth()); 
     1466      this.assertIdentical(200, $('dimensions-display-none').getWidth()); 
     1467    }
     1468     
     1469    testElementGetDimensions: function() { 
     1470      this.assertIdentical(100, $('dimensions-visible').getDimensions().height); 
     1471      this.assertIdentical(200, $('dimensions-visible').getDimensions().width); 
     1472      this.assertIdentical(100, $('dimensions-display-none').getDimensions().height); 
     1473      this.assertIdentical(200, $('dimensions-display-none').getDimensions().width); 
     1474       
     1475      this.assertIdentical(100, $('dimensions-visible-pos-rel').getDimensions().height); 
     1476      this.assertIdentical(200, $('dimensions-visible-pos-rel').getDimensions().width); 
     1477      this.assertIdentical(100, $('dimensions-display-none-pos-rel').getDimensions().height); 
     1478      this.assertIdentical(200, $('dimensions-display-none-pos-rel').getDimensions().width); 
     1479       
     1480      this.assertIdentical(100, $('dimensions-visible-pos-abs').getDimensions().height); 
     1481      this.assertIdentical(200, $('dimensions-visible-pos-abs').getDimensions().width); 
     1482      this.assertIdentical(100, $('dimensions-display-none-pos-abs').getDimensions().height); 
     1483      this.assertIdentical(200, $('dimensions-display-none-pos-abs').getDimensions().width); 
    14841484       
    14851485      // known failing issue 
    1486       // assert($('dimensions-nestee').getDimensions().width <= 500, 'check for proper dimensions of hidden child elements'); 
     1486      // this.assert($('dimensions-nestee').getDimensions().width <= 500, 'check for proper dimensions of hidden child elements'); 
    14871487       
    14881488      $('dimensions-td').hide(); 
    1489       assertIdentical(100, $('dimensions-td').getDimensions().height); 
    1490       assertIdentical(200, $('dimensions-td').getDimensions().width); 
     1489      this.assertIdentical(100, $('dimensions-td').getDimensions().height); 
     1490      this.assertIdentical(200, $('dimensions-td').getDimensions().width); 
    14911491      $('dimensions-td').show(); 
    14921492       
    14931493      $('dimensions-tr').hide(); 
    1494       assertIdentical(100, $('dimensions-tr').getDimensions().height); 
    1495       assertIdentical(200, $('dimensions-tr').getDimensions().width); 
     1494      this.assertIdentical(100, $('dimensions-tr').getDimensions().height); 
     1495      this.assertIdentical(200, $('dimensions-tr').getDimensions().width); 
    14961496      $('dimensions-tr').show(); 
    14971497       
    14981498      $('dimensions-table').hide(); 
    1499       assertIdentical(100, $('dimensions-table').getDimensions().height); 
    1500       assertIdentical(200, $('dimensions-table').getDimensions().width); 
    1501     }}
     1499      this.assertIdentical(100, $('dimensions-table').getDimensions().height); 
     1500      this.assertIdentical(200, $('dimensions-table').getDimensions().width); 
     1501    }
    15021502         
    1503     testDOMAttributesHavePrecedenceOverExtendedElementMethods: function() {with(this) { 
    1504       assertNothingRaised(function() { $('dom_attribute_precedence').down('form') }); 
    1505       assertEqual($('dom_attribute_precedence').down('input'), $('dom_attribute_precedence').down('form').update); 
    1506     }}
    1507      
    1508     testClassNames: function() {with(this) { 
    1509       assertEnumEqual([], $('class_names').classNames()); 
    1510       assertEnumEqual(['A'], $('class_names').down().classNames()); 
    1511       assertEnumEqual(['A', 'B'], $('class_names_ul').classNames()); 
    1512     }}
    1513      
    1514     testHasClassName: function() {with(this) { 
    1515       assertIdentical(false, $('class_names').hasClassName('does_not_exist')); 
    1516       assertIdentical(true, $('class_names').down().hasClassName('A')); 
    1517       assertIdentical(false, $('class_names').down().hasClassName('does_not_exist')); 
    1518       assertIdentical(true, $('class_names_ul').hasClassName('A')); 
    1519       assertIdentical(true, $('class_names_ul').hasClassName('B')); 
    1520       assertIdentical(false, $('class_names_ul').hasClassName('does_not_exist')); 
    1521     }}
    1522      
    1523     testAddClassName: function() {with(this) { 
     1503    testDOMAttributesHavePrecedenceOverExtendedElementMethods: function() { 
     1504      this.assertNothingRaised(function() { $('dom_attribute_precedence').down('form') }); 
     1505      this.assertEqual($('dom_attribute_precedence').down('input'), $('dom_attribute_precedence').down('form').update); 
     1506    }
     1507     
     1508    testClassNames: function() { 
     1509      this.assertEnumEqual([], $('class_names').classNames()); 
     1510      this.assertEnumEqual(['A'], $('class_names').down().classNames()); 
     1511      this.assertEnumEqual(['A', 'B'], $('class_names_ul').classNames()); 
     1512    }
     1513     
     1514    testHasClassName: function() { 
     1515      this.assertIdentical(false, $('class_names').hasClassName('does_not_exist')); 
     1516      this.assertIdentical(true, $('class_names').down().hasClassName('A')); 
     1517      this.assertIdentical(false, $('class_names').down().hasClassName('does_not_exist')); 
     1518      this.assertIdentical(true, $('class_names_ul').hasClassName('A')); 
     1519      this.assertIdentical(true, $('class_names_ul').hasClassName('B')); 
     1520      this.assertIdentical(false, $('class_names_ul').hasClassName('does_not_exist')); 
     1521    }
     1522     
     1523    testAddClassName: function() { 
    15241524      $('class_names').addClassName('added_className'); 
    1525       assertEnumEqual(['added_className'], $('class_names').classNames()); 
     1525      this.assertEnumEqual(['added_className'], $('class_names').classNames()); 
    15261526       
    15271527      $('class_names').addClassName('added_className'); // verify that className cannot be added twice. 
    1528       assertEnumEqual(['added_className'], $('class_names').classNames()); 
     1528      this.assertEnumEqual(['added_className'], $('class_names').classNames()); 
    15291529       
    15301530      $('class_names').addClassName('another_added_className'); 
    1531       assertEnumEqual(['added_className', 'another_added_className'], $('class_names').classNames()); 
    1532     }}
    1533      
    1534     testRemoveClassName: function() {with(this) { 
     1531      this.assertEnumEqual(['added_className', 'another_added_className'], $('class_names').classNames()); 
     1532    }
     1533     
     1534    testRemoveClassName: function() { 
    15351535      $('class_names').removeClassName('added_className'); 
    1536       assertEnumEqual(['another_added_className'], $('class_names').classNames()); 
     1536      this.assertEnumEqual(['another_added_className'], $('class_names').classNames()); 
    15371537       
    15381538      $('class_names').removeClassName('added_className'); // verify that removing a non existent className is safe. 
    1539       assertEnumEqual(['another_added_className'], $('class_names').classNames()); 
     1539      this.assertEnumEqual(['another_added_className'], $('class_names').classNames()); 
    15401540       
    15411541      $('class_names').removeClassName('another_added_className'); 
    1542       assertEnumEqual([], $('class_names').classNames()); 
    1543     }}
    1544      
    1545     testToggleClassName: function() {with(this) { 
     1542      this.assertEnumEqual([], $('class_names').classNames()); 
     1543    }
     1544     
     1545    testToggleClassName: function() { 
    15461546      $('class_names').toggleClassName('toggled_className'); 
    1547       assertEnumEqual(['toggled_className'], $('class_names').classNames()); 
     1547      this.assertEnumEqual(['toggled_className'], $('class_names').classNames()); 
    15481548       
    15491549      $('class_names').toggleClassName('toggled_className'); 
    1550       assertEnumEqual([], $('class_names').classNames()); 
     1550      this.assertEnumEqual([], $('class_names').classNames()); 
    15511551       
    15521552      $('class_names_ul').toggleClassName('toggled_className'); 
    1553       assertEnumEqual(['A', 'B', 'toggled_className'], $('class_names_ul').classNames()); 
     1553      this.assertEnumEqual(['A', 'B', 'toggled_className'], $('class_names_ul').classNames()); 
    15541554              
    15551555      $('class_names_ul').toggleClassName('toggled_className'); 
    1556       assertEnumEqual(['A', 'B'], $('class_names_ul').classNames());   
    1557     }}
    1558      
    1559     testElementScrollTo: function() {with(this) { 
     1556      this.assertEnumEqual(['A', 'B'], $('class_names_ul').classNames());   
     1557    }
     1558     
     1559    testElementScrollTo: function() { 
    15601560      var elem = $('scroll_test_2'); 
    15611561      Element.scrollTo('scroll_test_2'); 
    1562       assertEqual(Position.page(elem)[1], 0); 
     1562      this.assertEqual(Position.page(elem)[1], 0); 
    15631563      window.scrollTo(0, 0); 
    15641564       
    15651565      elem.scrollTo(); 
    1566       assertEqual(Position.page(elem)[1], 0);       
     1566      this.assertEqual(Position.page(elem)[1], 0);       
    15671567      window.scrollTo(0, 0); 
    1568     }}
    1569      
    1570     testCustomElementMethods: function() {with(this) { 
     1568    }
     1569     
     1570    testCustomElementMethods: function() { 
    15711571      var elem = $('navigation_test_f'); 
    1572       assertRespondsTo('hashBrowns', elem); 
    1573       assertEqual('hash browns', elem.hashBrowns()); 
    1574        
    1575       assertRespondsTo('hashBrowns', Element); 
    1576       assertEqual('hash browns', Element.hashBrowns(elem)); 
    1577     }}
    1578      
    1579     testSpecificCustomElementMethods: function() {with(this) { 
     1572      this.assertRespondsTo('hashBrowns', elem); 
     1573      this.assertEqual('hash browns', elem.hashBrowns()); 
     1574       
     1575      this.assertRespondsTo('hashBrowns', Element); 
     1576      this.assertEqual('hash browns', Element.hashBrowns(elem)); 
     1577    }
     1578     
     1579    testSpecificCustomElementMethods: function() { 
    15801580      var elem = $('navigation_test_f'); 
    15811581       
    1582       assert(Element.Methods.ByTag[elem.tagName]); 
    1583       assertRespondsTo('pancakes', elem); 
    1584       assertEqual("pancakes", elem.pancakes()); 
     1582      this.assert(Element.Methods.ByTag[elem.tagName]); 
     1583      this.assertRespondsTo('pancakes', elem); 
     1584      this.assertEqual("pancakes", elem.pancakes()); 
    15851585       
    15861586      var elem2 = $('test-visible'); 
    15871587 
    1588       assert(Element.Methods.ByTag[elem2.tagName]); 
    1589       assertUndefined(elem2.pancakes); 
    1590       assertRespondsTo('waffles', elem2); 
    1591       assertEqual("waffles", elem2.waffles()); 
    1592        
    1593       assertRespondsTo('orangeJuice', elem); 
    1594       assertRespondsTo('orangeJuice', elem2); 
    1595       assertEqual("orange juice", elem.orangeJuice()); 
    1596       assertEqual("orange juice", elem2.orangeJuice()); 
    1597        
    1598       assert(typeof Element.orangeJuice == 'undefined'); 
    1599       assert(typeof Element.pancakes == 'undefined'); 
    1600       assert(typeof Element.waffles == 'undefined'); 
    1601        
    1602     }}
    1603      
    1604     testScriptFragment: function() {with(this) { 
     1588      this.assert(Element.Methods.ByTag[elem2.tagName]); 
     1589      this.assertUndefined(elem2.pancakes); 
     1590      this.assertRespondsTo('waffles', elem2); 
     1591      this.assertEqual("waffles", elem2.waffles()); 
     1592       
     1593      this.assertRespondsTo('orangeJuice', elem); 
     1594      this.assertRespondsTo('orangeJuice', elem2); 
     1595      this.assertEqual("orange juice", elem.orangeJuice()); 
     1596      this.assertEqual("orange juice", elem2.orangeJuice()); 
     1597       
     1598      this.assert(typeof Element.orangeJuice == 'undefined'); 
     1599      this.assert(typeof Element.pancakes == 'undefined'); 
     1600      this.assert(typeof Element.waffles == 'undefined'); 
     1601       
     1602    }
     1603     
     1604    testScriptFragment: function() { 
    16051605      var element = document.createElement('div'); 
    16061606      // tests an issue with Safari 2.0 crashing when the ScriptFragment 
     
    16091609      ['\r','\n',' '].each(function(character){ 
    16101610        $(element).update("<script>"+character.times(10000)+"</scr"+"ipt>"); 
    1611         assertEqual('', element.innerHTML); 
    1612       }); 
     1611        this.assertEqual('', element.innerHTML); 
     1612      }, this); 
    16131613      $(element).update("<script>var blah='"+'\\'.times(10000)+"'</scr"+"ipt>"); 
    1614       assertEqual('', element.innerHTML); 
    1615     }}
    1616  
    1617     testPositionedOffset: function() {with(this) { 
    1618       assertEnumEqual([10,10], 
     1614      this.assertEqual('', element.innerHTML); 
     1615    }
     1616 
     1617    testPositionedOffset: function() { 
     1618      this.assertEnumEqual([10,10], 
    16191619        $('body_absolute').positionedOffset()); 
    1620       assertEnumEqual([10,10], 
     1620      this.assertEnumEqual([10,10], 
    16211621        $('absolute_absolute').positionedOffset()); 
    1622       assertEnumEqual([10,10], 
     1622      this.assertEnumEqual([10,10], 
    16231623        $('absolute_relative').positionedOffset()); 
    1624       assertEnumEqual([0,10], 
     1624      this.assertEnumEqual([0,10], 
    16251625        $('absolute_relative_undefined').positionedOffset()); 
    1626       assertEnumEqual([10,10], 
     1626      this.assertEnumEqual([10,10], 
    16271627        $('absolute_fixed_absolute').positionedOffset()); 
    16281628         
    16291629      var afu = $('absolute_fixed_undefined'); 
    1630       assertEnumEqual([afu.offsetLeft, afu.offsetTop], 
     1630      this.assertEnumEqual([afu.offsetLeft, afu.offsetTop], 
    16311631        afu.positionedOffset()); 
    16321632         
    16331633      var element = new Element('div'), offset = element.positionedOffset(); 
    1634       assertEnumEqual([0,0], offset); 
    1635       assertIdentical(0, offset.top); 
    1636       assertIdentical(0, offset.left); 
    1637     }}
    1638      
    1639     testCumulativeOffset: function() {with(this) { 
     1634      this.assertEnumEqual([0,0], offset); 
     1635      this.assertIdentical(0, offset.top); 
     1636      this.assertIdentical(0, offset.left); 
     1637    }
     1638     
     1639    testCumulativeOffset: function() { 
    16401640      var element = new Element('div'), offset = element.cumulativeOffset(); 
    1641       assertEnumEqual([0,0], offset); 
    1642       assertIdentical(0, offset.top); 
    1643       assertIdentical(0, offset.left); 
    1644     }}
    1645      
    1646     testViewportOffset: function() {with(this) { 
    1647       assertEnumEqual([10,10], 
     1641      this.assertEnumEqual([0,0], offset); 
     1642      this.assertIdentical(0, offset.top); 
     1643      this.assertIdentical(0, offset.left); 
     1644    }
     1645     
     1646    testViewportOffset: function() { 
     1647      this.assertEnumEqual([10,10], 
    16481648        $('body_absolute').viewportOffset()); 
    1649       assertEnumEqual([20,20], 
     1649      this.assertEnumEqual([20,20], 
    16501650        $('absolute_absolute').viewportOffset()); 
    1651       assertEnumEqual([20,20], 
     1651      this.assertEnumEqual([20,20], 
    16521652        $('absolute_relative').viewportOffset()); 
    1653       assertEnumEqual([20,30], 
     1653      this.assertEnumEqual([20,30], 
    16541654        $('absolute_relative_undefined').viewportOffset()); 
    16551655      var element = new Element('div'), offset = element.viewportOffset(); 
    1656       assertEnumEqual([0,0], offset); 
    1657       assertIdentical(0, offset.top); 
    1658       assertIdentical(0, offset.left); 
    1659     }}
    1660      
    1661     testOffsetParent: function() {with(this) { 
    1662       assertEqual('body_absolute', $('absolute_absolute').getOffsetParent().id); 
    1663       assertEqual('body_absolute', $('absolute_relative').getOffsetParent().id); 
    1664       assertEqual('absolute_relative', $('inline').getOffsetParent().id); 
    1665       assertEqual('absolute_relative', $('absolute_relative_undefined').getOffsetParent().id); 
    1666        
    1667       assertEqual(document.body, new Element('div').getOffsetParent()); 
    1668     }}
    1669  
    1670     testAbsolutize: function() {with(this) { 
     1656      this.assertEnumEqual([0,0], offset); 
     1657      this.assertIdentical(0, offset.top); 
     1658      this.assertIdentical(0, offset.left); 
     1659    }
     1660     
     1661    testOffsetParent: function() { 
     1662      this.assertEqual('body_absolute', $('absolute_absolute').getOffsetParent().id); 
     1663      this.assertEqual('body_absolute', $('absolute_relative').getOffsetParent().id); 
     1664      this.assertEqual('absolute_relative', $('inline').getOffsetParent().id); 
     1665      this.assertEqual('absolute_relative', $('absolute_relative_undefined').getOffsetParent().id); 
     1666       
     1667      this.assertEqual(document.body, new Element('div').getOffsetParent()); 
     1668    }
     1669 
     1670    testAbsolutize: function() { 
    16711671      $('notInlineAbsoluted', 'inlineAbsoluted').each(function(elt) { 
    16721672        if ('_originalLeft' in elt) delete elt._originalLeft; 
    16731673        elt.absolutize(); 
    1674         assertUndefined(elt._originalLeft, 'absolutize() did not detect absolute positioning'); 
    1675       }); 
     1674        this.assertUndefined(elt._originalLeft, 'absolutize() did not detect absolute positioning'); 
     1675      }, this); 
    16761676      // invoking on "absolute" positioned element should return element  
    16771677      var element = $('absolute_fixed_undefined').setStyle({position: 'absolute'}); 
    1678       assertEqual(element, element.absolutize()); 
    1679     }}
    1680      
    1681     testRelativize: function() {with(this) { 
     1678      this.assertEqual(element, element.absolutize()); 
     1679    }
     1680     
     1681    testRelativize: function() { 
    16821682      // invoking on "relative" positioned element should return element 
    16831683      var element = $('absolute_fixed_undefined').setStyle({position: 'relative'}); 
    1684       assertEqual(element, element.relativize()); 
    1685     }}
    1686      
    1687     testViewportDimensions: function() {with(this) { 
     1684      this.assertEqual(element, element.relativize()); 
     1685    }
     1686     
     1687    testViewportDimensions: function() { 
    16881688      preservingBrowserDimensions(function() { 
    16891689        window.resizeTo(800, 600); 
     
    16921692        var after  = document.viewport.getDimensions(); 
    16931693       
    1694         assertEqual(before.width + 50, after.width, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS"); 
    1695         assertEqual(before.height + 50, after.height, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS"); 
     1694        this.assertEqual(before.width + 50, after.width, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS"); 
     1695        this.assertEqual(before.height + 50, after.height, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS"); 
    16961696      }.bind(this)); 
    1697     }}
    1698      
    1699     testElementToViewportDimensionsDoesNotAffectDocumentProperties: function() {with(this) { 
     1697    }
     1698     
     1699    testElementToViewportDimensionsDoesNotAffectDocumentProperties: function() { 
    17001700      // No properties on the document should be affected when resizing 
    17011701      // an absolute positioned(0,0) element to viewport dimensions 
     
    17081708 
    17091709      documentViewportProperties.properties.each(function(prop) { 
    1710         assertEqual(before[prop], after[prop], prop + ' was affected'); 
    1711       });         
    1712     }}
    1713  
    1714     testViewportScrollOffsets: function() {with(this) { 
     1710        this.assertEqual(before[prop], after[prop], prop + ' was affected'); 
     1711      }, this); 
     1712    }
     1713 
     1714    testViewportScrollOffsets: function() { 
    17151715      preservingBrowserDimensions(function() { 
    17161716        window.scrollTo(0, 0); 
    1717         assertEqual(0, document.viewport.getScrollOffsets().top); 
     1717        this.assertEqual(0, document.viewport.getScrollOffsets().top); 
    17181718       
    17191719        window.scrollTo(0, 35); 
    1720         assertEqual(35, document.viewport.getScrollOffsets().top); 
     1720        this.assertEqual(35, document.viewport.getScrollOffsets().top); 
    17211721       
    17221722        window.resizeTo(200, 650); 
    17231723        window.scrollTo(25, 35); 
    1724         assertEqual(25, document.viewport.getScrollOffsets().left, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THESE TESTS TO PASS"); 
     1724        this.assertEqual(25, document.viewport.getScrollOffsets().left, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THESE TESTS TO PASS"); 
    17251725       
    17261726        window.resizeTo(850, 650); 
    17271727      }.bind(this)); 
    1728     }}
    1729      
    1730     testNodeConstants: function() {with(this) { 
    1731       assert(window.Node, 'window.Node is unavailable'); 
     1728    }
     1729     
     1730    testNodeConstants: function() { 
     1731      this.assert(window.Node, 'window.Node is unavailable'); 
    17321732 
    17331733      var constants = $H({ 
     
    17471747 
    17481748      constants.each(function(pair) { 
    1749         assertEqual(Node[pair.key], pair.value); 
     1749        this.assertEqual(Node[pair.key], pair.value); 
    17501750      }, this); 
    1751     }} 
     1751    } 
    17521752  }); 
    17531753 
  • spinoffs/prototype/trunk/test/unit/element_mixins.html

    r8572 r9036  
    3737 
    3838  new Test.Unit.Runner({ 
    39     testInput: function() {with(this) { 
    40       assert($("input").present != null); 
    41       assert(typeof $("input").present == 'function'); 
    42       assert($("input").select != null); 
    43       assertRespondsTo('present', Form.Element); 
    44       assertRespondsTo('present', Form.Element.Methods); 
    45       assertRespondsTo('coffee', $('input')); 
    46       assertIdentical(Prototype.K, Form.Element.coffee); 
    47       assertIdentical(Prototype.K, Form.Element.Methods.coffee); 
    48     }}
     39    testInput: function() { 
     40      this.assert($("input").present != null); 
     41      this.assert(typeof $("input").present == 'function'); 
     42      this.assert($("input").select != null); 
     43      this.assertRespondsTo('present', Form.Element); 
     44      this.assertRespondsTo('present', Form.Element.Methods); 
     45      this.assertRespondsTo('coffee', $('input')); 
     46      this.assertIdentical(Prototype.K, Form.Element.coffee); 
     47      this.assertIdentical(Prototype.K, Form.Element.Methods.coffee); 
     48    }
    4949     
    50     testForm: function() {with(this) { 
    51       assert($("form").reset != null); 
    52       assert($("form").getInputs().length == 2); 
    53     }}
     50    testForm: function() { 
     51      this.assert($("form").reset != null); 
     52      this.assert($("form").getInputs().length == 2); 
     53    }
    5454     
    55     testEvent: function() {with(this) { 
    56       assert($("form").observe != null) 
     55    testEvent: function() { 
     56      this.assert($("form").observe != null) 
    5757      // Can't really test this one with TestUnit... 
    5858      $('form').observe("submit", function(e) {  
     
    6060        Event.stop(e);  
    6161      }); 
    62     }}
     62    }
    6363     
    64     testCollections: function() {with(this) { 
    65       assert($$("input").all(function(input) { 
     64    testCollections: function() { 
     65      this.assert($$("input").all(function(input) { 
    6666        return (input.focus != null); 
    6767      })); 
    68     }} 
     68    } 
    6969  }); 
    7070// ]]> 
  • spinoffs/prototype/trunk/test/unit/enumerable.html

    r8798 r9036  
    6767 
    6868  new Test.Unit.Runner({     
    69     testEachBreak: function() {with(this) { 
     69    testEachBreak: function() { 
    7070      var result = 0; 
    7171      Fixtures.Basic.each(function(value) { 
     
    7373      }); 
    7474       
    75       assertEqual(2, result); 
    76     }}
    77      
    78     testEachReturnActsAsContinue: function() {with(this) { 
     75      this.assertEqual(2, result); 
     76    }
     77     
     78    testEachReturnActsAsContinue: function() { 
    7979      var results = []; 
    8080      Fixtures.Basic.each(function(value) { 
     
    8383      }); 
    8484       
    85       assertEqual('1, 3', results.join(', ')); 
    86     }}
    87      
    88     testEachChaining: function() {with(this) { 
    89       assertEqual(Fixtures.Primes, Fixtures.Primes.each(Prototype.emptyFunction)); 
    90       assertEqual(3, Fixtures.Basic.each(Prototype.emptyFunction).length); 
    91     }}
    92  
    93     testEnumContext: function() {with(this) { 
     85      this.assertEqual('1, 3', results.join(', ')); 
     86    }
     87     
     88    testEachChaining: function() { 
     89      this.assertEqual(Fixtures.Primes, Fixtures.Primes.each(Prototype.emptyFunction)); 
     90      this.assertEqual(3, Fixtures.Basic.each(Prototype.emptyFunction).length); 
     91    }
     92 
     93    testEnumContext: function() { 
    9494      var results = []; 
    9595      Fixtures.Basic.each(function(value) { 
     
    9797      }, { i: 2 }); 
    9898       
    99       assertEqual('2 4 6', results.join(' ')); 
    100  
    101       assert(Fixtures.Basic.all(function(value){ 
     99      this.assertEqual('2 4 6', results.join(' ')); 
     100 
     101      this.assert(Fixtures.Basic.all(function(value){ 
    102102        return value >= this.min && value <= this.max; 
    103103      }, { min: 1, max: 3 })); 
    104       assert(!Fixtures.Basic.all(function(value){ 
     104      this.assert(!Fixtures.Basic.all(function(value){ 
    105105        return value >= this.min && value <= this.max; 
    106106      })); 
    107       assert(Fixtures.Basic.any(function(value){ 
     107      this.assert(Fixtures.Basic.any(function(value){ 
    108108        return value == this.target_value; 
    109109      }, { target_value: 2 })); 
    110     }}
    111  
    112     testAny: function() {with(this) { 
    113       assert(!([].any())); 
    114        
    115       assert([true, true, true].any()); 
    116       assert([true, false, false].any()); 
    117       assert(![false, false, false].any()); 
    118        
    119       assert(Fixtures.Basic.any(function(value) { 
     110    }
     111 
     112    testAny: function() { 
     113      this.assert(!([].any())); 
     114       
     115      this.assert([true, true, true].any()); 
     116      this.assert([true, false, false].any()); 
     117      this.assert(![false, false, false].any()); 
     118       
     119      this.assert(Fixtures.Basic.any(function(value) { 
    120120        return value > 2; 
    121121      })); 
    122       assert(!Fixtures.Basic.any(function(value) { 
     122      this.assert(!Fixtures.Basic.any(function(value) { 
    123123        return value > 5; 
    124124      })); 
    125     }}
    126      
    127     testAll: function() {with(this) { 
    128       assert([].all()); 
    129        
    130       assert([true, true, true].all()); 
    131       assert(![true, false, false].all()); 
    132       assert(![false, false, false].all()); 
    133  
    134       assert(Fixtures.Basic.all(function(value) { 
     125    }
     126     
     127    testAll: function() { 
     128      this.assert([].all()); 
     129       
     130      this.assert([true, true, true].all()); 
     131      this.assert(![true, false, false].all()); 
     132      this.assert(![false, false, false].all()); 
     133 
     134      this.assert(Fixtures.Basic.all(function(value) { 
    135135        return value > 0; 
    136136      })); 
    137       assert(!Fixtures.Basic.all(function(value) { 
     137      this.assert(!Fixtures.Basic.all(function(value) { 
    138138        return value > 1; 
    139139      })); 
    140     }}
    141      
    142     testCollect: function() {with(this) { 
    143       assertEqual(Fixtures.Nicknames.join(', '),  
     140    }
     141     
     142    testCollect: function() { 
     143      this.assertEqual(Fixtures.Nicknames.join(', '),  
    144144        Fixtures.People.collect(function(person) { 
    145145          return person.nickname; 
    146146        }).join(", ")); 
    147147       
    148       assertEqual(26,  Fixtures.Primes.map().length); 
    149     }}
    150      
    151     testDetect: function() {with(this) { 
    152       assertEqual('Marcel Molina Jr.',  
     148      this.assertEqual(26,  Fixtures.Primes.map().length); 
     149    }
     150     
     151    testDetect: function() { 
     152      this.assertEqual('Marcel Molina Jr.',  
    153153        Fixtures.People.detect(function(person) { 
    154154          return person.nickname.match(/no/); 
    155155        }).name); 
    156     }}
    157      
    158     testEachSlice: function() {with(this) { 
    159       assertEnumEqual([], [].eachSlice(2)); 
    160       assertEqual(1, [1].eachSlice(1).length); 
    161       assertEnumEqual([1], [1].eachSlice(1)[0]); 
    162       assertEqual(2, Fixtures.Basic.eachSlice(2).length); 
    163       assertEnumEqual( 
     156    }
     157     
     158    testEachSlice: function() { 
     159      this.assertEnumEqual([], [].eachSlice(2)); 
     160      this.assertEqual(1, [1].eachSlice(1).length); 
     161      this.assertEnumEqual([1], [1].eachSlice(1)[0]); 
     162      this.assertEqual(2, Fixtures.Basic.eachSlice(2).length); 
     163      this.assertEnumEqual( 
    164164        [3, 2, 1, 11, 7, 5, 19, 17, 13, 31, 29, 23, 43, 41, 37, 59, 53, 47, 71, 67, 61, 83, 79, 73, 97, 89], 
    165165        Fixtures.Primes.eachSlice( 3, function(slice){ return slice.reverse() }).flatten() 
    166166      ); 
    167       assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(-10)); 
    168       assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
    169       assertNotIdentical(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
    170     }}
    171      
    172     testEachWithIndex: function() {with(this) { 
     167      this.assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(-10)); 
     168      this.assertEnumEqual(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
     169      this.assertNotIdentical(Fixtures.Basic, Fixtures.Basic.eachSlice(0)); 
     170    }
     171     
     172    testEachWithIndex: function() { 
    173173      var nicknames = [], indexes = []; 
    174174      Fixtures.People.each(function(person, index) { 
     
    177177      }); 
    178178       
    179       assertEqual(Fixtures.Nicknames.join(', '),  
     179      this.assertEqual(Fixtures.Nicknames.join(', '),  
    180180        nicknames.join(', ')); 
    181       assertEqual('0, 1, 2, 3', indexes.join(', ')); 
    182     }}
    183      
    184     testFindAll: function() {with(this) { 
    185       assertEqual(Fixtures.Primes.join(', '), 
     181      this.assertEqual('0, 1, 2, 3', indexes.join(', ')); 
     182    }
     183     
     184    testFindAll: function() { 
     185      this.assertEqual(Fixtures.Primes.join(', '), 
    186186        Fixtures.Z.findAll(prime).join(', ')); 
    187     }}
    188      
    189     testGrep: function() {with(this) { 
    190       assertEqual('noradio, htonl',  
     187    }
     188     
     189    testGrep: function() { 
     190      this.assertEqual('noradio, htonl',  
    191191        Fixtures.Nicknames.grep(/o/).join(", ")); 
    192192         
    193       assertEqual('NORADIO, HTONL',  
     193      this.assertEqual('NORADIO, HTONL',  
    194194        Fixtures.Nicknames.grep(/o/, function(nickname) { 
    195195          return nickname.toUpperCase(); 
    196196        }).join(", ")) 
    197197 
    198       assertEnumEqual($('grepHeader', 'grepCell'), 
     198      this.assertEnumEqual($('grepHeader', 'grepCell'), 
    199199        $('grepTable', 'grepTBody', 'grepRow', 'grepHeader', 'grepCell').grep(new Selector('.cell'))); 
    200     }}
    201      
    202     testInclude: function() {with(this) { 
    203       assert(Fixtures.Nicknames.include('sam-')); 
    204       assert(Fixtures.Nicknames.include('noradio')); 
    205       assert(!Fixtures.Nicknames.include('gmosx')); 
    206       assert(Fixtures.Basic.include(2)); 
    207       assert(Fixtures.Basic.include('2')); 
    208       assert(!Fixtures.Basic.include('4')); 
    209     }}
    210      
    211     testInGroupsOf: function() { with(this) { 
    212       assertEnumEqual([], [].inGroupsOf(3)); 
     200    }
     201     
     202    testInclude: function() { 
     203      this.assert(Fixtures.Nicknames.include('sam-')); 
     204      this.assert(Fixtures.Nicknames.include('noradio')); 
     205      this.assert(!Fixtures.Nicknames.include('gmosx')); 
     206      this.assert(Fixtures.Basic.include(2)); 
     207      this.assert(Fixtures.Basic.include('2')); 
     208      this.assert(!Fixtures.Basic.include('4')); 
     209    }
     210     
     211    testInGroupsOf: function() { 
     212      this.assertEnumEqual([], [].inGroupsOf(3)); 
    213213       
    214214      var arr = [1, 2, 3, 4, 5, 6].inGroupsOf(3); 
    215       assertEqual(2, arr.length); 
    216       assertEnumEqual([1, 2, 3], arr[0]); 
    217       assertEnumEqual([4, 5, 6], arr[1]); 
     215      this.assertEqual(2, arr.length); 
     216      this.assertEnumEqual([1, 2, 3], arr[0]); 
     217      this.assertEnumEqual([4, 5, 6], arr[1]); 
    218218       
    219219      arr = [1, 2, 3, 4, 5, 6].inGroupsOf(4); 
    220       assertEqual(2, arr.length); 
    221       assertEnumEqual([1, 2, 3, 4], arr[0]); 
    222       assertEnumEqual([5, 6, null, null], arr[1]); 
     220      this.assertEqual(2, arr.length); 
     221      this.assertEnumEqual([1, 2, 3, 4], arr[0]); 
     222      this.assertEnumEqual([5, 6, null, null], arr[1]); 
    223223       
    224224      var basic = Fixtures.Basic 
    225225       
    226226      arr = basic.inGroupsOf(4,'x'); 
    227       assertEqual(1, arr.length); 
    228       assertEnumEqual([1, 2, 3, 'x'], arr[0]); 
    229        
    230       assertEnumEqual([1,2,3,'a'], basic.inGroupsOf(2, 'a').flatten()); 
     227      this.assertEqual(1, arr.length); 
     228      this.assertEnumEqual([1, 2, 3, 'x'], arr[0]); 
     229       
     230      this.assertEnumEqual([1,2,3,'a'], basic.inGroupsOf(2, 'a').flatten()); 
    231231 
    232232      arr = basic.inGroupsOf(5, ''); 
    233       assertEqual(1, arr.length); 
    234       assertEnumEqual([1, 2, 3, '', ''], arr[0]); 
    235  
    236       assertEnumEqual([1,2,3,0], basic.inGroupsOf(2, 0).flatten()); 
    237       assertEnumEqual([1,2,3,false], basic.inGroupsOf(2, false).flatten()); 
    238     }}
    239      
    240     testInject: function() {with(this) { 
    241       assertEqual(1061,  
     233      this.assertEqual(1, arr.length); 
     234      this.assertEnumEqual([1, 2, 3, '', ''], arr[0]); 
     235 
     236      this.assertEnumEqual([1,2,3,0], basic.inGroupsOf(2, 0).flatten()); 
     237      this.assertEnumEqual([1,2,3,false], basic.inGroupsOf(2, false).flatten()); 
     238    }
     239     
     240    testInject: function() { 
     241      this.assertEqual(1061,  
    242242        Fixtures.Primes.inject(0, function(sum, value) { 
    243243          return sum + value; 
    244244        })); 
    245     }}
    246      
    247     testInvoke: function() {with(this) { 
     245    }
     246     
     247    testInvoke: function() { 
    248248      var result = [[2, 1, 3], [6, 5, 4]].invoke('sort'); 
    249       assertEqual(2, result.length); 
    250       assertEqual('1, 2, 3', result[0].join(', ')); 
    251       assertEqual('4, 5, 6', result[1].join(', ')); 
     249      this.assertEqual(2, result.length); 
     250      this.assertEqual('1, 2, 3', result[0].join(', ')); 
     251      this.assertEqual('4, 5, 6', result[1].join(', ')); 
    252252       
    253253      result = result.invoke('invoke', 'toString', 2); 
    254       assertEqual('1, 10, 11', result[0].join(', ')); 
    255       assertEqual('100, 101, 110', result[1].join(', ')); 
    256     }}
    257      
    258     testMax: function() {with(this) { 
    259       assertEqual(100, Fixtures.Z.max()); 
    260       assertEqual(97, Fixtures.Primes.max()); 
    261       assertEqual(2, [ -9, -8, -7, -6, -4, -3, -2,  0, -1,  2 ].max()); 
    262       assertEqual('sam-', Fixtures.Nicknames.max()); // ?s > ?U 
    263     }}
    264      
    265     testMin: function() {with(this) { 
    266       assertEqual(1, Fixtures.Z.min()); 
    267       assertEqual(0, [  1, 2, 3, 4, 5, 6, 7, 8, 0, 9 ].min()); 
    268       assertEqual('Ulysses', Fixtures.Nicknames.min()); // ?U < ?h 
    269     }}
    270      
    271     testPartition: function() {with(this) { 
     254      this.assertEqual('1, 10, 11', result[0].join(', ')); 
     255      this.assertEqual('100, 101, 110', result[1].join(', ')); 
     256    }
     257     
     258    testMax: function() { 
     259      this.assertEqual(100, Fixtures.Z.max()); 
     260      this.assertEqual(97, Fixtures.Primes.max()); 
     261      this.assertEqual(2, [ -9, -8, -7, -6, -4, -3, -2,  0, -1,  2 ].max()); 
     262      this.assertEqual('sam-', Fixtures.Nicknames.max()); // ?s > ?U 
     263    }
     264     
     265    testMin: function() { 
     266      this.assertEqual(1, Fixtures.Z.min()); 
     267      this.assertEqual(0, [  1, 2, 3, 4, 5, 6, 7, 8, 0, 9 ].min()); 
     268      this.assertEqual('Ulysses', Fixtures.Nicknames.min()); // ?U < ?h 
     269    }
     270     
     271    testPartition: function() { 
    272272      var result = Fixtures.People.partition(function(person) { 
    273273        return person.name.length < 15; 
    274274      }).invoke('pluck', 'nickname'); 
    275275       
    276       assertEqual(2, result.length); 
    277       assertEqual('sam-, htonl', result[0].join(', ')); 
    278       assertEqual('noradio, Ulysses', result[1].join(', ')); 
    279     }}
    280      
    281     testPluck: function() {with(this) { 
    282       assertEqual(Fixtures.Nicknames.join(', '), 
     276      this.assertEqual(2, result.length); 
     277      this.assertEqual('sam-, htonl', result[0].join(', ')); 
     278      this.assertEqual('noradio, Ulysses', result[1].join(', ')); 
     279    }
     280     
     281    testPluck: function() { 
     282      this.assertEqual(Fixtures.Nicknames.join(', '), 
    283283        Fixtures.People.pluck('nickname').join(', ')); 
    284     }}
    285      
    286     testReject: function() {with(this) { 
    287       assertEqual(0,  
     284    }
     285     
     286    testReject: function() { 
     287      this.assertEqual(0,  
    288288        Fixtures.Nicknames.reject(Prototype.K).length); 
    289289         
    290       assertEqual('sam-, noradio, htonl', 
     290      this.assertEqual('sam-, noradio, htonl', 
    291291        Fixtures.Nicknames.reject(function(nickname) { 
    292292          return nickname != nickname.toLowerCase(); 
    293293        }).join(', ')); 
    294     }}
    295      
    296     testSortBy: function() {with(this) { 
    297       assertEqual('htonl, noradio, sam-, Ulysses', 
     294    }
     295     
     296    testSortBy: function() { 
     297      this.assertEqual('htonl, noradio, sam-, Ulysses', 
    298298        Fixtures.People.sortBy(function(value) { 
    299299          return value.nickname.toLowerCase(); 
    300300        }).pluck('nickname').join(', ')); 
    301     }}
    302      
    303     testToArray: function() {with(this) { 
     301    }
     302     
     303    testToArray: function() { 
    304304      var result = Fixtures.People.toArray(); 
    305       assert(result != Fixtures.People); // they're different objects... 
    306       assertEqual(Fixtures.Nicknames.join(', '), 
     305      this.assert(result != Fixtures.People); // they're different objects... 
     306      this.assertEqual(Fixtures.Nicknames.join(', '), 
    307307        result.pluck('nickname').join(', ')); // but the values are the same 
    308     }}
    309      
    310     testZip: function() {with(this) { 
     308    }
     309     
     310    testZip: function() { 
    311311      var result = [1, 2, 3].zip([4, 5, 6], [7, 8, 9]); 
    312       assertEqual('[[1, 4, 7], [2, 5, 8], [3, 6, 9]]', result.inspect()); 
     312      this.assertEqual('[[1, 4, 7], [2, 5, 8], [3, 6, 9]]', result.inspect()); 
    313313       
    314314      result = [1, 2, 3].zip([4, 5, 6], [7, 8, 9], function(array) { return array.reverse() }); 
    315       assertEqual('[[7, 4, 1], [8, 5, 2], [9, 6, 3]]', result.inspect()); 
    316     }}
    317      
    318     testSize: function() {with(this) { 
    319       assertEqual(4, Fixtures.People.size()); 
    320       assertEqual(4, Fixtures.Nicknames.size()); 
    321       assertEqual(26, Fixtures.Primes.size()); 
    322       assertEqual(0, [].size()); 
    323     }} 
     315      this.assertEqual('[[7, 4, 1], [8, 5, 2], [9, 6, 3]]', result.inspect()); 
     316    }
     317     
     318    testSize: function() { 
     319      this.assertEqual(4, Fixtures.People.size()); 
     320      this.assertEqual(4, Fixtures.Nicknames.size()); 
     321      this.assertEqual(26, Fixtures.Primes.size()); 
     322      this.assertEqual(0, [].size()); 
     323    } 
    324324  }); 
    325325// ]]> 
  • spinoffs/prototype/trunk/test/unit/event.html

    r8721 r9036  
    3838     
    3939    // test firing an event and observing it on the element it's fired from 
    40     testCustomEventFiring: function() { with(this) { 
     40    testCustomEventFiring: function() { 
    4141      var span = $("span"), fired = false, observer = function(event) { 
    42         assertEqual(span, event.element()); 
    43         assertEqual(1, event.memo.index); 
     42        this.assertEqual(span, event.element()); 
     43        this.assertEqual(1, event.memo.index); 
    4444        fired = true; 
    45       } 
     45      }.bind(this); 
    4646       
    4747      span.observe("test:somethingHappened", observer); 
    4848      span.fire("test:somethingHappened", { index: 1 }); 
    49       assert(fired); 
     49      this.assert(fired); 
    5050       
    5151      fired = false; 
    5252      span.fire("test:somethingElseHappened"); 
    53       assert(!fired); 
    54        
    55       span.stopObserving("test:somethingHappened", observer); 
    56       span.fire("test:somethingHappened"); 
    57       assert(!fired); 
    58     }}
     53      this.assert(!fired); 
     54       
     55      span.stopObserving("test:somethingHappened", observer); 
     56      span.fire("test:somethingHappened"); 
     57      this.assert(!fired); 
     58    }
    5959     
    6060    // test firing an event and observing it on a containing element 
    61     testCustomEventBubbling: function() { with(this) { 
     61    testCustomEventBubbling: function() { 
    6262      var span = $("span"), outer = $("outer"), fired = false, observer = function(event) { 
    63         assertEqual(span, event.element()); 
     63        this.assertEqual(span, event.element()); 
    6464        fired = true; 
    65       }
     65      }.bind(this)
    6666       
    6767      outer.observe("test:somethingHappened", observer); 
    6868      span.fire("test:somethingHappened"); 
    69       assert(fired); 
     69      this.assert(fired); 
    7070       
    7171      fired = false; 
    7272      span.fire("test:somethingElseHappened"); 
    73       assert(!fired); 
     73      this.assert(!fired); 
    7474       
    7575      outer.stopObserving("test:somethingHappened", observer); 
    7676      span.fire("test:somethingHappened"); 
    77       assert(!fired); 
    78     }}
    79      
    80     testCustomEventCanceling: function() { with(this) { 
     77      this.assert(!fired); 
     78    }
     79     
     80    testCustomEventCanceling: function() { 
    8181      var span = $("span"), outer = $("outer"), inner = $("inner"); 
    8282      var fired = false, stopped = false; 
     
    9494      outer.observe("test:somethingHappened", outerObserver); 
    9595      span.fire("test:somethingHappened"); 
    96       assert(stopped); 
    97       assert(!fired); 
     96      this.assert(stopped); 
     97      this.assert(!fired); 
    9898       
    9999      fired = stopped = false; 
    100100      inner.stopObserving("test:somethingHappened", innerObserver); 
    101101      span.fire("test:somethingHappened"); 
    102       assert(!stopped); 
    103       assert(fired); 
     102      this.assert(!stopped); 
     103      this.assert(fired); 
    104104       
    105105      outer.stopObserving("test:somethingHappened", outerObserver); 
    106     }}
    107      
    108     testEventObjectIsExtended: function() { with(this) {  
     106    }
     107     
     108    testEventObjectIsExtended: function() {  
    109109      var span = $("span"), event, observedEvent, observer = function(e) { observedEvent = e }; 
    110110      span.observe("test:somethingHappened", observer); 
    111111      event = span.fire("test:somethingHappened"); 
    112       assertEqual(event, observedEvent); 
    113       assertEqual(Event.Methods.stop.methodize(), event.stop); 
     112      this.assertEqual(event, observedEvent); 
     113      this.assertEqual(Event.Methods.stop.methodize(), event.stop); 
    114114      span.stopObserving("test:somethingHappened", observer); 
    115115       
    116116      event = span.fire("test:somethingHappenedButNoOneIsListening"); 
    117       assertEqual(Event.Methods.stop.methodize(), event.stop); 
    118     }}
    119      
    120     testEventObserversAreBoundToTheObservedElement: function() { with(this) { 
     117      this.assertEqual(Event.Methods.stop.methodize(), event.stop); 
     118    }
     119     
     120    testEventObserversAreBoundToTheObservedElement: function() { 
    121121      var span = $("span"), target, observer = function() { target = this }; 
    122122       
     
    124124      span.fire("test:somethingHappened"); 
    125125      span.stopObserving("test:somethingHappened", observer); 
    126       assertEqual(span, target); 
     126      this.assertEqual(span, target); 
    127127      target = null; 
    128128       
     
    131131      span.fire("test:somethingHappened"); 
    132132      outer.stopObserving("test:somethingHappened", observer); 
    133       assertEqual(outer, target); 
    134     }}
    135      
    136     testMultipleCustomEventObserversWithTheSameHandler: function() { with(this) { 
     133      this.assertEqual(outer, target); 
     134    }
     135     
     136    testMultipleCustomEventObserversWithTheSameHandler: function() { 
    137137      var span = $("span"), count = 0, observer = function() { count++ }; 
    138138       
     
    140140      span.observe("test:somethingElseHappened", observer); 
    141141      span.fire("test:somethingHappened"); 
    142       assertEqual(1, count); 
    143       span.fire("test:somethingElseHappened"); 
    144       assertEqual(2, count); 
    145     }}
    146      
    147     testStopObservingWithoutArguments: function() { with(this) { 
     142      this.assertEqual(1, count); 
     143      span.fire("test:somethingElseHappened"); 
     144      this.assertEqual(2, count); 
     145    }
     146     
     147    testStopObservingWithoutArguments: function() { 
    148148      var span = $("span"), count = 0, observer = function() { count++ }; 
    149149       
     
    152152      span.stopObserving(); 
    153153      span.fire("test:somethingHappened"); 
    154       assertEqual(0, count); 
    155       span.fire("test:somethingElseHappened"); 
    156       assertEqual(0, count); 
    157     }}
    158      
    159     testStopObservingWithoutHandlerArgument: function() { with(this) { 
     154      this.assertEqual(0, count); 
     155      span.fire("test:somethingElseHappened"); 
     156      this.assertEqual(0, count); 
     157    }
     158     
     159    testStopObservingWithoutHandlerArgument: function() { 
    160160      var span = $("span"), count = 0, observer = function() { count++ }; 
    161161       
     
    164164      span.stopObserving("test:somethingHappened"); 
    165165      span.fire("test:somethingHappened"); 
    166       assertEqual(0, count); 
    167       span.fire("test:somethingElseHappened"); 
    168       assertEqual(1, count); 
     166      this.assertEqual(0, count); 
     167      span.fire("test:somethingElseHappened"); 
     168      this.assertEqual(1, count); 
    169169      span.stopObserving("test:somethingElseHappened"); 
    170170      span.fire("test:somethingElseHappened"); 
    171       assertEqual(1, count); 
    172     }}
    173      
    174     testStopObservingRemovesHandlerFromCache: function() { with(this) { 
     171      this.assertEqual(1, count); 
     172    }
     173     
     174    testStopObservingRemovesHandlerFromCache: function() { 
    175175      var span = $("span"), observer = function() { }, eventID; 
    176176       
     
    178178      eventID = span._prototypeEventID; 
    179179       
    180       assert(Event.cache[eventID]); 
    181       assert(Object.isArray(Event.cache[eventID]["test:somethingHappened"])); 
    182       assertEqual(1, Event.cache[eventID]["test:somethingHappened"].length); 
    183        
    184       span.stopObserving("test:somethingHappened", observer); 
    185       assert(Event.cache[eventID]); 
    186       assert(Object.isArray(Event.cache[eventID]["test:somethingHappened"])); 
    187       assertEqual(0, Event.cache[eventID]["test:somethingHappened"].length); 
    188     }}
    189      
    190     testObserveAndStopObservingAreChainable: function() { with(this) { 
     180      this.assert(Event.cache[eventID]); 
     181      this.assert(Object.isArray(Event.cache[eventID]["test:somethingHappened"])); 
     182      this.assertEqual(1, Event.cache[eventID]["test:somethingHappened"].length); 
     183       
     184      span.stopObserving("test:somethingHappened", observer); 
     185      this.assert(Event.cache[eventID]); 
     186      this.assert(Object.isArray(Event.cache[eventID]["test:somethingHappened"])); 
     187      this.assertEqual(0, Event.cache[eventID]["test:somethingHappened"].length); 
     188    }
     189     
     190    testObserveAndStopObservingAreChainable: function() { 
    191191      var span = $("span"), observer = function() { }; 
    192192 
    193       assertEqual(span, span.observe("test:somethingHappened", observer)); 
    194       assertEqual(span, span.stopObserving("test:somethingHappened", observer)); 
    195  
    196       span.observe("test:somethingHappened", observer); 
    197       assertEqual(span, span.stopObserving("test:somethingHappened")); 
    198  
    199       span.observe("test:somethingHappened", observer); 
    200       assertEqual(span, span.stopObserving()); 
    201       assertEqual(span, span.stopObserving()); // assert it again, after there are no observers 
    202  
    203       span.observe("test:somethingHappened", observer); 
    204       assertEqual(span, span.observe("test:somethingHappened", observer)); // try to reuse the same observer 
     193      this.assertEqual(span, span.observe("test:somethingHappened", observer)); 
     194      this.assertEqual(span, span.stopObserving("test:somethingHappened", observer)); 
     195 
     196      span.observe("test:somethingHappened", observer); 
     197      this.assertEqual(span, span.stopObserving("test:somethingHappened")); 
     198 
     199      span.observe("test:somethingHappened", observer); 
     200      this.assertEqual(span, span.stopObserving()); 
     201      this.assertEqual(span, span.stopObserving()); // assert it again, after there are no observers 
     202 
     203      span.observe("test:somethingHappened", observer); 
     204      this.assertEqual(span, span.observe("test:somethingHappened", observer)); // try to reuse the same observer 
    205205      span.stopObserving(); 
    206     }}
    207  
    208     testDocumentLoaded: function() { with(this) { 
    209       assert(!documentLoaded); 
    210       assert(document.loaded); 
    211     }}
    212      
    213     testDocumentContentLoadedEventFiresBeforeWindowLoad: function() { with(this) { 
    214       assert(eventResults.contentLoaded, "contentLoaded"); 
    215       assert(eventResults.contentLoaded.endOfDocument, "contentLoaded.endOfDocument"); 
    216       assert(!eventResults.contentLoaded.windowLoad, "!contentLoaded.windowLoad"); 
    217       assert(eventResults.windowLoad, "windowLoad"); 
    218       assert(eventResults.windowLoad.endOfDocument, "windowLoad.endOfDocument"); 
    219       assert(eventResults.windowLoad.contentLoaded, "windowLoad.contentLoaded"); 
    220     }}
    221      
    222     testEventStopped: function() { with(this) { 
     206    }
     207 
     208    testDocumentLoaded: function() { 
     209      this.assert(!documentLoaded); 
     210      this.assert(document.loaded); 
     211    }
     212     
     213    testDocumentContentLoadedEventFiresBeforeWindowLoad: function() { 
     214      this.assert(eventResults.contentLoaded, "contentLoaded"); 
     215      this.assert(eventResults.contentLoaded.endOfDocument, "contentLoaded.endOfDocument"); 
     216      this.assert(!eventResults.contentLoaded.windowLoad, "!contentLoaded.windowLoad"); 
     217      this.assert(eventResults.windowLoad, "windowLoad"); 
     218      this.assert(eventResults.windowLoad.endOfDocument, "windowLoad.endOfDocument"); 
     219      this.assert(eventResults.windowLoad.contentLoaded, "windowLoad.contentLoaded"); 
     220    }
     221     
     222    testEventStopped: function() { 
    223223      var span = $("span"), event; 
    224224 
    225225      span.observe("test:somethingHappened", function() { }); 
    226226      event = span.fire("test:somethingHappened"); 
    227       assert(!event.stopped, "event.stopped should be false with an empty observer"); 
     227      this.assert(!event.stopped, "event.stopped should be false with an empty observer"); 
    228228      span.stopObserving("test:somethingHappened"); 
    229229       
    230230      span.observe("test:somethingHappened", function(e) { e.stop() }); 
    231231      event = span.fire("test:somethingHappened"); 
    232       assert(event.stopped, "event.stopped should be true for an observer that calls stop"); 
     232      this.assert(event.stopped, "event.stopped should be true for an observer that calls stop"); 
    233233      span.stopObserving("test:somethingHappened"); 
    234     }}
    235  
    236     testEventFindElement: function() { with(this) { 
     234    }
     235 
     236    testEventFindElement: function() { 
    237237      var span = $("span"), event; 
    238238      event = span.fire("test:somethingHappened"); 
    239       assertElementMatches(event.findElement(), 'span#span'); 
    240       assertElementMatches(event.findElement('span'), 'span#span'); 
    241       assertElementMatches(event.findElement('p'), 'p#inner'); 
    242       assertEqual(null, event.findElement('div.does_not_exist')); 
    243       assertElementMatches(event.findElement('.does_not_exist, span'), 'span#span'); 
    244     }}
    245      
    246     testEventIDDuplication: function() { with(this) { 
     239      this.assertElementMatches(event.findElement(), 'span#span'); 
     240      this.assertElementMatches(event.findElement('span'), 'span#span'); 
     241      this.assertElementMatches(event.findElement('p'), 'p#inner'); 
     242      this.assertEqual(null, event.findElement('div.does_not_exist')); 
     243      this.assertElementMatches(event.findElement('.does_not_exist, span'), 'span#span'); 
     244    }
     245     
     246    testEventIDDuplication: function() { 
    247247      $('container').down().observe("test:somethingHappened", Prototype.emptyFunction); 
    248248      $('container').innerHTML += $('container').innerHTML; 
    249       assertUndefined($('container').down(1)._prototypeEventID); 
    250     }} 
     249      this.assertUndefined($('container').down(1)._prototypeEventID); 
     250    } 
    251251  }); 
    252252 
  • spinoffs/prototype/trunk/test/unit/form.html

    r8998 r9036  
    150150    // Make sure to set defaults in the test forms, as some browsers override this 
    151151    // with previously entered values on page reload 
    152     setup: function(){ with(this) { 
     152    setup: function(){ 
    153153      $$('form').each(function(f){ f.reset() }); 
    154154      // hidden value does not reset (for some reason) 
    155155      $('bigform')['tf_hidden'].value = ''; 
    156     }}
    157      
    158     testDollarF: function(){ with(this) { 
    159       assertEqual("4", $F("input_enabled")); 
    160     }}
    161      
    162     testFormElementEventObserver: function(){ with(this) { 
     156    }
     157     
     158    testDollarF: function(){ 
     159      this.assertEqual("4", $F("input_enabled")); 
     160    }
     161     
     162    testFormElementEventObserver: function(){ 
    163163      var callbackCounter = 0; 
    164164      var observer = new Form.Element.EventObserver('input_enabled', function(){ 
     
    166166      }); 
    167167       
    168       assertEqual(0, callbackCounter); 
     168      this.assertEqual(0, callbackCounter); 
    169169      $('input_enabled').value = 'boo!'; 
    170170      observer.onElementEvent(); // can't test the event directly, simulating 
    171       assertEqual(1, callbackCounter); 
    172     }}
    173  
    174     testFormElementObserver: function(){ with(this) { 
     171      this.assertEqual(1, callbackCounter); 
     172    }
     173 
     174    testFormElementObserver: function(){ 
    175175      var timedCounter = 0; 
    176176      // First part: regular field 
     
    180180 
    181181      // Test it's unchanged yet 
    182       assertEqual(0, timedCounter); 
     182      this.assertEqual(0, timedCounter); 
    183183      // Test it doesn't change on first check 
    184       wait(550, function() { 
    185         assertEqual(0, timedCounter); 
     184      this.wait(550, function() { 
     185        this.assertEqual(0, timedCounter); 
    186186        // Change, test it doesn't immediately change 
    187187        $('input_enabled').value = 'yowza!'; 
    188         assertEqual(0, timedCounter); 
     188        this.assertEqual(0, timedCounter); 
    189189        // Test it changes on next check, but not again on the next 
    190         wait(550, function() { 
    191           assertEqual(1, timedCounter); 
    192           wait(550, function() { 
    193             assertEqual(1, timedCounter); 
     190        this.wait(550, function() { 
     191          this.assertEqual(1, timedCounter); 
     192          this.wait(550, function() { 
     193            this.assertEqual(1, timedCounter); 
    194194            observer.stop(); 
    195195          }); 
     
    207207 
    208208      // Test it's unchanged yet 
    209       assertEqual(0, timedCounter); 
     209      this.assertEqual(0, timedCounter); 
    210210      // Test it doesn't change on first check 
    211       wait(550, function() { 
    212         assertEqual(0, timedCounter); 
     211      this.wait(550, function() { 
     212        this.assertEqual(0, timedCounter); 
    213213        // Change, test it doesn't immediately change 
    214214        // NOTE: it is important that the 3rd be re-selected, for the 
    215215        // serialize form to obtain the expected value :-) 
    216216        $('multiSel1_opt3').selected = true; 
    217         assertEqual(0, timedCounter); 
     217        this.assertEqual(0, timedCounter); 
    218218        // Test it changes on next check, but not again on the next 
    219         wait(550, function() { 
    220           assertEqual(1, timedCounter); 
    221           wait(550, function() { 
    222             assertEqual(1, timedCounter); 
     219        this.wait(550, function() { 
     220          this.assertEqual(1, timedCounter); 
     221          this.wait(550, function() { 
     222            this.assertEqual(1, timedCounter); 
    223223            observer.stop(); 
    224224          }); 
    225225        }); 
    226226      }); 
    227     }}
    228      
    229     testFormObserver: function(){ with(this) { 
     227    }
     228     
     229    testFormObserver: function(){ 
    230230      var timedCounter = 0; 
    231231      // should work the same way was Form.Element.Observer 
     
    235235 
    236236      // Test it's unchanged yet 
    237       assertEqual(0, timedCounter); 
     237      this.assertEqual(0, timedCounter); 
    238238      // Test it doesn't change on first check 
    239       wait(550, function() { 
    240         assertEqual(0, timedCounter); 
     239      this.wait(550, function() { 
     240        this.assertEqual(0, timedCounter); 
    241241        // Change, test it doesn't immediately change 
    242242        $('input_enabled').value = 'yowza!'; 
    243         assertEqual(0, timedCounter); 
     243        this.assertEqual(0, timedCounter); 
    244244        // Test it changes on next check, but not again on the next 
    245         wait(550, function() { 
    246           assertEqual(1, timedCounter); 
    247           wait(550, function() { 
    248             assertEqual(1, timedCounter); 
     245        this.wait(550, function() { 
     246          this.assertEqual(1, timedCounter); 
     247          this.wait(550, function() { 
     248            this.assertEqual(1, timedCounter); 
    249249            observer.stop(); 
    250250          }); 
    251251        }); 
    252252      }); 
    253     }}
    254      
    255     testFormEnabling: function(){ with(this) { 
     253    }
     254     
     255    testFormEnabling: function(){ 
    256256      var form = $('bigform') 
    257257      var input1 = $('dummy_disabled'); 
    258258      var input2 = $('focus_text'); 
    259259       
    260       assertDisabled(input1); 
    261       assertEnabled(input2); 
     260      this.assertDisabled(input1); 
     261      this.assertEnabled(input2); 
    262262       
    263263      form.disable(); 
    264       assertDisabled(input1, input2); 
     264      this.assertDisabled(input1, input2); 
    265265      form.enable(); 
    266       assertEnabled(input1, input2); 
     266      this.assertEnabled(input1, input2); 
    267267      input1.disable(); 
    268       assertDisabled(input1); 
     268      this.assertDisabled(input1); 
    269269       
    270270      // non-form elements: 
    271271      var fieldset = $('selects_fieldset'); 
    272272      var fields = fieldset.immediateDescendants(); 
    273       fields.each(function(select) { assertEnabled(select) }); 
     273      fields.each(function(select) { this.assertEnabled(select) }, this); 
    274274       
    275275      Form.disable(fieldset) 
    276       fields.each(function(select) { assertDisabled(select) }); 
     276      fields.each(function(select) { this.assertDisabled(select) }, this); 
    277277       
    278278      Form.enable(fieldset) 
    279       fields.each(function(select) { assertEnabled(select) }); 
    280     }}
    281      
    282     testFormElementEnabling: function(){ with(this) { 
     279      fields.each(function(select) { this.assertEnabled(select) }, this); 
     280    }
     281     
     282    testFormElementEnabling: function(){ 
    283283      var field = $('input_disabled'); 
    284284      field.enable(); 
    285       assertEnabled(field); 
     285      this.assertEnabled(field); 
    286286      field.disable(); 
    287       assertDisabled(field); 
     287      this.assertDisabled(field); 
    288288       
    289289      var field = $('input_enabled'); 
    290       assertEnabled(field); 
     290      this.assertEnabled(field); 
    291291      field.disable(); 
    292       assertDisabled(field); 
     292      this.assertDisabled(field); 
    293293      field.enable(); 
    294       assertEnabled(field); 
    295     }}
     294      this.assertEnabled(field); 
     295    }
    296296 
    297297    // due to the lack of a DOM hasFocus() API method, 
    298298    // we're simulating things here a little bit 
    299     testFormActivating: function(){ with(this) { 
     299    testFormActivating: function(){ 
    300300      // Firefox, IE, and Safari 2+ 
    301301      function getSelection(element){ 
     
    312312      // Form.focusFirstElement shouldn't focus disabled elements 
    313313      var element = Form.findFirstElement('bigform'); 
    314       assertEqual('submit', element.id); 
     314      this.assertEqual('submit', element.id); 
    315315       
    316316      // Test IE doesn't select text on buttons 
    317317      Form.focusFirstElement('bigform'); 
    318       if(document.selection) assertEqual('', getSelection(element)); 
     318      if(document.selection) this.assertEqual('', getSelection(element)); 
    319319       
    320320      // Form.Element.activate shouldn't select text on buttons 
    321321      element = $('focus_text'); 
    322       assertEqual('', getSelection(element)); 
     322      this.assertEqual('', getSelection(element)); 
    323323         
    324324      // Form.Element.activate should select text on text input elements 
    325325      element.activate(); 
    326       assertEqual('Hello', getSelection(element)); 
     326      this.assertEqual('Hello', getSelection(element)); 
    327327 
    328328      // Form.Element.activate shouldn't raise an exception when the form or field is hidden 
    329       assertNothingRaised(function() { 
     329      this.assertNothingRaised(function() { 
    330330        $('form_focus_hidden').focusFirstElement(); 
    331331      }); 
    332     }}
    333      
    334     testFormGetElements: function() {with(this) { 
     332    }
     333     
     334    testFormGetElements: function() { 
    335335      var elements = Form.getElements('various'), 
    336336        names = $w('tf_selectOne tf_textarea tf_checkbox tf_selectMany tf_text tf_radio tf_hidden tf_password'); 
    337       assertEnumEqual(names, elements.pluck('name')) 
    338     }}
    339      
    340     testFormGetInputs: function() {with(this){ 
     337      this.assertEnumEqual(names, elements.pluck('name')) 
     338    }
     339     
     340    testFormGetInputs: function() { 
    341341      var form = $('form'); 
    342342      [form.getInputs(), Form.getInputs(form)].each(function(inputs){ 
    343         assertEqual(inputs.length, 5); 
    344         assert(inputs instanceof Array); 
    345         assert(inputs.all(function(input) { return (input.tagName == "INPUT"); })); 
    346       }); 
    347     }}
    348  
    349     testFormFindFirstElement: function() {with(this) { 
    350       assertEqual($('ffe_checkbox'), $('ffe').findFirstElement()); 
    351       assertEqual($('ffe_ti_submit'), $('ffe_ti').findFirstElement()); 
    352       assertEqual($('ffe_ti2_checkbox'), $('ffe_ti2').findFirstElement()); 
    353     }}
    354      
    355     testFormSerialize: function() {with(this){ 
     343        this.assertEqual(inputs.length, 5); 
     344        this.assert(inputs instanceof Array); 
     345        this.assert(inputs.all(function(input) { return (input.tagName == "INPUT"); })); 
     346      }, this); 
     347    }
     348 
     349    testFormFindFirstElement: function() { 
     350      this.assertEqual($('ffe_checkbox'), $('ffe').findFirstElement()); 
     351      this.assertEqual($('ffe_ti_submit'), $('ffe_ti').findFirstElement()); 
     352      this.assertEqual($('ffe_ti2_checkbox'), $('ffe_ti2').findFirstElement()); 
     353    }
     354     
     355    testFormSerialize: function() { 
    356356      // form is initially empty 
    357357      var form = $('bigform'); 
    358358      var expected = { tf_selectOne:'', tf_textarea:'', tf_text:'', tf_hidden:'', tf_password:'' }; 
    359       assertHashEqual(expected, Form.serialize('various', true)); 
     359      this.assertHashEqual(expected, Form.serialize('various', true)); 
    360360         
    361361      // set up some stuff 
     
    371371 
    372372      // return params 
    373       assertHashEqual(expected, Form.serialize('various', true)); 
     373      this.assertHashEqual(expected, Form.serialize('various', true)); 
    374374      // return string 
    375       assertEnumEqual(Object.toQueryString(expected).split('&').sort(), 
     375      this.assertEnumEqual(Object.toQueryString(expected).split('&').sort(), 
    376376                      Form.serialize('various').split('&').sort()); 
    377       assertEqual('string', typeof $('form').serialize({ hash:false })); 
     377      this.assertEqual('string', typeof $('form').serialize({ hash:false })); 
    378378 
    379379      // Checks that disabled element is not included in serialized form. 
    380380      $('input_enabled').enable(); 
    381       assertHashEqual({ val1:4, action:'blah', first_submit:'Commit it!' }, 
     381      this.assertHashEqual({ val1:4, action:'blah', first_submit:'Commit it!' }, 
    382382                      $('form').serialize(true)); 
    383383 
     
    385385      $('checkbox_hack').checked = false; 
    386386      var data = Form.serialize('value_checks', true);  
    387       assertEnumEqual(['', 'siamese'], data['twin']);  
    388       assertEqual('0', data['checky']); 
     387      this.assertEnumEqual(['', 'siamese'], data['twin']);  
     388      this.assertEqual('0', data['checky']); 
    389389       
    390390      $('checkbox_hack').checked = true;  
    391       assertEnumEqual($w('1 0'), Form.serialize('value_checks', true)['checky']); 
     391      this.assertEnumEqual($w('1 0'), Form.serialize('value_checks', true)['checky']); 
    392392 
    393393      // all kinds of SELECT controls 
    394394      var params = Form.serialize('selects_fieldset', true); 
    395395      var expected = { 'nvm[]':['One', 'Three'], evu:'', 'evm[]':['', 'Three'] }; 
    396       assertHashEqual(expected, params); 
     396      this.assertHashEqual(expected, params); 
    397397      params = Form.serialize('selects_wrapper', true); 
    398       assertHashEqual(Object.extend(expected, { vu:1, 'vm[]':[1, 3], nvu:'One' }), params); 
     398      this.assertHashEqual(Object.extend(expected, { vu:1, 'vm[]':[1, 3], nvu:'One' }), params); 
    399399 
    400400      // explicit submit button 
    401       assertHashEqual({ val1:4, action:'blah', second_submit:'Delete it!' }, 
     401      this.assertHashEqual({ val1:4, action:'blah', second_submit:'Delete it!' }, 
    402402                      $('form').serialize({ submit: 'second_submit' })); 
    403       assertHashEqual({ val1:4, action:'blah' }, 
     403      this.assertHashEqual({ val1:4, action:'blah' }, 
    404404                      $('form').serialize({ submit: false })); 
    405       assertHashEqual({ val1:4, action:'blah' }, 
     405      this.assertHashEqual({ val1:4, action:'blah' }, 
    406406                      $('form').serialize({ submit: 'inexistent' })); 
    407407                       
    408     }}
    409      
    410     testFormMethodsOnExtendedElements: function() {with(this) { 
     408    }
     409     
     410    testFormMethodsOnExtendedElements: function() { 
    411411      var form = $('form'); 
    412       assertEqual(Form.serialize('form'), form.serialize()); 
    413       assertEqual(Form.Element.serialize('input_enabled'), $('input_enabled').serialize()); 
    414       assertNotEqual(form.serialize, $('input_enabled').serialize); 
     412      this.assertEqual(Form.serialize('form'), form.serialize()); 
     413      this.assertEqual(Form.Element.serialize('input_enabled'), $('input_enabled').serialize()); 
     414      this.assertNotEqual(form.serialize, $('input_enabled').serialize); 
    415415       
    416416      Element.addMethods('INPUT',  { anInputMethod: function(input)  { return 'input'  } }); 
     
    421421      input._extendedByPrototype = select._extendedByPrototype = false; 
    422422 
    423       assert($(input).anInputMethod); 
    424       assert(!input.aSelectMethod); 
    425       assertEqual('input', input.anInputMethod()); 
    426  
    427       assert($(select).aSelectMethod); 
    428       assert(!select.anInputMethod);       
    429       assertEqual('select', select.aSelectMethod()); 
    430     }}
    431      
    432     testFormRequest: function() {with(this) { 
     423      this.assert($(input).anInputMethod); 
     424      this.assert(!input.aSelectMethod); 
     425      this.assertEqual('input', input.anInputMethod()); 
     426 
     427      this.assert($(select).aSelectMethod); 
     428      this.assert(!select.anInputMethod);       
     429      this.assertEqual('select', select.aSelectMethod()); 
     430    }
     431     
     432    testFormRequest: function() { 
    433433      request = $("form").request(); 
    434       assert($("form").hasAttribute("method")); 
    435       assert(request.url.include("fixtures/empty.js?val1=4")); 
    436       assertEqual("get", request.method); 
     434      this.assert($("form").hasAttribute("method")); 
     435      this.assert(request.url.include("fixtures/empty.js?val1=4")); 
     436      this.assertEqual("get", request.method); 
    437437       
    438438      request = $("form").request({ method: "put", parameters: {val2: "hello"} }); 
    439       assert(request.url.endsWith("fixtures/empty.js")); 
    440       assertEqual(4, request.options.parameters['val1']); 
    441       assertEqual('hello', request.options.parameters['val2']); 
    442       assertEqual("post", request.method); 
    443       assertEqual("put", request.parameters['_method']); 
     439      this.assert(request.url.endsWith("fixtures/empty.js")); 
     440      this.assertEqual(4, request.options.parameters['val1']); 
     441      this.assertEqual('hello', request.options.parameters['val2']); 
     442      this.assertEqual("post", request.method); 
     443      this.assertEqual("put", request.parameters['_method']); 
    444444 
    445445      // with empty action attribute 
    446446      request = $("ffe").request({ method: 'post' }); 
    447       assert(request.url.include("unit/form.html"), 
     447      this.assert(request.url.include("unit/form.html"), 
    448448        'wrong default action for form element with empty action attribute'); 
    449     }}
    450      
    451     testFormElementMethodsChaining: function(){ with(this) { 
     449    }
     450     
     451    testFormElementMethodsChaining: function(){ 
    452452      var methods = $w('clear activate disable enable'), 
    453453        formElements = $('form').getElements(); 
     
    455455        formElements.each(function(element){ 
    456456          var returned = element[method](); 
    457           assertIdentical(element, returned); 
    458         }); 
    459       }); 
    460     }}
    461  
    462     testSetValue: function(){ with(this) { 
     457          this.assertIdentical(element, returned); 
     458        }, this); 
     459      }, this); 
     460    }
     461 
     462    testSetValue: function(){ 
    463463      // text input 
    464464      var input = $('input_enabled'), oldValue = input.getValue(); 
    465       assertEqual(input, input.setValue('foo'), 'setValue chaining is broken'); 
    466       assertEqual('foo', input.getValue(), 'value improperly set'); 
     465      this.assertEqual(input, input.setValue('foo'), 'setValue chaining is broken'); 
     466      this.assertEqual('foo', input.getValue(), 'value improperly set'); 
    467467      input.setValue(oldValue); 
    468       assertEqual(oldValue, input.getValue(), 'value improperly restored to original'); 
     468      this.assertEqual(oldValue, input.getValue(), 'value improperly restored to original'); 
    469469 
    470470      // checkbox 
    471471      input = $('checkbox_hack'); 
    472472      input.setValue(false); 
    473       assertEqual(null, input.getValue(), 'checkbox should be unchecked'); 
     473      this.assertEqual(null, input.getValue(), 'checkbox should be unchecked'); 
    474474      input.setValue(true); 
    475       assertEqual("1", input.getValue(), 'checkbox should be checked'); 
     475      this.assertEqual("1", input.getValue(), 'checkbox should be checked'); 
    476476      // selectbox 
    477477      input = $('bigform')['vu']; 
    478478      input.setValue('3'); 
    479       assertEqual('3', input.getValue(), 'single select option improperly set'); 
     479      this.assertEqual('3', input.getValue(), 'single select option improperly set'); 
    480480      input.setValue('1'); 
    481       assertEqual('1', input.getValue()); 
     481      this.assertEqual('1', input.getValue()); 
    482482      // multiple select 
    483483      input = $('bigform')['vm[]']; 
    484484      input.setValue(['2', '3']); 
    485       assertEnumEqual(['2', '3'], input.getValue(), 
     485      this.assertEnumEqual(['2', '3'], input.getValue(), 
    486486        'multiple select options improperly set'); 
    487487      input.setValue(['1', '3']); 
    488       assertEnumEqual(['1', '3'], input.getValue()); 
    489     }} 
    490      
     488      this.assertEnumEqual(['1', '3'], input.getValue()); 
     489    } 
    491490  }); 
    492491// ]]> 
  • spinoffs/prototype/trunk/test/unit/hash.html

    r8572 r9036  
    5555   
    5656  new Test.Unit.Runner({ 
    57     testSet: function(){ with(this)
     57    testSet: function()
    5858      var h = $H({a: 'A'}) 
    5959 
    60       assertEqual('B', h.set('b', 'B')); 
    61       assertHashEqual({a: 'A', b: 'B'}, h); 
    62        
    63       assertUndefined(h.set('c')); 
    64       assertHashEqual({a: 'A', b: 'B', c: undefined}, h); 
    65     }}
    66  
    67     testGet: function(){ with(this)
     60      this.assertEqual('B', h.set('b', 'B')); 
     61      this.assertHashEqual({a: 'A', b: 'B'}, h); 
     62       
     63      this.assertUndefined(h.set('c')); 
     64      this.assertHashEqual({a: 'A', b: 'B', c: undefined}, h); 
     65    }
     66 
     67    testGet: function()
    6868      var h = $H({a: 'A'}); 
    69       assertEqual('A', h.get('a')); 
    70       assertUndefined(h.a); 
    71       assertUndefined($H({}).get('a')); 
    72     }}
    73      
    74     testUnset: function(){ with(this)
     69      this.assertEqual('A', h.get('a')); 
     70      this.assertUndefined(h.a); 
     71      this.assertUndefined($H({}).get('a')); 
     72    }
     73     
     74    testUnset: function()
    7575      var hash = $H(Fixtures.many); 
    76       assertEqual('B', hash.unset('b')); 
    77       assertHashEqual({a:'A', c: 'C', d:'D#'}, hash); 
    78       assertUndefined(hash.unset('z')); 
    79       assertHashEqual({a:'A', c: 'C', d:'D#'}, hash); 
     76      this.assertEqual('B', hash.unset('b')); 
     77      this.assertHashEqual({a:'A', c: 'C', d:'D#'}, hash); 
     78      this.assertUndefined(hash.unset('z')); 
     79      this.assertHashEqual({a:'A', c: 'C', d:'D#'}, hash); 
    8080      // not equivalent to Hash#remove 
    81       assertEqual('A', hash.unset('a', 'c')); 
    82       assertHashEqual({c: 'C', d:'D#'}, hash); 
    83     }}
    84      
    85     testToObject: function(){ with(this)
     81      this.assertEqual('A', hash.unset('a', 'c')); 
     82      this.assertHashEqual({c: 'C', d:'D#'}, hash); 
     83    }
     84     
     85    testToObject: function()
    8686      var hash = $H(Fixtures.many), object = hash.toObject(); 
    87       assertInstanceOf(Object, object); 
    88       assertHashEqual(Fixtures.many, object); 
    89       assertNotIdentical(Fixtures.many, object); 
     87      this.assertInstanceOf(Object, object); 
     88      this.assertHashEqual(Fixtures.many, object); 
     89      this.assertNotIdentical(Fixtures.many, object); 
    9090      hash.set('foo', 'bar'); 
    91       assertHashNotEqual(object, hash.toObject()); 
    92     }}
    93      
    94     testConstruct: function(){ with(this)
     91      this.assertHashNotEqual(object, hash.toObject()); 
     92    }
     93     
     94    testConstruct: function()
    9595      var object = Object.clone(Fixtures.one); 
    9696      var h = new Hash(object), h2 = $H(object); 
    97       assertInstanceOf(Hash, h); 
    98       assertInstanceOf(Hash, h2); 
    99        
    100       assertHashEqual({}, new Hash()); 
    101       assertHashEqual(object, h); 
    102       assertHashEqual(object, h2); 
     97      this.assertInstanceOf(Hash, h); 
     98      this.assertInstanceOf(Hash, h2); 
     99       
     100      this.assertHashEqual({}, new Hash()); 
     101      this.assertHashEqual(object, h); 
     102      this.assertHashEqual(object, h2); 
    103103       
    104104      h.set('foo', 'bar'); 
    105       assertHashNotEqual(object, h); 
     105      this.assertHashNotEqual(object, h); 
    106106       
    107107      var clone = $H(h); 
    108       assertInstanceOf(Hash, clone); 
    109       assertHashEqual(h, clone); 
     108      this.assertInstanceOf(Hash, clone); 
     109      this.assertHashEqual(h, clone); 
    110110      h.set('foo', 'foo'); 
    111       assertHashNotEqual(h, clone); 
    112       assertIdentical($H, Hash.from); 
    113     }}
    114      
    115     testKeys: function(){ with(this)
    116       assertEnumEqual([],               $H({}).keys()); 
    117       assertEnumEqual(['a'],            $H(Fixtures.one).keys()); 
    118       assertEnumEqual($w('a b c d'),    $H(Fixtures.many).keys().sort()); 
    119       assertEnumEqual($w('plus quad'),  $H(Fixtures.functions).keys().sort()); 
    120     }}
    121      
    122     testValues: function(){ with(this)
    123       assertEnumEqual([],             $H({}).values()); 
    124       assertEnumEqual(['A#'],         $H(Fixtures.one).values()); 
    125       assertEnumEqual($w('A B C D#'), $H(Fixtures.many).values().sort()); 
    126       assertEnumEqual($w('function function'), 
     111      this.assertHashNotEqual(h, clone); 
     112      this.assertIdentical($H, Hash.from); 
     113    }
     114     
     115    testKeys: function()
     116      this.assertEnumEqual([],               $H({}).keys()); 
     117      this.assertEnumEqual(['a'],            $H(Fixtures.one).keys()); 
     118      this.assertEnumEqual($w('a b c d'),    $H(Fixtures.many).keys().sort()); 
     119      this.assertEnumEqual($w('plus quad'),  $H(Fixtures.functions).keys().sort()); 
     120    }
     121     
     122    testValues: function()
     123      this.assertEnumEqual([],             $H({}).values()); 
     124      this.assertEnumEqual(['A#'],         $H(Fixtures.one).values()); 
     125      this.assertEnumEqual($w('A B C D#'), $H(Fixtures.many).values().sort()); 
     126      this.assertEnumEqual($w('function function'), 
    127127        $H(Fixtures.functions).values().map(function(i){ return typeof i })); 
    128       assertEqual(9, $H(Fixtures.functions).get('quad')(3)); 
    129       assertEqual(6, $H(Fixtures.functions).get('plus')(3)); 
    130     }}
    131      
    132     testIndex: function(){ with(this)
    133       assertUndefined($H().index('foo')); 
    134        
    135       assert('a', $H(Fixtures.one).index('A#')); 
    136       assert('a', $H(Fixtures.many).index('A')); 
    137       assertUndefined($H(Fixtures.many).index('Z')) 
     128      this.assertEqual(9, $H(Fixtures.functions).get('quad')(3)); 
     129      this.assertEqual(6, $H(Fixtures.functions).get('plus')(3)); 
     130    }
     131     
     132    testIndex: function()
     133      this.assertUndefined($H().index('foo')); 
     134       
     135      this.assert('a', $H(Fixtures.one).index('A#')); 
     136      this.assert('a', $H(Fixtures.many).index('A')); 
     137      this.assertUndefined($H(Fixtures.many).index('Z')) 
    138138     
    139139      var hash = $H({a:1,b:'2',c:1}); 
    140       assert(['a','c'].include(hash.index(1))); 
    141       assertUndefined(hash.index('1')); 
    142     }}
    143        
    144     testMerge: function(){ with(this)
     140      this.assert(['a','c'].include(hash.index(1))); 
     141      this.assertUndefined(hash.index('1')); 
     142    }
     143       
     144    testMerge: function()
    145145      var h = $H(Fixtures.many); 
    146       assertNotIdentical(h, h.merge()); 
    147       assertNotIdentical(h, h.merge({})); 
    148       assertInstanceOf(Hash, h.merge()); 
    149       assertInstanceOf(Hash, h.merge({})); 
    150       assertHashEqual(h, h.merge()); 
    151       assertHashEqual(h, h.merge({})); 
    152       assertHashEqual(h, h.merge($H())); 
    153       assertHashEqual({a:'A',  b:'B', c:'C', d:'D#', aaa:'AAA' }, h.merge({aaa: 'AAA'})); 
    154       assertHashEqual({a:'A#', b:'B', c:'C', d:'D#' }, h.merge(Fixtures.one)); 
    155     }}
    156      
    157     testUpdate: function(){ with(this)
     146      this.assertNotIdentical(h, h.merge()); 
     147      this.assertNotIdentical(h, h.merge({})); 
     148      this.assertInstanceOf(Hash, h.merge()); 
     149      this.assertInstanceOf(Hash, h.merge({})); 
     150      this.assertHashEqual(h, h.merge()); 
     151      this.assertHashEqual(h, h.merge({})); 
     152      this.assertHashEqual(h, h.merge($H())); 
     153      this.assertHashEqual({a:'A',  b:'B', c:'C', d:'D#', aaa:'AAA' }, h.merge({aaa: 'AAA'})); 
     154      this.assertHashEqual({a:'A#', b:'B', c:'C', d:'D#' }, h.merge(Fixtures.one)); 
     155    }
     156     
     157    testUpdate: function()
    158158      var h = $H(Fixtures.many); 
    159       assertIdentical(h, h.update()); 
    160       assertIdentical(h, h.update({})); 
    161       assertHashEqual(h, h.update()); 
    162       assertHashEqual(h, h.update({})); 
    163       assertHashEqual(h, h.update($H())); 
    164       assertHashEqual({a:'A',  b:'B', c:'C', d:'D#', aaa:'AAA' }, h.update({aaa: 'AAA'})); 
    165       assertHashEqual({a:'A#', b:'B', c:'C', d:'D#', aaa:'AAA' }, h.update(Fixtures.one)); 
    166     }}
    167      
    168     testToQueryString: function(){ with(this)
    169       assertEqual('',                   $H({}).toQueryString()); 
    170       assertEqual('a%23=A',             $H({'a#': 'A'}).toQueryString()); 
    171       assertEqual('a=A%23',             $H(Fixtures.one).toQueryString()); 
    172       assertEqual('a=A&b=B&c=C&d=D%23', $H(Fixtures.many).toQueryString()); 
    173       assertEqual("a=b&c",              $H(Fixtures.value_undefined).toQueryString()); 
    174       assertEqual("a=b&c",              $H("a=b&c".toQueryParams()).toQueryString()); 
    175       assertEqual("a=b&c=",             $H(Fixtures.value_null).toQueryString()); 
    176       assertEqual("a=b&c=0",            $H(Fixtures.value_zero).toQueryString()); 
    177       assertEqual("color=r&color=g&color=b", $H(Fixtures.multiple).toQueryString()); 
    178       assertEqual("color=r&color=&color=g&color&color=0", $H(Fixtures.multiple_nil).toQueryString()); 
    179       assertEqual("color=&color",       $H(Fixtures.multiple_all_nil).toQueryString()); 
    180       assertEqual("",                   $H(Fixtures.multiple_empty).toQueryString()); 
    181       assertEqual("stuff%5B%5D=%24&stuff%5B%5D=a&stuff%5B%5D=%3B", $H(Fixtures.multiple_special).toQueryString()); 
    182       assertHashEqual(Fixtures.multiple_special, $H(Fixtures.multiple_special).toQueryString().toQueryParams()); 
    183       assertIdentical(Object.toQueryString, Hash.toQueryString); 
    184     }}
    185      
    186     testInspect: function(){ with(this)
    187       assertEqual('#<Hash:{}>',              $H({}).inspect()); 
    188       assertEqual("#<Hash:{'a': 'A#'}>",     $H(Fixtures.one).inspect()); 
    189       assertEqual("#<Hash:{'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D#'}>", $H(Fixtures.many).inspect()); 
    190     }}
    191  
    192     testClone: function(){ with(this)
     159      this.assertIdentical(h, h.update()); 
     160      this.assertIdentical(h, h.update({})); 
     161      this.assertHashEqual(h, h.update()); 
     162      this.assertHashEqual(h, h.update({})); 
     163      this.assertHashEqual(h, h.update($H())); 
     164      this.assertHashEqual({a:'A',  b:'B', c:'C', d:'D#', aaa:'AAA' }, h.update({aaa: 'AAA'})); 
     165      this.assertHashEqual({a:'A#', b:'B', c:'C', d:'D#', aaa:'AAA' }, h.update(Fixtures.one)); 
     166    }
     167     
     168    testToQueryString: function()
     169      this.assertEqual('',                   $H({}).toQueryString()); 
     170      this.assertEqual('a%23=A',             $H({'a#': 'A'}).toQueryString()); 
     171      this.assertEqual('a=A%23',             $H(Fixtures.one).toQueryString()); 
     172      this.assertEqual('a=A&b=B&c=C&d=D%23', $H(Fixtures.many).toQueryString()); 
     173      this.assertEqual("a=b&c",              $H(Fixtures.value_undefined).toQueryString()); 
     174      this.assertEqual("a=b&c",              $H("a=b&c".toQueryParams()).toQueryString()); 
     175      this.assertEqual("a=b&c=",             $H(Fixtures.value_null).toQueryString()); 
     176      this.assertEqual("a=b&c=0",            $H(Fixtures.value_zero).toQueryString()); 
     177      this.assertEqual("color=r&color=g&color=b", $H(Fixtures.multiple).toQueryString()); 
     178      this.assertEqual("color=r&color=&color=g&color&color=0", $H(Fixtures.multiple_nil).toQueryString()); 
     179      this.assertEqual("color=&color",       $H(Fixtures.multiple_all_nil).toQueryString()); 
     180      this.assertEqual("",                   $H(Fixtures.multiple_empty).toQueryString()); 
     181      this.assertEqual("stuff%5B%5D=%24&stuff%5B%5D=a&stuff%5B%5D=%3B", $H(Fixtures.multiple_special).toQueryString()); 
     182      this.assertHashEqual(Fixtures.multiple_special, $H(Fixtures.multiple_special).toQueryString().toQueryParams()); 
     183      this.assertIdentical(Object.toQueryString, Hash.toQueryString); 
     184    }
     185     
     186    testInspect: function()
     187      this.assertEqual('#<Hash:{}>',              $H({}).inspect()); 
     188      this.assertEqual("#<Hash:{'a': 'A#'}>",     $H(Fixtures.one).inspect()); 
     189      this.assertEqual("#<Hash:{'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D#'}>", $H(Fixtures.many).inspect()); 
     190    }
     191 
     192    testClone: function()
    193193      var h = $H(Fixtures.many); 
    194       assertHashEqual(h, h.clone()); 
    195       assertInstanceOf(Hash, h.clone()); 
    196       assertNotIdentical(h, h.clone()); 
    197     }}
    198      
    199     testToJSON: function(){ with(this)
    200       assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
     194      this.assertHashEqual(h, h.clone()); 
     195      this.assertInstanceOf(Hash, h.clone()); 
     196      this.assertNotIdentical(h, h.clone()); 
     197    }
     198     
     199    testToJSON: function()
     200      this.assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    201201        $H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}).toJSON()); 
    202     }}
    203      
    204     testAbilityToContainAnyKey: function(){ with(this)
     202    }
     203     
     204    testAbilityToContainAnyKey: function()
    205205      var h = $H({ _each: 'E', map: 'M', keys: 'K', pluck: 'P', unset: 'U' }); 
    206       assertEnumEqual($w('_each keys map pluck unset'), h.keys().sort()); 
    207       assertEqual('U', h.unset('unset')); 
    208       assertHashEqual({ _each: 'E', map: 'M', keys: 'K', pluck: 'P' }, h); 
    209     }}
    210      
    211     testHashToTemplateReplacements: function() { with(this) { 
     206      this.assertEnumEqual($w('_each keys map pluck unset'), h.keys().sort()); 
     207      this.assertEqual('U', h.unset('unset')); 
     208      this.assertHashEqual({ _each: 'E', map: 'M', keys: 'K', pluck: 'P' }, h); 
     209    }
     210     
     211    testHashToTemplateReplacements: function() { 
    212212      var template = new Template("#{a} #{b}"), hash = $H({ a: "hello", b: "world" }); 
    213       assertEqual("hello world", template.evaluate(hash.toObject())); 
    214       assertEqual("hello world", template.evaluate(hash)); 
    215       assertEqual("hello", "#{a}".interpolate(hash)); 
    216     }}
    217      
    218     testPreventIterationOverShadowedProperties: function() { with(this) { 
     213      this.assertEqual("hello world", template.evaluate(hash.toObject())); 
     214      this.assertEqual("hello world", template.evaluate(hash)); 
     215      this.assertEqual("hello", "#{a}".interpolate(hash)); 
     216    }
     217     
     218    testPreventIterationOverShadowedProperties: function() { 
    219219      // redundant now that object is systematically cloned. 
    220220      var FooMaker = function(value) { 
     
    223223      FooMaker.prototype.key = 'foo'; 
    224224      var foo = new FooMaker('bar'); 
    225       assertEqual("key=bar", new Hash(foo).toQueryString()); 
    226       assertEqual("key=bar", new Hash(new Hash(foo)).toQueryString()); 
    227     }} 
     225      this.assertEqual("key=bar", new Hash(foo).toQueryString()); 
     226      this.assertEqual("key=bar", new Hash(new Hash(foo)).toQueryString()); 
     227    } 
    228228     
    229229  }); 
  • spinoffs/prototype/trunk/test/unit/number.html

    r8572 r9036  
    3030  new Test.Unit.Runner({ 
    3131     
    32     testNumberMathMethods: function() {with(this) { 
    33       assertEqual(1, (0.9).round()); 
    34       assertEqual(-2, (-1.9).floor()); 
    35       assertEqual(-1, (-1.9).ceil()); 
     32    testNumberMathMethods: function() { 
     33      this.assertEqual(1, (0.9).round()); 
     34      this.assertEqual(-2, (-1.9).floor()); 
     35      this.assertEqual(-1, (-1.9).ceil()); 
    3636 
    37       $w('abs floor round ceil').each( function(method)
    38         assertEqual(Math[method](Math.PI), Math.PI[method]()); 
    39       }); 
    40     }}
     37      $w('abs floor round ceil').each(function(method)
     38        this.assertEqual(Math[method](Math.PI), Math.PI[method]()); 
     39      }, this); 
     40    }
    4141 
    42     testNumberToColorPart: function() {with(this) { 
    43       assertEqual('00', (0).toColorPart()); 
    44       assertEqual('0a', (10).toColorPart()); 
    45       assertEqual('ff', (255).toColorPart()); 
    46     }}
     42    testNumberToColorPart: function() { 
     43      this.assertEqual('00', (0).toColorPart()); 
     44      this.assertEqual('0a', (10).toColorPart()); 
     45      this.assertEqual('ff', (255).toColorPart()); 
     46    }
    4747 
    48     testNumberToPaddedString: function() {with(this) { 
    49       assertEqual('00', (0).toPaddedString(2, 16)); 
    50       assertEqual('0a', (10).toPaddedString(2, 16)); 
    51       assertEqual('ff', (255).toPaddedString(2, 16)); 
    52       assertEqual('000', (0).toPaddedString(3)); 
    53       assertEqual('010', (10).toPaddedString(3)); 
    54       assertEqual('100', (100).toPaddedString(3)); 
    55       assertEqual('1000', (1000).toPaddedString(3)); 
    56     }}
     48    testNumberToPaddedString: function() { 
     49      this.assertEqual('00', (0).toPaddedString(2, 16)); 
     50      this.assertEqual('0a', (10).toPaddedString(2, 16)); 
     51      this.assertEqual('ff', (255).toPaddedString(2, 16)); 
     52      this.assertEqual('000', (0).toPaddedString(3)); 
     53      this.assertEqual('010', (10).toPaddedString(3)); 
     54      this.assertEqual('100', (100).toPaddedString(3)); 
     55      this.assertEqual('1000', (1000).toPaddedString(3)); 
     56    }
    5757 
    58     testNumberToJSON: function() {with(this) { 
    59       assertEqual('null', Number.NaN.toJSON()); 
    60       assertEqual('0', (0).toJSON()); 
    61       assertEqual('-293', (-293).toJSON()); 
    62     }} 
     58    testNumberToJSON: function() { 
     59      this.assertEqual('null', Number.NaN.toJSON()); 
     60      this.assertEqual('0', (0).toJSON()); 
     61      this.assertEqual('-293', (-293).toJSON()); 
     62    } 
    6363 
    6464  }); 
  • spinoffs/prototype/trunk/test/unit/position.html

    r8572 r9036  
    5454    }, 
    5555     
    56     testPrepare: function() {with(this) { 
     56    testPrepare: function() { 
    5757      Position.prepare(); 
    58       assertEqual(0, Position.deltaX); 
    59       assertEqual(0, Position.deltaY); 
     58      this.assertEqual(0, Position.deltaX); 
     59      this.assertEqual(0, Position.deltaY); 
    6060      scrollTo(20,30); 
    6161      Position.prepare(); 
    62       assertEqual(20, Position.deltaX); 
    63       assertEqual(30, Position.deltaY); 
    64     }}
     62      this.assertEqual(20, Position.deltaX); 
     63      this.assertEqual(30, Position.deltaY); 
     64    }
    6565     
    66     testWithin: function() {with(this) { 
     66    testWithin: function() { 
    6767      [true, false].each(function(withScrollOffsets) { 
    6868        Position.includeScrollOffsets = withScrollOffsets; 
    69         assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top'); 
    70         assert(Position.within($('body_absolute'), 10, 10), 'left/top corner'); 
    71         assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner'); 
    72         assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom'); 
    73       }); 
     69        this.assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top'); 
     70        this.assert(Position.within($('body_absolute'), 10, 10), 'left/top corner'); 
     71        this.assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner'); 
     72        this.assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom'); 
     73      }, this); 
    7474       
    7575      scrollTo(20,30); 
    7676      Position.prepare(); 
    7777      Position.includeScrollOffsets = true; 
    78       assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top'); 
    79       assert(Position.within($('body_absolute'), 10, 10), 'left/top corner'); 
    80       assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner'); 
    81       assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom'); 
    82     }} 
    83      
     78      this.assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top'); 
     79      this.assert(Position.within($('body_absolute'), 10, 10), 'left/top corner'); 
     80      this.assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner'); 
     81      this.assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom'); 
     82    } 
    8483  }); 
    8584 
  • spinoffs/prototype/trunk/test/unit/range.html

    r8572 r9036  
    2929  new Test.Unit.Runner({ 
    3030     
    31     testInclude: function() {with(this) { 
    32       assert(!$R(0, 0, true).include(0)); 
    33       assert($R(0, 0, false).include(0)); 
     31    testInclude: function() { 
     32      this.assert(!$R(0, 0, true).include(0)); 
     33      this.assert($R(0, 0, false).include(0)); 
    3434 
    35       assert($R(0, 5, true).include(0)); 
    36       assert($R(0, 5, true).include(4)); 
    37       assert(!$R(0, 5, true).include(5)); 
     35      this.assert($R(0, 5, true).include(0)); 
     36      this.assert($R(0, 5, true).include(4)); 
     37      this.assert(!$R(0, 5, true).include(5)); 
    3838 
    39       assert($R(0, 5, false).include(0)); 
    40       assert($R(0, 5, false).include(5)); 
    41       assert(!$R(0, 5, false).include(6)); 
    42     }}
     39      this.assert($R(0, 5, false).include(0)); 
     40      this.assert($R(0, 5, false).include(5)); 
     41      this.assert(!$R(0, 5, false).include(6)); 
     42    }
    4343 
    44     testEach: function() {with(this) { 
     44    testEach: function() { 
    4545      var results = []; 
    4646      $R(0, 0, true).each(function(value) { 
     
    4848      }); 
    4949 
    50       assertEnumEqual([], results); 
     50      this.assertEnumEqual([], results); 
    5151 
    5252      results = []; 
     
    5555      }); 
    5656 
    57       assertEnumEqual([0, 1, 2, 3], results); 
    58     }}
     57      this.assertEnumEqual([0, 1, 2, 3], results); 
     58    }
    5959 
    60     testAny: function() {with(this) { 
    61       assert(!$R(1, 1, true).any()); 
    62       assert($R(0, 3, false).any(function(value) { 
     60    testAny: function() { 
     61      this.assert(!$R(1, 1, true).any()); 
     62      this.assert($R(0, 3, false).any(function(value) { 
    6363        return value == 3; 
    6464      })); 
    65     }}
     65    }
    6666 
    67     testAll: function() {with(this) { 
    68       assert($R(1, 1, true).all()); 
    69       assert($R(0, 3, false).all(function(value) { 
     67    testAll: function() { 
     68      this.assert($R(1, 1, true).all()); 
     69      this.assert($R(0, 3, false).all(function(value) { 
    7070        return value <= 3; 
    7171      })); 
    72     }}
     72    }
    7373 
    74     testToArray: function() {with(this) { 
    75       assertEnumEqual([], $R(0, 0, true).toArray()); 
    76       assertEnumEqual([0], $R(0, 0, false).toArray()); 
    77       assertEnumEqual([0], $R(0, 1, true).toArray()); 
    78       assertEnumEqual([0, 1], $R(0, 1, false).toArray()); 
    79       assertEnumEqual([-3, -2, -1, 0, 1, 2], $R(-3, 3, true).toArray()); 
    80       assertEnumEqual([-3, -2, -1, 0, 1, 2, 3], $R(-3, 3, false).toArray()); 
    81     }}
     74    testToArray: function() { 
     75      this.assertEnumEqual([], $R(0, 0, true).toArray()); 
     76      this.assertEnumEqual([0], $R(0, 0, false).toArray()); 
     77      this.assertEnumEqual([0], $R(0, 1, true).toArray()); 
     78      this.assertEnumEqual([0, 1], $R(0, 1, false).toArray()); 
     79      this.assertEnumEqual([-3, -2, -1, 0, 1, 2], $R(-3, 3, true).toArray()); 
     80      this.assertEnumEqual([-3, -2, -1, 0, 1, 2, 3], $R(-3, 3, false).toArray()); 
     81    }
    8282     
    83     testDefaultsToNotExclusive: function() {with(this) { 
    84       assertEnumEqual( 
    85         $R(-3,3), $R(-3,3,false) 
    86       ); 
    87     }} 
    88      
     83    testDefaultsToNotExclusive: function() { 
     84      this.assertEnumEqual($R(-3,3), $R(-3,3,false)); 
     85    } 
    8986  }); 
    9087// ]]> 
  • spinoffs/prototype/trunk/test/unit/selector.html

    r8797 r9036  
    104104  new Test.Unit.Runner({ 
    105105     
    106     testSelectorWithTagName: function() {with(this) { 
    107       assertEnumEqual($A(document.getElementsByTagName('li')), $$('li')); 
    108       assertEnumEqual([$('strong')], $$('strong')); 
    109       assertEnumEqual([], $$('nonexistent')); 
     106    testSelectorWithTagName: function() { 
     107      this.assertEnumEqual($A(document.getElementsByTagName('li')), $$('li')); 
     108      this.assertEnumEqual([$('strong')], $$('strong')); 
     109      this.assertEnumEqual([], $$('nonexistent')); 
    110110       
    111111      var allNodes = $A(document.getElementsByTagName('*')).select( function(node) { 
    112112        return node.tagName !== '!'; 
    113113      });       
    114       assertEnumEqual(allNodes, $$('*')); 
    115     }}
    116      
    117     testSelectorWithId: function() {with(this) { 
    118       assertEnumEqual([$('fixtures')], $$('#fixtures')); 
    119       assertEnumEqual([], $$('#nonexistent')); 
    120       assertEnumEqual([$('troubleForm')], $$('#troubleForm')); 
    121     }}
    122      
    123     testSelectorWithClassName: function() {with(this) { 
    124       assertEnumEqual($('p', 'link_1', 'item_1'), $$('.first')); 
    125       assertEnumEqual([], $$('.second')); 
    126     }}
    127      
    128     testSelectorWithTagNameAndId: function() {with(this) { 
    129       assertEnumEqual([$('strong')], $$('strong#strong')); 
    130       assertEnumEqual([], $$('p#strong')); 
    131     }}
    132      
    133     testSelectorWithTagNameAndClassName: function() {with(this) { 
    134       assertEnumEqual($('link_1', 'link_2'), $$('a.internal')); 
    135       assertEnumEqual([$('link_2')], $$('a.internal.highlight')); 
    136       assertEnumEqual([$('link_2')], $$('a.highlight.internal')); 
    137       assertEnumEqual([], $$('a.highlight.internal.nonexistent')); 
    138     }}
    139      
    140     testSelectorWithIdAndClassName: function() {with(this) { 
    141       assertEnumEqual([$('link_2')], $$('#link_2.internal')); 
    142       assertEnumEqual([$('link_2')], $$('.internal#link_2')); 
    143       assertEnumEqual([$('link_2')], $$('#link_2.internal.highlight')); 
    144       assertEnumEqual([], $$('#link_2.internal.nonexistent')); 
    145     }}
    146      
    147     testSelectorWithTagNameAndIdAndClassName: function() {with(this) { 
    148       assertEnumEqual([$('link_2')], $$('a#link_2.internal')); 
    149       assertEnumEqual([$('link_2')], $$('a.internal#link_2')); 
    150       assertEnumEqual([$('item_1')], $$('li#item_1.first')); 
    151       assertEnumEqual([], $$('li#item_1.nonexistent')); 
    152       assertEnumEqual([], $$('li#item_1.first.nonexistent')); 
    153     }}
    154      
    155     test$$MatchesAncestryWithTokensSeparatedByWhitespace: function() {with(this) { 
    156       assertEnumEqual($('em2', 'em', 'span'), $$('#fixtures a *')); 
    157       assertEnumEqual([$('p')], $$('div#fixtures p')); 
    158     }}
    159      
    160     test$$CombinesResultsWhenMultipleExpressionsArePassed: function() {with(this) { 
    161       assertEnumEqual($('link_1', 'link_2', 'item_1', 'item_2', 'item_3'), $$('#p a', ' ul#list li ')); 
    162     }}
    163  
    164     testSelectorWithTagNameAndAttributeExistence: function() {with(this) { 
    165       assertEnumEqual($$('#fixtures h1'), $$('h1[class]'), 'h1[class]'); 
    166       assertEnumEqual($$('#fixtures h1'), $$('h1[CLASS]'), 'h1[CLASS]'); 
    167       assertEnumEqual([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]'); 
    168     }}
    169      
    170     testSelectorWithTagNameAndSpecificAttributeValue: function() {with(this) { 
    171       assertEnumEqual($('link_1', 'link_2', 'link_3'), $$('a[href="#"]')); 
    172       assertEnumEqual($('link_1', 'link_2', 'link_3'), $$('a[href=#]')); 
    173     }}
    174      
    175     testSelectorWithTagNameAndWhitespaceTokenizedAttributeValue: function() {with(this) { 
    176       assertEnumEqual($('link_1', 'link_2'), $$('a[class~="internal"]')); 
    177       assertEnumEqual($('link_1', 'link_2'), $$('a[class~=internal]')); 
    178     }}
    179      
    180     testSelectorWithAttributeAndNoTagName: function() {with(this) { 
    181       assertEnumEqual($(document.body).select('a[href]'), $(document.body).select('[href]')); 
    182       assertEnumEqual($$('a[class~="internal"]'), $$('[class~=internal]')); 
    183       assertEnumEqual($$('*[id]'), $$('[id]')); 
    184       assertEnumEqual($('checked_radio', 'unchecked_radio'), $$('[type=radio]')); 
    185       assertEnumEqual($$('*[type=checkbox]'), $$('[type=checkbox]')); 
    186       assertEnumEqual($('with_title', 'commaParent'), $$('[title]')); 
    187       assertEnumEqual($$('#troubleForm *[type=radio]'), $$('#troubleForm [type=radio]')); 
    188       assertEnumEqual($$('#troubleForm *[type]'), $$('#troubleForm [type]')); 
    189     }}
    190      
    191     testSelectorWithUniversalAndHyphenTokenizedAttributeValue: function() {with(this) { 
    192       assertEnumEqual([$('item_3')], $$('*[xml:lang|="es"]')); 
    193       assertEnumEqual([$('item_3')], $$('*[xml:lang|="ES"]')); 
    194     }}
    195      
    196     testSelectorWithTagNameAndNegatedAttributeValue: function() {with(this) { 
    197       assertEnumEqual([], $$('a[href!=#]')); 
    198     }}
    199  
    200     testSelectorWithBracketAttributeValue: function() {with(this) { 
    201       assertEnumEqual($('chk_1', 'chk_2'), $$('#troubleForm2 input[name="brackets[5][]"]')); 
    202       assertEnumEqual([$('chk_1')], $$('#troubleForm2 input[name="brackets[5][]"]:checked')); 
    203       assertEnumEqual([$('chk_2')], $$('#troubleForm2 input[name="brackets[5][]"][value=2]')); 
    204       assertEnumEqual([], $$('#troubleForm2 input[name=brackets[5][]]')); 
    205     }}
    206      
    207     test$$WithNestedAttributeSelectors: function() {with(this) { 
    208       assertEnumEqual([$('strong')], $$('div[style] p[id] strong')); 
    209     }}
    210      
    211     testSelectorWithMultipleConditions: function() {with(this) { 
    212       assertEnumEqual([$('link_3')], $$('a[class~=external][href="#"]')); 
    213       assertEnumEqual([], $$('a[class~=external][href!="#"]')); 
    214     }}
    215      
    216     testSelectorMatchElements: function() {with(this) { 
    217       assertElementsMatch(Selector.matchElements($('list').descendants(), 'li'), '#item_1', '#item_2', '#item_3'); 
    218       assertElementsMatch(Selector.matchElements($('fixtures').descendants(), 'a.internal'), '#link_1', '#link_2'); 
    219       assertEnumEqual([], Selector.matchElements($('fixtures').descendants(), 'p.last')); 
    220       assertElementsMatch(Selector.matchElements($('fixtures').descendants(), '.inexistant, a.internal'), '#link_1', '#link_2'); 
    221     }}
    222      
    223     testSelectorFindElement: function() {with(this) { 
    224       assertElementMatches(Selector.findElement($('list').descendants(), 'li'), 'li#item_1.first'); 
    225       assertElementMatches(Selector.findElement($('list').descendants(), 'li', 1), 'li#item_2'); 
    226       assertElementMatches(Selector.findElement($('list').descendants(), 'li#item_3'), 'li'); 
    227       assertEqual(undefined, Selector.findElement($('list').descendants(), 'em')); 
    228     }}
    229      
    230     testElementMatch: function() {with(this) { 
     114      this.assertEnumEqual(allNodes, $$('*')); 
     115    }
     116     
     117    testSelectorWithId: function() { 
     118      this.assertEnumEqual([$('fixtures')], $$('#fixtures')); 
     119      this.assertEnumEqual([], $$('#nonexistent')); 
     120      this.assertEnumEqual([$('troubleForm')], $$('#troubleForm')); 
     121    }
     122     
     123    testSelectorWithClassName: function() { 
     124      this.assertEnumEqual($('p', 'link_1', 'item_1'), $$('.first')); 
     125      this.assertEnumEqual([], $$('.second')); 
     126    }
     127     
     128    testSelectorWithTagNameAndId: function() { 
     129      this.assertEnumEqual([$('strong')], $$('strong#strong')); 
     130      this.assertEnumEqual([], $$('p#strong')); 
     131    }
     132     
     133    testSelectorWithTagNameAndClassName: function() { 
     134      this.assertEnumEqual($('link_1', 'link_2'), $$('a.internal')); 
     135      this.assertEnumEqual([$('link_2')], $$('a.internal.highlight')); 
     136      this.assertEnumEqual([$('link_2')], $$('a.highlight.internal')); 
     137      this.assertEnumEqual([], $$('a.highlight.internal.nonexistent')); 
     138    }
     139     
     140    testSelectorWithIdAndClassName: function() { 
     141      this.assertEnumEqual([$('link_2')], $$('#link_2.internal')); 
     142      this.assertEnumEqual([$('link_2')], $$('.internal#link_2')); 
     143      this.assertEnumEqual([$('link_2')], $$('#link_2.internal.highlight')); 
     144      this.assertEnumEqual([], $$('#link_2.internal.nonexistent')); 
     145    }
     146     
     147    testSelectorWithTagNameAndIdAndClassName: function() { 
     148      this.assertEnumEqual([$('link_2')], $$('a#link_2.internal')); 
     149      this.assertEnumEqual([$('link_2')], $$('a.internal#link_2')); 
     150      this.assertEnumEqual([$('item_1')], $$('li#item_1.first')); 
     151      this.assertEnumEqual([], $$('li#item_1.nonexistent')); 
     152      this.assertEnumEqual([], $$('li#item_1.first.nonexistent')); 
     153    }
     154     
     155    test$$MatchesAncestryWithTokensSeparatedByWhitespace: function() { 
     156      this.assertEnumEqual($('em2', 'em', 'span'), $$('#fixtures a *')); 
     157      this.assertEnumEqual([$('p')], $$('div#fixtures p')); 
     158    }
     159     
     160    test$$CombinesResultsWhenMultipleExpressionsArePassed: function() { 
     161      this.assertEnumEqual($('link_1', 'link_2', 'item_1', 'item_2', 'item_3'), $$('#p a', ' ul#list li ')); 
     162    }
     163 
     164    testSelectorWithTagNameAndAttributeExistence: function() { 
     165      this.assertEnumEqual($$('#fixtures h1'), $$('h1[class]'), 'h1[class]'); 
     166      this.assertEnumEqual($$('#fixtures h1'), $$('h1[CLASS]'), 'h1[CLASS]'); 
     167      this.assertEnumEqual([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]'); 
     168    }
     169     
     170    testSelectorWithTagNameAndSpecificAttributeValue: function() { 
     171      this.assertEnumEqual($('link_1', 'link_2', 'link_3'), $$('a[href="#"]')); 
     172      this.assertEnumEqual($('link_1', 'link_2', 'link_3'), $$('a[href=#]')); 
     173    }
     174     
     175    testSelectorWithTagNameAndWhitespaceTokenizedAttributeValue: function() { 
     176      this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~="internal"]')); 
     177      this.assertEnumEqual($('link_1', 'link_2'), $$('a[class~=internal]')); 
     178    }
     179     
     180    testSelectorWithAttributeAndNoTagName: function() { 
     181      this.assertEnumEqual($(document.body).select('a[href]'), $(document.body).select('[href]')); 
     182      this.assertEnumEqual($$('a[class~="internal"]'), $$('[class~=internal]')); 
     183      this.assertEnumEqual($$('*[id]'), $$('[id]')); 
     184      this.assertEnumEqual($('checked_radio', 'unchecked_radio'), $$('[type=radio]')); 
     185      this.assertEnumEqual($$('*[type=checkbox]'), $$('[type=checkbox]')); 
     186      this.assertEnumEqual($('with_title', 'commaParent'), $$('[title]')); 
     187      this.assertEnumEqual($$('#troubleForm *[type=radio]'), $$('#troubleForm [type=radio]')); 
     188      this.assertEnumEqual($$('#troubleForm *[type]'), $$('#troubleForm [type]')); 
     189    }
     190     
     191    testSelectorWithUniversalAndHyphenTokenizedAttributeValue: function() { 
     192      this.assertEnumEqual([$('item_3')], $$('*[xml:lang|="es"]')); 
     193      this.assertEnumEqual([$('item_3')], $$('*[xml:lang|="ES"]')); 
     194    }
     195     
     196    testSelectorWithTagNameAndNegatedAttributeValue: function() { 
     197      this.assertEnumEqual([], $$('a[href!=#]')); 
     198    }
     199 
     200    testSelectorWithBracketAttributeValue: function() { 
     201      this.assertEnumEqual($('chk_1', 'chk_2'), $$('#troubleForm2 input[name="brackets[5][]"]')); 
     202      this.assertEnumEqual([$('chk_1')], $$('#troubleForm2 input[name="brackets[5][]"]:checked')); 
     203      this.assertEnumEqual([$('chk_2')], $$('#troubleForm2 input[name="brackets[5][]"][value=2]')); 
     204      this.assertEnumEqual([], $$('#troubleForm2 input[name=brackets[5][]]')); 
     205    }
     206     
     207    test$$WithNestedAttributeSelectors: function() { 
     208      this.assertEnumEqual([$('strong')], $$('div[style] p[id] strong')); 
     209    }
     210     
     211    testSelectorWithMultipleConditions: function() { 
     212      this.assertEnumEqual([$('link_3')], $$('a[class~=external][href="#"]')); 
     213      this.assertEnumEqual([], $$('a[class~=external][href!="#"]')); 
     214    }
     215     
     216    testSelectorMatchElements: function() { 
     217      this.assertElementsMatch(Selector.matchElements($('list').descendants(), 'li'), '#item_1', '#item_2', '#item_3'); 
     218      this.assertElementsMatch(Selector.matchElements($('fixtures').descendants(), 'a.internal'), '#link_1', '#link_2'); 
     219      this.assertEnumEqual([], Selector.matchElements($('fixtures').descendants(), 'p.last')); 
     220      this.assertElementsMatch(Selector.matchElements($('fixtures').descendants(), '.inexistant, a.internal'), '#link_1', '#link_2'); 
     221    }
     222     
     223    testSelectorFindElement: function() { 
     224      this.assertElementMatches(Selector.findElement($('list').descendants(), 'li'), 'li#item_1.first'); 
     225      this.assertElementMatches(Selector.findElement($('list').descendants(), 'li', 1), 'li#item_2'); 
     226      this.assertElementMatches(Selector.findElement($('list').descendants(), 'li#item_3'), 'li'); 
     227      this.assertEqual(undefined, Selector.findElement($('list').descendants(), 'em')); 
     228    }
     229     
     230    testElementMatch: function() { 
    231231      var span = $('dupL1'); 
    232232       
    233233      // tests that should pass 
    234       assert(span.match('span')); 
    235       assert(span.match('span#dupL1')); 
    236       assert(span.match('div > span'), 'child combinator'); 
    237       assert(span.match('#dupContainer span'), 'descendant combinator');       
    238       assert(span.match('#dupL1'), 'ID only'); 
    239       assert(span.match('span.span_foo'), 'class name 1'); 
    240       assert(span.match('span.span_bar'), 'class name 2'); 
    241       assert(span.match('span:first-child'), 'first-child pseudoclass'); 
    242        
    243       assert(!span.match('span.span_wtf'), 'bogus class name'); 
    244       assert(!span.match('#dupL2'), 'different ID'); 
    245       assert(!span.match('div'), 'different tag name'); 
    246       assert(!span.match('span span'), 'different ancestry'); 
    247       assert(!span.match('span > span'), 'different parent'); 
    248       assert(!span.match('span:nth-child(5)'), 'different pseudoclass'); 
    249        
    250       assert(!$('link_2').match('a[rel^=external]')); 
    251       assert($('link_1').match('a[rel^=external]')); 
    252       assert($('link_1').match('a[rel^="external"]')); 
    253       assert($('link_1').match("a[rel^='external']")); 
    254        
    255       assert(span.match({ match: function(element) { return true }}), 'custom selector'); 
    256       assert(!span.match({ match: function(element) { return false }}), 'custom selector'); 
    257     }}
    258  
    259     testSelectorWithSpaceInAttributeValue: function() {with(this) { 
    260       assertEnumEqual([$('with_title')], $$('cite[title="hello world!"]')); 
    261     }}
     234      this.assert(span.match('span')); 
     235      this.assert(span.match('span#dupL1')); 
     236      this.assert(span.match('div > span'), 'child combinator'); 
     237      this.assert(span.match('#dupContainer span'), 'descendant combinator');       
     238      this.assert(span.match('#dupL1'), 'ID only'); 
     239      this.assert(span.match('span.span_foo'), 'class name 1'); 
     240      this.assert(span.match('span.span_bar'), 'class name 2'); 
     241      this.assert(span.match('span:first-child'), 'first-child pseudoclass'); 
     242       
     243      this.assert(!span.match('span.span_wtf'), 'bogus class name'); 
     244      this.assert(!span.match('#dupL2'), 'different ID'); 
     245      this.assert(!span.match('div'), 'different tag name'); 
     246      this.assert(!span.match('span span'), 'different ancestry'); 
     247      this.assert(!span.match('span > span'), 'different parent'); 
     248      this.assert(!span.match('span:nth-child(5)'), 'different pseudoclass'); 
     249       
     250      this.assert(!$('link_2').match('a[rel^=external]')); 
     251      this.assert($('link_1').match('a[rel^=external]')); 
     252      this.assert($('link_1').match('a[rel^="external"]')); 
     253      this.assert($('link_1').match("a[rel^='external']")); 
     254       
     255      this.assert(span.match({ match: function(element) { return true }}), 'custom selector'); 
     256      this.assert(!span.match({ match: function(element) { return false }}), 'custom selector'); 
     257    }
     258 
     259    testSelectorWithSpaceInAttributeValue: function() { 
     260      this.assertEnumEqual([$('with_title')], $$('cite[title="hello world!"]')); 
     261    }
    262262     
    263263    // AND NOW COME THOSE NEW TESTS AFTER ANDREW'S REWRITE! 
    264264 
    265     testSelectorWithNamespacedAttributes: function() { with(this) { 
     265    testSelectorWithNamespacedAttributes: function() { 
    266266      if (Prototype.BrowserFeatures.XPath) { 
    267         assertUndefined(new Selector('html[xml:lang]').xpath); 
    268         assertUndefined(new Selector('body p[xml:lang]').xpath); 
     267        this.assertUndefined(new Selector('html[xml:lang]').xpath); 
     268        this.assertUndefined(new Selector('body p[xml:lang]').xpath); 
    269269      } else 
    270         info("Could not test XPath bypass: no XPath to begin with!"); 
    271        
    272       assertElementsMatch($$('[xml:lang]'), 'html', '#item_3'); 
    273       assertElementsMatch($$('*[xml:lang]'), 'html', '#item_3'); 
    274     }}
    275  
    276     testSelectorWithChild: function() { with(this) { 
    277       assertEnumEqual($('link_1', 'link_2'), $$('p.first > a')); 
    278       assertEnumEqual($('father', 'uncle'), $$('div#grandfather > div')); 
    279       assertEnumEqual($('level2_1', 'level2_2'), $$('#level1>span')); 
    280       assertEnumEqual($('level2_1', 'level2_2'), $$('#level1 > span')); 
    281       assertEnumEqual($('level3_1', 'level3_2'), $$('#level2_1 > *')); 
    282       assertEnumEqual([], $$('div > #nonexistent')); 
    283       $RunBenchmarks && wait(500, function() { 
    284         benchmark(function() { $$('#level1 > span') }, 1000); 
    285       }); 
    286     }}
    287  
    288     testSelectorWithAdjacence: function() { with(this) { 
    289       assertEnumEqual([$('uncle')], $$('div.brothers + div.brothers')); 
    290       assertEnumEqual([$('uncle')], $$('div.brothers + div'));       
    291       assertEqual($('level2_2'), $$('#level2_1+span').reduce()); 
    292       assertEqual($('level2_2'), $$('#level2_1 + span').reduce()); 
    293       assertEqual($('level2_2'), $$('#level2_1 + *').reduce()); 
    294       assertEnumEqual([], $$('#level2_2 + span')); 
    295       assertEqual($('level3_2'), $$('#level3_1 + span').reduce()); 
    296       assertEqual($('level3_2'), $$('#level3_1 + *').reduce()); 
    297       assertEnumEqual([], $$('#level3_2 + *')); 
    298       assertEnumEqual([], $$('#level3_1 + em')); 
    299       $RunBenchmarks && wait(500, function() { 
    300         benchmark(function() { $$('#level3_1 + span') }, 1000); 
    301       }); 
    302     }}
    303  
    304     testSelectorWithLaterSibling: function() { with(this) { 
    305       assertEnumEqual([$('list')], $$('h1 ~ ul')); 
    306       assertEqual($('level2_2'), $$('#level2_1 ~ span').reduce()); 
    307       assertEnumEqual($('level2_2', 'level2_3'), $$('#level2_1 ~ *').reduce()); 
    308       assertEnumEqual([], $$('#level2_2 ~ span')); 
    309       assertEnumEqual([], $$('#level3_2 ~ *')); 
    310       assertEnumEqual([], $$('#level3_1 ~ em')); 
    311       assertEnumEqual([$('level3_2')], $$('#level3_1 ~ #level3_2')); 
    312       assertEnumEqual([$('level3_2')], $$('span ~ #level3_2')); 
    313       assertEnumEqual([], $$('div ~ #level3_2')); 
    314       assertEnumEqual([], $$('div ~ #level2_3')); 
    315       $RunBenchmarks && wait(500, function() { 
    316         benchmark(function() { $$('#level2_1 ~ span') }, 1000); 
    317       }); 
    318     }}
    319  
    320     testSelectorWithNewAttributeOperators: function() { with(this) { 
    321       assertEnumEqual($('father', 'uncle'), $$('div[class^=bro]'), 'matching beginning of string'); 
    322       assertEnumEqual($('father', 'uncle'), $$('div[class$=men]'), 'matching end of string'); 
    323       assertEnumEqual($('father', 'uncle'), $$('div[class*="ers m"]'), 'matching substring') 
    324       assertEnumEqual($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^="level2_"]')); 
    325       assertEnumEqual($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^=level2_]')); 
    326       assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 *[id$="_1"]')); 
    327       assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 *[id$=_1]')); 
    328       assertEnumEqual($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*="2"]')); 
    329       assertEnumEqual($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*=2]')); 
    330       $RunBenchmarks && wait(500, function() { 
    331         benchmark(function() { $$('#level1 *[id^=level2_]') }, 1000, '[^=]'); 
    332         benchmark(function() { $$('#level1 *[id$=_1]') }, 1000, '[$=]'); 
    333         benchmark(function() { $$('#level1 *[id*=_2]') }, 1000, '[*=]'); 
    334       }); 
    335     }}
    336  
    337     testSelectorWithDuplicates: function() { with(this) { 
    338       assertEnumEqual($$('div div'), $$('div div').uniq()); 
    339       assertEnumEqual($('dupL2', 'dupL3', 'dupL4', 'dupL5'), $$('#dupContainer span span')); 
    340       $RunBenchmarks && wait(500, function() { 
    341         benchmark(function() { $$('#dupContainer span span') }, 1000); 
    342       }); 
    343     }}
    344  
    345     testSelectorWithFirstLastOnlyNthNthLastChild: function() { with(this) { 
    346       assertEnumEqual([$('level2_1')], $$('#level1>*:first-child')); 
    347       assertEnumEqual($('level2_1', 'level3_1', 'level_only_child'), $$('#level1 *:first-child')); 
    348       assertEnumEqual([$('level2_3')], $$('#level1>*:last-child')); 
    349       assertEnumEqual($('level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:last-child')); 
    350       assertEnumEqual([$('level2_3')], $$('#level1>div:last-child')); 
    351       assertEnumEqual([$('level2_3')], $$('#level1 div:last-child')); 
    352       assertEnumEqual([], $$('#level1>div:first-child')); 
    353       assertEnumEqual([], $$('#level1>span:last-child')); 
    354       assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 span:first-child')); 
    355       assertEnumEqual([], $$('#level1:first-child')); 
    356       assertEnumEqual([], $$('#level1>*:only-child')); 
    357       assertEnumEqual([$('level_only_child')], $$('#level1 *:only-child')); 
    358       assertEnumEqual([], $$('#level1:only-child')); 
    359       assertEnumEqual([$('link_2')], $$('#p *:nth-last-child(2)'), 'nth-last-child'); 
    360       assertEnumEqual([$('link_2')], $$('#p *:nth-child(3)'), 'nth-child'); 
    361       assertEnumEqual([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child'); 
    362       assertEnumEqual($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)')); 
    363       assertEnumEqual($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)')); 
    364       $RunBenchmarks && wait(500, function() { 
    365         benchmark(function() { $$('#level1 *:first-child') }, 1000, ':first-child'); 
    366         benchmark(function() { $$('#level1 *:last-child') }, 1000, ':last-child'); 
    367         benchmark(function() { $$('#level1 *:only-child') }, 1000, ':only-child'); 
    368       }); 
    369     }}
    370      
    371     testSelectorWithFirstLastNthNthLastOfType: function() {with(this) { 
    372       assertEnumEqual([$('link_2')], $$('#p a:nth-of-type(2)'), 'nth-of-type'); 
    373       assertEnumEqual([$('link_1')], $$('#p a:nth-of-type(1)'), 'nth-of-type'); 
    374       assertEnumEqual([$('link_2')], $$('#p a:nth-last-of-type(1)'), 'nth-last-of-type'); 
    375       assertEnumEqual([$('link_1')], $$('#p a:first-of-type'), 'first-of-type'); 
    376       assertEnumEqual([$('link_2')], $$('#p a:last-of-type'), 'last-of-type'); 
    377     }}
    378      
    379     testSelectorWithNot: function() {with(this) { 
    380       assertEnumEqual([$('link_2')], $$('#p a:not(a:first-of-type)'), 'first-of-type'); 
    381       assertEnumEqual([$('link_1')], $$('#p a:not(a:last-of-type)'), 'last-of-type'); 
    382       assertEnumEqual([$('link_2')], $$('#p a:not(a:nth-of-type(1))'), 'nth-of-type'); 
    383       assertEnumEqual([$('link_1')], $$('#p a:not(a:nth-last-of-type(1))'), 'nth-last-of-type'); 
    384       assertEnumEqual([$('link_2')], $$('#p a:not([rel~=nofollow])'), 'attribute 1'); 
    385       assertEnumEqual([$('link_2')], $$('#p a:not(a[rel^=external])'), 'attribute 2'); 
    386       assertEnumEqual([$('link_2')], $$('#p a:not(a[rel$=nofollow])'), 'attribute 3'); 
    387       assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) > em'), 'attribute 4') 
    388       assertEnumEqual([$('item_2')], $$('#list li:not(#item_1):not(#item_3)'), 'adjacent :not clauses'); 
    389       assertEnumEqual([$('son')], $$('#grandfather > div:not(#uncle) #son')); 
    390       assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) em'), 'attribute 4 + all descendants'); 
    391       assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"])>em'), 'attribute 4 (without whitespace)'); 
    392     }}
    393      
    394     testSelectorWithEnabledDisabledChecked: function() {with(this) { 
    395       assertEnumEqual([$('disabled_text_field')], $$('#troubleForm > *:disabled')); 
    396       assertEnumEqual($('troubleForm').getInputs().without($('disabled_text_field')), $$('#troubleForm > *:enabled')); 
    397       assertEnumEqual($('checked_box', 'checked_radio'), $$('#troubleForm *:checked')); 
    398     }}
    399      
    400     testSelectorWithEmpty: function() {with(this) { 
     270        this.info("Could not test XPath bypass: no XPath to begin with!"); 
     271       
     272      this.assertElementsMatch($$('[xml:lang]'), 'html', '#item_3'); 
     273      this.assertElementsMatch($$('*[xml:lang]'), 'html', '#item_3'); 
     274    }
     275 
     276    testSelectorWithChild: function() { 
     277      this.assertEnumEqual($('link_1', 'link_2'), $$('p.first > a')); 
     278      this.assertEnumEqual($('father', 'uncle'), $$('div#grandfather > div')); 
     279      this.assertEnumEqual($('level2_1', 'level2_2'), $$('#level1>span')); 
     280      this.assertEnumEqual($('level2_1', 'level2_2'), $$('#level1 > span')); 
     281      this.assertEnumEqual($('level3_1', 'level3_2'), $$('#level2_1 > *')); 
     282      this.assertEnumEqual([], $$('div > #nonexistent')); 
     283      $RunBenchmarks && this.wait(500, function() { 
     284        this.benchmark(function() { $$('#level1 > span') }, 1000); 
     285      }); 
     286    }
     287 
     288    testSelectorWithAdjacence: function() { 
     289      this.assertEnumEqual([$('uncle')], $$('div.brothers + div.brothers')); 
     290      this.assertEnumEqual([$('uncle')], $$('div.brothers + div'));       
     291      this.assertEqual($('level2_2'), $$('#level2_1+span').reduce()); 
     292      this.assertEqual($('level2_2'), $$('#level2_1 + span').reduce()); 
     293      this.assertEqual($('level2_2'), $$('#level2_1 + *').reduce()); 
     294      this.assertEnumEqual([], $$('#level2_2 + span')); 
     295      this.assertEqual($('level3_2'), $$('#level3_1 + span').reduce()); 
     296      this.assertEqual($('level3_2'), $$('#level3_1 + *').reduce()); 
     297      this.assertEnumEqual([], $$('#level3_2 + *')); 
     298      this.assertEnumEqual([], $$('#level3_1 + em')); 
     299      $RunBenchmarks && this.wait(500, function() { 
     300        this.benchmark(function() { $$('#level3_1 + span') }, 1000); 
     301      }); 
     302    }
     303 
     304    testSelectorWithLaterSibling: function() { 
     305      this.assertEnumEqual([$('list')], $$('h1 ~ ul')); 
     306      this.assertEqual($('level2_2'), $$('#level2_1 ~ span').reduce()); 
     307      this.assertEnumEqual($('level2_2', 'level2_3'), $$('#level2_1 ~ *').reduce()); 
     308      this.assertEnumEqual([], $$('#level2_2 ~ span')); 
     309      this.assertEnumEqual([], $$('#level3_2 ~ *')); 
     310      this.assertEnumEqual([], $$('#level3_1 ~ em')); 
     311      this.assertEnumEqual([$('level3_2')], $$('#level3_1 ~ #level3_2')); 
     312      this.assertEnumEqual([$('level3_2')], $$('span ~ #level3_2')); 
     313      this.assertEnumEqual([], $$('div ~ #level3_2')); 
     314      this.assertEnumEqual([], $$('div ~ #level2_3')); 
     315      $RunBenchmarks && this.wait(500, function() { 
     316        this.benchmark(function() { $$('#level2_1 ~ span') }, 1000); 
     317      }); 
     318    }
     319 
     320    testSelectorWithNewAttributeOperators: function() { 
     321      this.assertEnumEqual($('father', 'uncle'), $$('div[class^=bro]'), 'matching beginning of string'); 
     322      this.assertEnumEqual($('father', 'uncle'), $$('div[class$=men]'), 'matching end of string'); 
     323      this.assertEnumEqual($('father', 'uncle'), $$('div[class*="ers m"]'), 'matching substring') 
     324      this.assertEnumEqual($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^="level2_"]')); 
     325      this.assertEnumEqual($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^=level2_]')); 
     326      this.assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 *[id$="_1"]')); 
     327      this.assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 *[id$=_1]')); 
     328      this.assertEnumEqual($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*="2"]')); 
     329      this.assertEnumEqual($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*=2]')); 
     330      $RunBenchmarks && this.wait(500, function() { 
     331        this.benchmark(function() { $$('#level1 *[id^=level2_]') }, 1000, '[^=]'); 
     332        this.benchmark(function() { $$('#level1 *[id$=_1]') }, 1000, '[$=]'); 
     333        this.benchmark(function() { $$('#level1 *[id*=_2]') }, 1000, '[*=]'); 
     334      }); 
     335    }
     336 
     337    testSelectorWithDuplicates: function() { 
     338      this.assertEnumEqual($$('div div'), $$('div div').uniq()); 
     339      this.assertEnumEqual($('dupL2', 'dupL3', 'dupL4', 'dupL5'), $$('#dupContainer span span')); 
     340      $RunBenchmarks && this.wait(500, function() { 
     341        this.benchmark(function() { $$('#dupContainer span span') }, 1000); 
     342      }); 
     343    }
     344 
     345    testSelectorWithFirstLastOnlyNthNthLastChild: function() { 
     346      this.assertEnumEqual([$('level2_1')], $$('#level1>*:first-child')); 
     347      this.assertEnumEqual($('level2_1', 'level3_1', 'level_only_child'), $$('#level1 *:first-child')); 
     348      this.assertEnumEqual([$('level2_3')], $$('#level1>*:last-child')); 
     349      this.assertEnumEqual($('level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:last-child')); 
     350      this.assertEnumEqual([$('level2_3')], $$('#level1>div:last-child')); 
     351      this.assertEnumEqual([$('level2_3')], $$('#level1 div:last-child')); 
     352      this.assertEnumEqual([], $$('#level1>div:first-child')); 
     353      this.assertEnumEqual([], $$('#level1>span:last-child')); 
     354      this.assertEnumEqual($('level2_1', 'level3_1'), $$('#level1 span:first-child')); 
     355      this.assertEnumEqual([], $$('#level1:first-child')); 
     356      this.assertEnumEqual([], $$('#level1>*:only-child')); 
     357      this.assertEnumEqual([$('level_only_child')], $$('#level1 *:only-child')); 
     358      this.assertEnumEqual([], $$('#level1:only-child')); 
     359      this.assertEnumEqual([$('link_2')], $$('#p *:nth-last-child(2)'), 'nth-last-child'); 
     360      this.assertEnumEqual([$('link_2')], $$('#p *:nth-child(3)'), 'nth-child'); 
     361      this.assertEnumEqual([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child'); 
     362      this.assertEnumEqual($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)')); 
     363      this.assertEnumEqual($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)')); 
     364      $RunBenchmarks && this.wait(500, function() { 
     365        this.benchmark(function() { $$('#level1 *:first-child') }, 1000, ':first-child'); 
     366        this.benchmark(function() { $$('#level1 *:last-child') }, 1000, ':last-child'); 
     367        this.benchmark(function() { $$('#level1 *:only-child') }, 1000, ':only-child'); 
     368      }); 
     369    }
     370     
     371    testSelectorWithFirstLastNthNthLastOfType: function() { 
     372      this.assertEnumEqual([$('link_2')], $$('#p a:nth-of-type(2)'), 'nth-of-type'); 
     373      this.assertEnumEqual([$('link_1')], $$('#p a:nth-of-type(1)'), 'nth-of-type'); 
     374      this.assertEnumEqual([$('link_2')], $$('#p a:nth-last-of-type(1)'), 'nth-last-of-type'); 
     375      this.assertEnumEqual([$('link_1')], $$('#p a:first-of-type'), 'first-of-type'); 
     376      this.assertEnumEqual([$('link_2')], $$('#p a:last-of-type'), 'last-of-type'); 
     377    }
     378     
     379    testSelectorWithNot: function() { 
     380      this.assertEnumEqual([$('link_2')], $$('#p a:not(a:first-of-type)'), 'first-of-type'); 
     381      this.assertEnumEqual([$('link_1')], $$('#p a:not(a:last-of-type)'), 'last-of-type'); 
     382      this.assertEnumEqual([$('link_2')], $$('#p a:not(a:nth-of-type(1))'), 'nth-of-type'); 
     383      this.assertEnumEqual([$('link_1')], $$('#p a:not(a:nth-last-of-type(1))'), 'nth-last-of-type'); 
     384      this.assertEnumEqual([$('link_2')], $$('#p a:not([rel~=nofollow])'), 'attribute 1'); 
     385      this.assertEnumEqual([$('link_2')], $$('#p a:not(a[rel^=external])'), 'attribute 2'); 
     386      this.assertEnumEqual([$('link_2')], $$('#p a:not(a[rel$=nofollow])'), 'attribute 3'); 
     387      this.assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) > em'), 'attribute 4') 
     388      this.assertEnumEqual([$('item_2')], $$('#list li:not(#item_1):not(#item_3)'), 'adjacent :not clauses'); 
     389      this.assertEnumEqual([$('son')], $$('#grandfather > div:not(#uncle) #son')); 
     390      this.assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"]) em'), 'attribute 4 + all descendants'); 
     391      this.assertEnumEqual([$('em')], $$('#p a:not(a[rel$="nofollow"])>em'), 'attribute 4 (without whitespace)'); 
     392    }
     393     
     394    testSelectorWithEnabledDisabledChecked: function() { 
     395      this.assertEnumEqual([$('disabled_text_field')], $$('#troubleForm > *:disabled')); 
     396      this.assertEnumEqual($('troubleForm').getInputs().without($('disabled_text_field')), $$('#troubleForm > *:enabled')); 
     397      this.assertEnumEqual($('checked_box', 'checked_radio'), $$('#troubleForm *:checked')); 
     398    }
     399     
     400    testSelectorWithEmpty: function() { 
    401401      $('level3_1').innerHTML = "\t\n\n\r\n\t   "; 
    402       assertEnumEqual($('level3_1', 'level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:empty')); 
    403       assertEnumEqual([$('level_only_child')], $$('#level_only_child:empty')); 
    404     }},     
    405      
    406     testIdenticalResultsFromEquivalentSelectors: function() {with(this) { 
    407       assertEnumEqual($$('div.brothers'), $$('div[class~=brothers]')); 
    408       assertEnumEqual($$('div.brothers'), $$('div[class~=brothers].brothers')); 
    409       assertEnumEqual($$('div:not(.brothers)'), $$('div:not([class~=brothers])')); 
    410       assertEnumEqual($$('li ~ li'), $$('li:not(:first-child)')); 
    411       assertEnumEqual($$('ul > li'), $$('ul > li:nth-child(n)')); 
    412       assertEnumEqual($$('ul > li:nth-child(even)'), $$('ul > li:nth-child(2n)')); 
    413       assertEnumEqual($$('ul > li:nth-child(odd)'), $$('ul > li:nth-child(2n+1)')); 
    414       assertEnumEqual($$('ul > li:first-child'), $$('ul > li:nth-child(1)')); 
    415       assertEnumEqual($$('ul > li:last-child'), $$('ul > li:nth-last-child(1)')); 
    416       assertEnumEqual($$('#troubleForm *:enabled'), $$('#troubleForm *:not(:disabled)')); 
    417       assertEnumEqual($$('ul > li:nth-child(n-999)'), $$('ul > li')); 
    418       assertEnumEqual($$('ul>li'), $$('ul > li')); 
    419       assertEnumEqual($$('#p a:not(a[rel$="nofollow"])>em'), $$('#p a:not(a[rel$="nofollow"]) > em')) 
    420     }}
    421      
    422     testSelectorsThatShouldReturnNothing: function() {with(this) { 
    423       assertEnumEqual([], $$('span:empty > *')); 
    424       assertEnumEqual([], $$('div.brothers:not(.brothers)')); 
    425       assertEnumEqual([], $$('#level2_2 :only-child:not(:last-child)')); 
    426       assertEnumEqual([], $$('#level2_2 :only-child:not(:first-child)')); 
    427     }}
    428  
    429     testCommasFor$$: function() {with(this) { 
    430       assertEnumEqual($('list', 'p', 'link_1', 'item_1', 'item_3', 'troubleForm'), $$('#list, .first,*[xml:lang="es-us"] , #troubleForm')); 
    431       assertEnumEqual($('list', 'p', 'link_1', 'item_1', 'item_3', 'troubleForm'), $$('#list, .first,', '*[xml:lang="es-us"] , #troubleForm')); 
    432       assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"], input[value="#commaOne,#commaTwo"]')); 
    433       assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"]', 'input[value="#commaOne,#commaTwo"]')); 
    434     }}
    435      
    436     testSelectorExtendsAllNodes: function(){ with(this) { 
     402      this.assertEnumEqual($('level3_1', 'level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:empty')); 
     403      this.assertEnumEqual([$('level_only_child')], $$('#level_only_child:empty')); 
     404    },     
     405     
     406    testIdenticalResultsFromEquivalentSelectors: function() { 
     407      this.assertEnumEqual($$('div.brothers'), $$('div[class~=brothers]')); 
     408      this.assertEnumEqual($$('div.brothers'), $$('div[class~=brothers].brothers')); 
     409      this.assertEnumEqual($$('div:not(.brothers)'), $$('div:not([class~=brothers])')); 
     410      this.assertEnumEqual($$('li ~ li'), $$('li:not(:first-child)')); 
     411      this.assertEnumEqual($$('ul > li'), $$('ul > li:nth-child(n)')); 
     412      this.assertEnumEqual($$('ul > li:nth-child(even)'), $$('ul > li:nth-child(2n)')); 
     413      this.assertEnumEqual($$('ul > li:nth-child(odd)'), $$('ul > li:nth-child(2n+1)')); 
     414      this.assertEnumEqual($$('ul > li:first-child'), $$('ul > li:nth-child(1)')); 
     415      this.assertEnumEqual($$('ul > li:last-child'), $$('ul > li:nth-last-child(1)')); 
     416      this.assertEnumEqual($$('#troubleForm *:enabled'), $$('#troubleForm *:not(:disabled)')); 
     417      this.assertEnumEqual($$('ul > li:nth-child(n-999)'), $$('ul > li')); 
     418      this.assertEnumEqual($$('ul>li'), $$('ul > li')); 
     419      this.assertEnumEqual($$('#p a:not(a[rel$="nofollow"])>em'), $$('#p a:not(a[rel$="nofollow"]) > em')) 
     420    }
     421     
     422    testSelectorsThatShouldReturnNothing: function() { 
     423      this.assertEnumEqual([], $$('span:empty > *')); 
     424      this.assertEnumEqual([], $$('div.brothers:not(.brothers)')); 
     425      this.assertEnumEqual([], $$('#level2_2 :only-child:not(:last-child)')); 
     426      this.assertEnumEqual([], $$('#level2_2 :only-child:not(:first-child)')); 
     427    }
     428 
     429    testCommasFor$$: function() { 
     430      this.assertEnumEqual($('list', 'p', 'link_1', 'item_1', 'item_3', 'troubleForm'), $$('#list, .first,*[xml:lang="es-us"] , #troubleForm')); 
     431      this.assertEnumEqual($('list', 'p', 'link_1', 'item_1', 'item_3', 'troubleForm'), $$('#list, .first,', '*[xml:lang="es-us"] , #troubleForm')); 
     432      this.assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"], input[value="#commaOne,#commaTwo"]')); 
     433      this.assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"]', 'input[value="#commaOne,#commaTwo"]')); 
     434    }
     435     
     436    testSelectorExtendsAllNodes: function(){ 
    437437      var element = document.createElement('div'); 
    438438      (3).times(function(){ 
     
    443443       
    444444      var results = $$('#scratch_element div'); 
    445       assert(typeof results[0].show == 'function'); 
    446       assert(typeof results[1].show == 'function'); 
    447       assert(typeof results[2].show == 'function'); 
    448     }}
    449      
    450     testCountedIsNotAnAttribute: function() { with(this) { 
     445      this.assert(typeof results[0].show == 'function'); 
     446      this.assert(typeof results[1].show == 'function'); 
     447      this.assert(typeof results[2].show == 'function'); 
     448    }
     449     
     450    testCountedIsNotAnAttribute: function() { 
    451451      var el = $('list'); 
    452452      Selector.handlers.mark([el]); 
    453       assert(!el.innerHTML.include("_counted")); 
     453      this.assert(!el.innerHTML.include("_counted")); 
    454454      Selector.handlers.unmark([el]); 
    455       assert(!el.innerHTML.include("_counted"));       
    456     }}
    457  
    458     testCopiedNodesGetIncluded: function(){ with(this)
    459       assertElementsMatch( 
     455      this.assert(!el.innerHTML.include("_counted"));       
     456    }
     457 
     458    testCopiedNodesGetIncluded: function()
     459      this.assertElementsMatch( 
    460460        Selector.matchElements($('counted_container').descendants(), 'div'), 
    461461        'div.is_counted' 
    462462      ); 
    463463      $('counted_container').innerHTML += $('counted_container').innerHTML; 
    464       assertElementsMatch( 
     464      this.assertElementsMatch( 
    465465        Selector.matchElements($('counted_container').descendants(), 'div'), 'div.is_counted',  
    466466        'div.is_counted' 
    467467      ); 
    468     }} 
     468    } 
    469469  }); 
    470470   
  • spinoffs/prototype/trunk/test/unit/string.html

    r8999 r9036  
    3737   
    3838  new Test.Unit.Runner({ 
    39     testInterpret: function(){with(this) { 
    40       assertIdentical('true', String.interpret(true)); 
    41       assertIdentical('123',  String.interpret(123)); 
    42       assertIdentical('foo bar', String.interpret('foo bar')); 
    43       assertIdentical( 
     39    testInterpret: function(){ 
     40      this.assertIdentical('true', String.interpret(true)); 
     41      this.assertIdentical('123',  String.interpret(123)); 
     42      this.assertIdentical('foo bar', String.interpret('foo bar')); 
     43      this.assertIdentical( 
    4444        'object string', 
    4545        String.interpret({ toString: function(){ return 'object string' } })); 
    4646 
    47       assertIdentical('0', String.interpret(0)); 
    48       assertIdentical('false', String.interpret(false)); 
    49       assertIdentical('', String.interpret(undefined)); 
    50       assertIdentical('', String.interpret(null)); 
    51       assertIdentical('', String.interpret('')); 
    52     }}
    53  
    54     testGsubWithReplacementFunction: function() {with(this) { 
     47      this.assertIdentical('0', String.interpret(0)); 
     48      this.assertIdentical('false', String.interpret(false)); 
     49      this.assertIdentical('', String.interpret(undefined)); 
     50      this.assertIdentical('', String.interpret(null)); 
     51      this.assertIdentical('', String.interpret('')); 
     52    }
     53 
     54    testGsubWithReplacementFunction: function() { 
    5555      var source = 'foo boo boz'; 
    5656       
    57       assertEqual('Foo Boo BoZ', 
     57      this.assertEqual('Foo Boo BoZ', 
    5858        source.gsub(/[^o]+/, function(match) { 
    5959          return match[0].toUpperCase() 
    6060        })); 
    61       assertEqual('f2 b2 b1z', 
     61      this.assertEqual('f2 b2 b1z', 
    6262        source.gsub(/o+/, function(match) { 
    6363          return match[0].length; 
    6464        })); 
    65       assertEqual('f0 b0 b1z', 
     65      this.assertEqual('f0 b0 b1z', 
    6666        source.gsub(/o+/, function(match) { 
    6767          return match[0].length % 2; 
    6868        })); 
    6969 
    70     }}
    71      
    72     testGsubWithReplacementString: function() {with(this) { 
     70    }
     71     
     72    testGsubWithReplacementString: function() { 
    7373      var source = 'foo boo boz'; 
    7474       
    75       assertEqual('foobooboz', 
     75      this.assertEqual('foobooboz', 
    7676        source.gsub(/\s+/, '')); 
    77       assertEqual('  z',  
     77      this.assertEqual('  z',  
    7878        source.gsub(/(.)(o+)/, '')); 
    7979         
    80       assertEqual('りィメンズ2007<br/>クルヌズコレクション',  
     80      this.assertEqual('りィメンズ2007<br/>クルヌズコレクション',  
    8181        'りィメンズ2007\nクルヌズコレクション'.gsub(/\n/,'<br/>')); 
    82       assertEqual('りィメンズ2007<br/>クルヌズコレクション',  
     82      this.assertEqual('りィメンズ2007<br/>クルヌズコレクション',  
    8383        'りィメンズ2007\nクルヌズコレクション'.gsub('\n','<br/>')); 
    84     }}
    85      
    86     testGsubWithReplacementTemplateString: function() {with(this) { 
     84    }
     85     
     86    testGsubWithReplacementTemplateString: function() { 
    8787      var source = 'foo boo boz'; 
    8888       
    89       assertEqual('-oo-#{1}- -oo-#{1}- -o-#{1}-z', 
     89      this.assertEqual('-oo-#{1}- -oo-#{1}- -o-#{1}-z', 
    9090        source.gsub(/(.)(o+)/, '-#{2}-\\#{1}-')); 
    91       assertEqual('-foo-f- -boo-b- -bo-b-z', 
     91      this.assertEqual('-foo-f- -boo-b- -bo-b-z', 
    9292        source.gsub(/(.)(o+)/, '-#{0}-#{1}-')); 
    93       assertEqual('-oo-f- -oo-b- -o-b-z', 
     93      this.assertEqual('-oo-f- -oo-b- -o-b-z', 
    9494        source.gsub(/(.)(o+)/, '-#{2}-#{1}-')); 
    95       assertEqual('  z', 
     95      this.assertEqual('  z', 
    9696        source.gsub(/(.)(o+)/, '#{3}'));       
    97     }}
    98      
    99     testSubWithReplacementFunction: function() {with(this) { 
     97    }
     98     
     99    testSubWithReplacementFunction: function() { 
    100100      var source = 'foo boo boz'; 
    101101 
    102       assertEqual('Foo boo boz', 
     102      this.assertEqual('Foo boo boz', 
    103103        source.sub(/[^o]+/, function(match) { 
    104104          return match[0].toUpperCase() 
    105105        }), 1); 
    106       assertEqual('Foo Boo boz', 
     106      this.assertEqual('Foo Boo boz', 
    107107        source.sub(/[^o]+/, function(match) { 
    108108          return match[0].toUpperCase() 
    109109        }, 2), 2); 
    110       assertEqual(source, 
     110      this.assertEqual(source, 
    111111        source.sub(/[^o]+/, function(match) { 
    112112          return match[0].toUpperCase() 
    113113        }, 0), 0); 
    114       assertEqual(source, 
     114      this.assertEqual(source, 
    115115        source.sub(/[^o]+/, function(match) { 
    116116          return match[0].toUpperCase() 
    117117        }, -1), -1); 
    118     }}
    119      
    120     testSubWithReplacementString: function() {with(this) { 
     118    }
     119     
     120    testSubWithReplacementString: function() { 
    121121      var source = 'foo boo boz'; 
    122122       
    123       assertEqual('oo boo boz', 
     123      this.assertEqual('oo boo boz', 
    124124        source.sub(/[^o]+/, '')); 
    125       assertEqual('oooo boz', 
     125      this.assertEqual('oooo boz', 
    126126        source.sub(/[^o]+/, '', 2)); 
    127       assertEqual('-f-oo boo boz', 
     127      this.assertEqual('-f-oo boo boz', 
    128128        source.sub(/[^o]+/, '-#{0}-')); 
    129       assertEqual('-f-oo- b-oo boz', 
     129      this.assertEqual('-f-oo- b-oo boz', 
    130130        source.sub(/[^o]+/, '-#{0}-', 2)); 
    131     }}
    132      
    133     testScan: function() {with(this) { 
     131    }
     132     
     133    testScan: function() { 
    134134      var source = 'foo boo boz', results = []; 
    135135      var str = source.scan(/[o]+/, function(match) { 
    136136        results.push(match[0].length); 
    137137      }); 
    138       assertEnumEqual([2, 2, 1], results); 
    139       assertEqual(source, source.scan(/x/, fail)); 
    140       assert(typeof str == 'string'); 
    141     }}
    142      
    143     testToArray: function() {with(this) { 
    144       assertEnumEqual([],''.toArray()); 
    145       assertEnumEqual(['a'],'a'.toArray()); 
    146       assertEnumEqual(['a','b'],'ab'.toArray()); 
    147       assertEnumEqual(['f','o','o'],'foo'.toArray()); 
    148     }}
     138      this.assertEnumEqual([2, 2, 1], results); 
     139      this.assertEqual(source, source.scan(/x/, this.fail)); 
     140      this.assert(typeof str == 'string'); 
     141    }
     142     
     143    testToArray: function() { 
     144      this.assertEnumEqual([],''.toArray()); 
     145      this.assertEnumEqual(['a'],'a'.toArray()); 
     146      this.assertEnumEqual(['a','b'],'ab'.toArray()); 
     147      this.assertEnumEqual(['f','o','o'],'foo'.toArray()); 
     148    }
    149149 
    150150    /*  
     
    155155       - CamelCases first word if there is a front dash 
    156156    */ 
    157     testCamelize: function() {with(this) { 
    158       assertEqual('', ''.camelize()); 
    159       assertEqual('', '-'.camelize()); 
    160       assertEqual('foo', 'foo'.camelize()); 
    161       assertEqual('foo_bar', 'foo_bar'.camelize()); 
    162       assertEqual('FooBar', '-foo-bar'.camelize()); 
    163       assertEqual('FooBar', 'FooBar'.camelize()); 
    164        
    165       assertEqual('fooBar', 'foo-bar'.camelize()); 
    166       assertEqual('borderBottomWidth', 'border-bottom-width'.camelize()); 
    167        
    168       assertEqual('classNameTest','class-name-test'.camelize()); 
    169       assertEqual('classNameTest','className-test'.camelize()); 
    170       assertEqual('classNameTest','class-nameTest'.camelize()); 
    171        
    172       /* benchmark(function(){ 
     157    testCamelize: function() { 
     158      this.assertEqual('', ''.camelize()); 
     159      this.assertEqual('', '-'.camelize()); 
     160      this.assertEqual('foo', 'foo'.camelize()); 
     161      this.assertEqual('foo_bar', 'foo_bar'.camelize()); 
     162      this.assertEqual('FooBar', '-foo-bar'.camelize()); 
     163      this.assertEqual('FooBar', 'FooBar'.camelize()); 
     164       
     165      this.assertEqual('fooBar', 'foo-bar'.camelize()); 
     166      this.assertEqual('borderBottomWidth', 'border-bottom-width'.camelize()); 
     167       
     168      this.assertEqual('classNameTest','class-name-test'.camelize()); 
     169      this.assertEqual('classNameTest','className-test'.camelize()); 
     170      this.assertEqual('classNameTest','class-nameTest'.camelize()); 
     171       
     172      /* this.benchmark(function(){ 
    173173        'class-name-test'.camelize(); 
    174174      },10000); */ 
    175     }}
    176  
    177     testCapitalize: function() {with(this) { 
    178       assertEqual('',''.capitalize()); 
    179       assertEqual('Ä','À'.capitalize()); 
    180       assertEqual('A','A'.capitalize()); 
    181       assertEqual('Hello','hello'.capitalize()); 
    182       assertEqual('Hello','HELLO'.capitalize()); 
    183       assertEqual('Hello','Hello'.capitalize()); 
    184       assertEqual('Hello world','hello WORLD'.capitalize()); 
    185     }},   
    186        
    187     testUnderscore: function() {with(this) { 
    188       assertEqual('', ''.underscore()); 
    189       assertEqual('_', '-'.underscore()); 
    190       assertEqual('foo', 'foo'.underscore()); 
    191       assertEqual('foo', 'Foo'.underscore()); 
    192       assertEqual('foo_bar', 'foo_bar'.underscore()); 
    193       assertEqual('border_bottom', 'borderBottom'.underscore()); 
    194       assertEqual('border_bottom_width', 'borderBottomWidth'.underscore()); 
    195       assertEqual('border_bottom_width', 'border-Bottom-Width'.underscore());       
    196     }}
    197      
    198     testDasherize: function() {with(this) { 
    199       assertEqual('', ''.dasherize()); 
    200       assertEqual('foo', 'foo'.dasherize()); 
    201       assertEqual('Foo', 'Foo'.dasherize()); 
    202       assertEqual('foo-bar', 'foo-bar'.dasherize()); 
    203       assertEqual('border-bottom-width', 'border_bottom_width'.dasherize()); 
    204     }}
    205      
    206     testTruncate: function() {with(this) { 
     175    }
     176 
     177    testCapitalize: function() { 
     178      this.assertEqual('',''.capitalize()); 
     179      this.assertEqual('Ä','À'.capitalize()); 
     180      this.assertEqual('A','A'.capitalize()); 
     181      this.assertEqual('Hello','hello'.capitalize()); 
     182      this.assertEqual('Hello','HELLO'.capitalize()); 
     183      this.assertEqual('Hello','Hello'.capitalize()); 
     184      this.assertEqual('Hello world','hello WORLD'.capitalize()); 
     185    },   
     186       
     187    testUnderscore: function() { 
     188      this.assertEqual('', ''.underscore()); 
     189      this.assertEqual('_', '-'.underscore()); 
     190      this.assertEqual('foo', 'foo'.underscore()); 
     191      this.assertEqual('foo', 'Foo'.underscore()); 
     192      this.assertEqual('foo_bar', 'foo_bar'.underscore()); 
     193      this.assertEqual('border_bottom', 'borderBottom'.underscore()); 
     194      this.assertEqual('border_bottom_width', 'borderBottomWidth'.underscore()); 
     195      this.assertEqual('border_bottom_width', 'border-Bottom-Width'.underscore());       
     196    }
     197     
     198    testDasherize: function() { 
     199      this.assertEqual('', ''.dasherize()); 
     200      this.assertEqual('foo', 'foo'.dasherize()); 
     201      this.assertEqual('Foo', 'Foo'.dasherize()); 
     202      this.assertEqual('foo-bar', 'foo-bar'.dasherize()); 
     203      this.assertEqual('border-bottom-width', 'border_bottom_width'.dasherize()); 
     204    }
     205     
     206    testTruncate: function() { 
    207207      var source = 'foo boo boz foo boo boz foo boo boz foo boo boz'; 
    208       assertEqual(source, source.truncate(source.length)); 
    209       assertEqual('foo boo boz foo boo boz foo...', source.truncate(0)); 
    210       assertEqual('fo...', source.truncate(5)); 
    211       assertEqual('foo b', source.truncate(5, '')); 
    212        
    213       assert(typeof 'foo'.truncate(5) == 'string'); 
    214       assert(typeof 'foo bar baz'.truncate(5) == 'string'); 
    215     }}
    216      
    217     testStrip: function() {with(this) { 
    218       assertEqual('hello world', '   hello world  '.strip()); 
    219       assertEqual('hello world', 'hello world'.strip()); 
    220       assertEqual('hello  \n  world', '  hello  \n  world  '.strip()); 
    221       assertEqual('', ' '.strip()); 
    222     }}
    223      
    224     testStripTags: function() {with(this) { 
    225       assertEqual('hello world', 'hello world'.stripTags()); 
    226       assertEqual('hello world', 'hello <span>world</span>'.stripTags()); 
    227       assertEqual('hello world', '<a href="#" onclick="moo!">hello</a> world'.stripTags()); 
    228       assertEqual('hello world', 'h<b><em>e</em></b>l<i>l</i>o w<span class="moo" id="x"><b>o</b></span>rld'.stripTags()); 
    229       assertEqual('1\n2', '1\n2'.stripTags()); 
    230     }}
    231      
    232     testStripScripts: function() {with(this) { 
    233       assertEqual('foo bar', 'foo bar'.stripScripts()); 
    234       assertEqual('foo bar', ('foo <script>boo();<'+'/script>bar').stripScripts()); 
    235       assertEqual('foo bar', ('foo <script type="text/javascript">boo();\nmoo();<'+'/script>bar').stripScripts()); 
    236     }}
    237      
    238     testExtractScripts: function() {with(this) { 
    239       assertEnumEqual([], 'foo bar'.extractScripts()); 
    240       assertEnumEqual(['boo();'], ('foo <script>boo();<'+'/script>bar').extractScripts()); 
    241       assertEnumEqual(['boo();','boo();\nmoo();'],  
     208      this.assertEqual(source, source.truncate(source.length)); 
     209      this.assertEqual('foo boo boz foo boo boz foo...', source.truncate(0)); 
     210      this.assertEqual('fo...', source.truncate(5)); 
     211      this.assertEqual('foo b', source.truncate(5, '')); 
     212       
     213      this.assert(typeof 'foo'.truncate(5) == 'string'); 
     214      this.assert(typeof 'foo bar baz'.truncate(5) == 'string'); 
     215    }
     216     
     217    testStrip: function() { 
     218      this.assertEqual('hello world', '   hello world  '.strip()); 
     219      this.assertEqual('hello world', 'hello world'.strip()); 
     220      this.assertEqual('hello  \n  world', '  hello  \n  world  '.strip()); 
     221      this.assertEqual('', ' '.strip()); 
     222    }
     223     
     224    testStripTags: function() { 
     225      this.assertEqual('hello world', 'hello world'.stripTags()); 
     226      this.assertEqual('hello world', 'hello <span>world</span>'.stripTags()); 
     227      this.assertEqual('hello world', '<a href="#" onclick="moo!">hello</a> world'.stripTags()); 
     228      this.assertEqual('hello world', 'h<b><em>e</em></b>l<i>l</i>o w<span class="moo" id="x"><b>o</b></span>rld'.stripTags()); 
     229      this.assertEqual('1\n2', '1\n2'.stripTags()); 
     230    }
     231     
     232    testStripScripts: function() { 
     233      this.assertEqual('foo bar', 'foo bar'.stripScripts()); 
     234      this.assertEqual('foo bar', ('foo <script>boo();<'+'/script>bar').stripScripts()); 
     235      this.assertEqual('foo bar', ('foo <script type="text/javascript">boo();\nmoo();<'+'/script>bar').stripScripts()); 
     236    }
     237     
     238    testExtractScripts: function() { 
     239      this.assertEnumEqual([], 'foo bar'.extractScripts()); 
     240      this.assertEnumEqual(['boo();'], ('foo <script>boo();<'+'/script>bar').extractScripts()); 
     241      this.assertEnumEqual(['boo();','boo();\nmoo();'],  
    242242        ('foo <script>boo();<'+'/script><script type="text/javascript">boo();\nmoo();<'+'/script>bar').extractScripts()); 
    243       assertEnumEqual(['boo();','boo();\nmoo();'],  
     243      this.assertEnumEqual(['boo();','boo();\nmoo();'],  
    244244        ('foo <script>boo();<'+'/script>blub\nblub<script type="text/javascript">boo();\nmoo();<'+'/script>bar').extractScripts()); 
    245     }}
    246      
    247     testEvalScripts: function() {with(this) { 
    248       assertEqual(0, evalScriptsCounter); 
     245    }
     246     
     247    testEvalScripts: function() { 
     248      this.assertEqual(0, evalScriptsCounter); 
    249249       
    250250      ('foo <script>evalScriptsCounter++<'+'/script>bar').evalScripts(); 
    251       assertEqual(1, evalScriptsCounter); 
     251      this.assertEqual(1, evalScriptsCounter); 
    252252       
    253253      var stringWithScripts = ''; 
    254254      (3).times(function(){ stringWithScripts += 'foo <script>evalScriptsCounter++<'+'/script>bar' }); 
    255255      stringWithScripts.evalScripts(); 
    256       assertEqual(4, evalScriptsCounter); 
    257     }}
    258      
    259     testEscapeHTML: function() {with(this) { 
    260       assertEqual('foo bar', 'foo bar'.escapeHTML()); 
    261       assertEqual('foo &lt;span&gt;bar&lt;/span&gt;', 'foo <span>bar</span>'.escapeHTML()); 
    262       assertEqual('foo ß bar', 'foo ß bar'.escapeHTML()); 
    263        
    264       assertEqual('りィメンズ2007\nクルヌズコレクション',  
     256      this.assertEqual(4, evalScriptsCounter); 
     257    }
     258     
     259    testEscapeHTML: function() { 
     260      this.assertEqual('foo bar', 'foo bar'.escapeHTML()); 
     261      this.assertEqual('foo &lt;span&gt;bar&lt;/span&gt;', 'foo <span>bar</span>'.escapeHTML()); 
     262      this.assertEqual('foo ß bar', 'foo ß bar'.escapeHTML()); 
     263       
     264      this.assertEqual('りィメンズ2007\nクルヌズコレクション',  
    265265        'りィメンズ2007\nクルヌズコレクション'.escapeHTML()); 
    266266         
    267       assertEqual('a&lt;a href="blah"&gt;blub&lt;/a&gt;b&lt;span&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;cdef&lt;strong&gt;!!!!&lt;/strong&gt;g', 
     267      this.assertEqual('a&lt;a href="blah"&gt;blub&lt;/a&gt;b&lt;span&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;cdef&lt;strong&gt;!!!!&lt;/strong&gt;g', 
    268268        'a<a href="blah">blub</a>b<span><div></div></span>cdef<strong>!!!!</strong>g'.escapeHTML()); 
    269269       
    270       assertEqual(largeTextEscaped, largeTextUnescaped.escapeHTML()); 
    271        
    272       assertEqual('1\n2', '1\n2'.escapeHTML()); 
    273        
    274       benchmark(function(){ 
    275         largeTextUnescaped.escapeHTML(); 
    276       },1000); 
    277     }}, 
    278      
    279     testUnescapeHTML: function() {with(this) { 
    280       assertEqual('foo bar', 'foo bar'.unescapeHTML()); 
    281       assertEqual('foo <span>bar</span>', 'foo &lt;span&gt;bar&lt;/span&gt;'.unescapeHTML()); 
    282       assertEqual('foo ß bar', 'foo ß bar'.unescapeHTML()); 
    283        
    284       assertEqual('a<a href="blah">blub</a>b<span><div></div></span>cdef<strong>!!!!</strong>g', 
     270      this.assertEqual(largeTextEscaped, largeTextUnescaped.escapeHTML()); 
     271       
     272      this.assertEqual('1\n2', '1\n2'.escapeHTML()); 
     273       
     274      this.benchmark(function() { largeTextUnescaped.escapeHTML() }, 1000); 
     275    }, 
     276     
     277    testUnescapeHTML: function() { 
     278      this.assertEqual('foo bar', 'foo bar'.unescapeHTML()); 
     279      this.assertEqual('foo <span>bar</span>', 'foo &lt;span&gt;bar&lt;/span&gt;'.unescapeHTML()); 
     280      this.assertEqual('foo ß bar', 'foo ß bar'.unescapeHTML()); 
     281       
     282      this.assertEqual('a<a href="blah">blub</a>b<span><div></div></span>cdef<strong>!!!!</strong>g', 
    285283        'a&lt;a href="blah"&gt;blub&lt;/a&gt;b&lt;span&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;cdef&lt;strong&gt;!!!!&lt;/strong&gt;g'.unescapeHTML()); 
    286284       
    287       assertEqual(largeTextUnescaped, largeTextEscaped.unescapeHTML()); 
    288        
    289       assertEqual('1\n2', '1\n2'.unescapeHTML()); 
    290       assertEqual('Pride & Prejudice', '<h1>Pride &amp; Prejudice</h1>'.unescapeHTML()); 
    291        
    292       benchmark(function(){ 
    293         largeTextEscaped.unescapeHTML(); 
    294       },1000); 
    295        
    296     }}, 
    297      
    298     testTemplateEvaluation: function() {with(this) { 
     285      this.assertEqual(largeTextUnescaped, largeTextEscaped.unescapeHTML()); 
     286       
     287      this.assertEqual('1\n2', '1\n2'.unescapeHTML()); 
     288      this.assertEqual('Pride & Prejudice', '<h1>Pride &amp; Prejudice</h1>'.unescapeHTML()); 
     289       
     290      this.benchmark(function() { largeTextEscaped.unescapeHTML() }, 1000); 
     291       
     292    }, 
     293     
     294    testTemplateEvaluation: function() { 
    299295      var source = '<tr><td>#{name}</td><td>#{age}</td></tr>'; 
    300296      var person = {name: 'Sam', age: 21}; 
    301297      var template = new Template(source); 
    302298       
    303       assertEqual('<tr><td>Sam</td><td>21</td></tr>', 
     299      this.assertEqual('<tr><td>Sam</td><td>21</td></tr>', 
    304300        template.evaluate(person)); 
    305       assertEqual('<tr><td></td><td></td></tr>', 
     301      this.assertEqual('<tr><td></td><td></td></tr>', 
    306302        template.evaluate({})); 
    307     }}
    308  
    309     testTemplateEvaluationWithEmptyReplacement: function() {with(this) { 
     303    }
     304 
     305    testTemplateEvaluationWithEmptyReplacement: function() { 
    310306      var template = new Template('##{}'); 
    311       assertEqual('#', template.evaluate({})); 
    312       assertEqual('#', template.evaluate({foo: 'bar'})); 
     307      this.assertEqual('#', template.evaluate({})); 
     308      this.assertEqual('#', template.evaluate({foo: 'bar'})); 
    313309 
    314310      template = new Template('#{}'); 
    315       assertEqual('', template.evaluate({})); 
    316     }}
    317  
    318     testTemplateEvaluationWithFalses: function() {with(this) { 
     311      this.assertEqual('', template.evaluate({})); 
     312    }
     313 
     314    testTemplateEvaluationWithFalses: function() { 
    319315      var source = '<tr><td>#{zero}</td><td>#{false_}</td><td>#{undef}</td><td>#{null_}</td><td>#{empty}</td></tr>'; 
    320316      var falses = {zero:0, false_:false, undef:undefined, null_:null, empty:""}; 
    321317      var template = new Template(source); 
    322318       
    323       assertEqual('<tr><td>0</td><td>false</td><td></td><td></td><td></td></tr>', 
     319      this.assertEqual('<tr><td>0</td><td>false</td><td></td><td></td><td></td></tr>', 
    324320        template.evaluate(falses)); 
    325     }}
    326  
    327     testTemplateEvaluationWithNested: function() {with(this) { 
     321    }
     322 
     323    testTemplateEvaluationWithNested: function() { 
    328324      var source = '#{name} #{manager.name} #{manager.age} #{manager.undef} #{manager.age.undef} #{colleagues.first.name}'; 
    329       var subject = { manager: { name: 'John', age: 29 }, name: 'Stephan', age: 22, colleagues: { first: { name: 'Mark' } } }; 
    330       assertEqual('Stephan', new Template('#{name}').evaluate(subject)); 
    331       assertEqual('John', new Template('#{manager.name}').evaluate(subject)); 
    332       assertEqual('29', new Template('#{manager.age}').evaluate(subject)); 
    333       assertEqual('', new Template('#{manager.undef}').evaluate(subject)); 
    334       assertEqual('', new Template('#{manager.age.undef}').evaluate(subject)); 
    335       assertEqual('Mark', new Template('#{colleagues.first.name}').evaluate(subject)); 
    336       assertEqual('Stephan John 29   Mark', new Template(source).evaluate(subject)); 
    337     }}
    338  
    339     testTemplateEvaluationWithIndexing: function() {with(this) { 
     325      var subject = { manager: { name: 'John', age: 29 }, name: 'Stephan', age: 22, colleagues: { first: { name: 'Mark' }} }; 
     326      this.assertEqual('Stephan', new Template('#{name}').evaluate(subject)); 
     327      this.assertEqual('John', new Template('#{manager.name}').evaluate(subject)); 
     328      this.assertEqual('29', new Template('#{manager.age}').evaluate(subject)); 
     329      this.assertEqual('', new Template('#{manager.undef}').evaluate(subject)); 
     330      this.assertEqual('', new Template('#{manager.age.undef}').evaluate(subject)); 
     331      this.assertEqual('Mark', new Template('#{colleagues.first.name}').evaluate(subject)); 
     332      this.assertEqual('Stephan John 29   Mark', new Template(source).evaluate(subject)); 
     333    }
     334 
     335    testTemplateEvaluationWithIndexing: function() { 
    340336      var source = '#{0} = #{[0]} - #{1} = #{[1]} - #{[2][0]} - #{[2].name} - #{first[0]} - #{[first][0]} - #{[\\]]} - #{first[\\]]}'; 
    341337      var subject = [ 'zero', 'one', [ 'two-zero' ] ]; 
     
    344340      subject[']'] = '\\'; 
    345341      subject.first[']'] = 'first\\'; 
    346       assertEqual('zero', new Template('#{[0]}').evaluate(subject)); 
    347       assertEqual('one', new Template('#{[1]}').evaluate(subject)); 
    348       assertEqual('two-zero', new Template('#{[2][0]}').evaluate(subject)); 
    349       assertEqual('two-zero-name', new Template('#{[2].name}').evaluate(subject)); 
    350       assertEqual('two-zero', new Template('#{first[0]}').evaluate(subject)); 
    351       assertEqual('\\', new Template('#{[\\]]}').evaluate(subject)); 
    352       assertEqual('first\\', new Template('#{first[\\]]}').evaluate(subject)); 
    353       assertEqual('empty - empty2', new Template('#{[]} - #{m[]}').evaluate({ '': 'empty', m: {'': 'empty2'}})); 
    354       assertEqual('zero = zero - one = one - two-zero - two-zero-name - two-zero - two-zero - \\ - first\\', new Template(source).evaluate(subject)); 
    355     }}
    356  
    357     testTemplateToTemplateReplacements: function() {with(this) { 
     342      this.assertEqual('zero', new Template('#{[0]}').evaluate(subject)); 
     343      this.assertEqual('one', new Template('#{[1]}').evaluate(subject)); 
     344      this.assertEqual('two-zero', new Template('#{[2][0]}').evaluate(subject)); 
     345      this.assertEqual('two-zero-name', new Template('#{[2].name}').evaluate(subject)); 
     346      this.assertEqual('two-zero', new Template('#{first[0]}').evaluate(subject)); 
     347      this.assertEqual('\\', new Template('#{[\\]]}').evaluate(subject)); 
     348      this.assertEqual('first\\', new Template('#{first[\\]]}').evaluate(subject)); 
     349      this.assertEqual('empty - empty2', new Template('#{[]} - #{m[]}').evaluate({ '': 'empty', m: {'': 'empty2'}})); 
     350      this.assertEqual('zero = zero - one = one - two-zero - two-zero-name - two-zero - two-zero - \\ - first\\', new Template(source).evaluate(subject)); 
     351    }
     352 
     353    testTemplateToTemplateReplacements: function() { 
    358354      var source = 'My name is #{name}, my job is #{job}'; 
    359355      var subject = { 
     
    362358        toTemplateReplacements: function() { return { name: this.name, job: this.getJob() } } 
    363359      }; 
    364       assertEqual('My name is Stephan, my job is Web developer', new Template(source).evaluate(subject)); 
    365     }}
    366  
    367     testTemplateEvaluationCombined: function() {with(this) { 
     360      this.assertEqual('My name is Stephan, my job is Web developer', new Template(source).evaluate(subject)); 
     361    }
     362 
     363    testTemplateEvaluationCombined: function() { 
    368364      var source = '#{name} is #{age} years old, managed by #{manager.name}, #{manager.age}.\n' + 
    369365        'Colleagues include #{colleagues[0].name} and #{colleagues[1].name}.'; 
     
    373369        colleagues: [ { name: 'Mark' }, { name: 'Indy' } ] 
    374370      }; 
    375       assertEqual('Stephan is 22 years old, managed by John, 29.\n' + 
     371      this.assertEqual('Stephan is 22 years old, managed by John, 29.\n' + 
    376372        'Colleagues include Mark and Indy.', 
    377373        new Template(source).evaluate(subject)); 
    378     }}
    379  
    380     testInterpolate: function() {with(this) { 
     374    }
     375 
     376    testInterpolate: function() { 
    381377      var subject = { name: 'Stephan' }; 
    382378      var pattern = /(^|.|\r|\n)(#\((.*?)\))/; 
    383       assertEqual('#{name}: Stephan', '\\#{name}: #{name}'.interpolate(subject)); 
    384       assertEqual('#(name): Stephan', '\\#(name): #(name)'.interpolate(subject, pattern)); 
    385     }}
    386  
    387     testToQueryParams: function() {with(this) { 
     379      this.assertEqual('#{name}: Stephan', '\\#{name}: #{name}'.interpolate(subject)); 
     380      this.assertEqual('#(name): Stephan', '\\#(name): #(name)'.interpolate(subject, pattern)); 
     381    }
     382 
     383    testToQueryParams: function() { 
    388384      // only the query part 
    389385      var result = {a:undefined, b:'c'}; 
    390       assertHashEqual({}, ''.toQueryParams(), 'empty query'); 
    391       assertHashEqual({}, 'foo?'.toQueryParams(), 'empty query with URL'); 
    392       assertHashEqual(result, 'foo?a&b=c'.toQueryParams(), 'query with URL'); 
    393       assertHashEqual(result, 'foo?a&b=c#fragment'.toQueryParams(), 'query with URL and fragment'); 
    394       assertHashEqual(result, 'a;b=c'.toQueryParams(';'), 'custom delimiter'); 
    395      
    396       assertHashEqual({a:undefined}, 'a'.toQueryParams(), 'key without value'); 
    397       assertHashEqual({a:'b'},  'a=b&=c'.toQueryParams(), 'empty key'); 
    398       assertHashEqual({a:'b', c:''}, 'a=b&c='.toQueryParams(), 'empty value'); 
    399        
    400       assertHashEqual({'a b':'c', d:'e f', g:'h'}, 
     386      this.assertHashEqual({}, ''.toQueryParams(), 'empty query'); 
     387      this.assertHashEqual({}, 'foo?'.toQueryParams(), 'empty query with URL'); 
     388      this.assertHashEqual(result, 'foo?a&b=c'.toQueryParams(), 'query with URL'); 
     389      this.assertHashEqual(result, 'foo?a&b=c#fragment'.toQueryParams(), 'query with URL and fragment'); 
     390      this.assertHashEqual(result, 'a;b=c'.toQueryParams(';'), 'custom delimiter'); 
     391     
     392      this.assertHashEqual({a:undefined}, 'a'.toQueryParams(), 'key without value'); 
     393      this.assertHashEqual({a:'b'},  'a=b&=c'.toQueryParams(), 'empty key'); 
     394      this.assertHashEqual({a:'b', c:''}, 'a=b&c='.toQueryParams(), 'empty value'); 
     395       
     396      this.assertHashEqual({'a b':'c', d:'e f', g:'h'}, 
    401397        'a%20b=c&d=e%20f&g=h'.toQueryParams(), 'proper decoding'); 
    402       assertHashEqual({a:'b=c=d'}, 'a=b=c=d'.toQueryParams(), 'multiple equal signs'); 
    403       assertHashEqual({a:'b', c:'d'}, '&a=b&&&c=d'.toQueryParams(), 'proper splitting'); 
    404        
    405       assertEnumEqual($w('r g b'), 'col=r&col=g&col=b'.toQueryParams()['col'], 
     398      this.assertHashEqual({a:'b=c=d'}, 'a=b=c=d'.toQueryParams(), 'multiple equal signs'); 
     399      this.assertHashEqual({a:'b', c:'d'}, '&a=b&&&c=d'.toQueryParams(), 'proper splitting'); 
     400       
     401      this.assertEnumEqual($w('r g b'), 'col=r&col=g&col=b'.toQueryParams()['col'], 
    406402        'collection without square brackets'); 
    407403      var msg = 'empty values inside collection'; 
    408       assertEnumEqual(['r', '', 'b'], 'c=r&c=&c=b'.toQueryParams()['c'], msg); 
    409       assertEnumEqual(['', 'blue'],   'c=&c=blue'.toQueryParams()['c'], msg); 
    410       assertEnumEqual(['blue', ''],   'c=blue&c='.toQueryParams()['c'], msg); 
    411     }}
    412      
    413     testInspect: function() {with(this) { 
    414       assertEqual('\'\'', ''.inspect()); 
    415       assertEqual('\'test\'', 'test'.inspect()); 
    416       assertEqual('\'test \\\'test\\\' "test"\'', 'test \'test\' "test"'.inspect()); 
    417       assertEqual('\"test \'test\' \\"test\\"\"', 'test \'test\' "test"'.inspect(true)); 
    418       assertEqual('\'\\b\\t\\n\\f\\r"\\\\\'', '\b\t\n\f\r"\\'.inspect()); 
    419       assertEqual('\"\\b\\t\\n\\f\\r\\"\\\\\"', '\b\t\n\f\r"\\'.inspect(true)); 
    420       assertEqual('\'\\b\\t\\n\\f\\r\'', '\x08\x09\x0a\x0c\x0d'.inspect()); 
    421       assertEqual('\'\\u001a\'', '\x1a'.inspect()); 
    422     }}
    423      
    424     testInclude: function() {with(this) { 
    425       assert('hello world'.include('h')); 
    426       assert('hello world'.include('hello')); 
    427       assert('hello world'.include('llo w')); 
    428       assert('hello world'.include('world'));       
    429       assert(!'hello world'.include('bye')); 
    430       assert(!''.include('bye')); 
    431     }}
    432      
    433     testStartsWith: function() {with(this) { 
    434       assert('hello world'.startsWith('h')); 
    435       assert('hello world'.startsWith('hello')); 
    436       assert(!'hello world'.startsWith('bye')); 
    437       assert(!''.startsWith('bye')); 
    438       assert(!'hell'.startsWith('hello')); 
    439     }}
    440      
    441     testEndsWith: function() {with(this) { 
    442       assert('hello world'.endsWith('d')); 
    443       assert('hello world'.endsWith(' world')); 
    444       assert(!'hello world'.endsWith('planet')); 
    445       assert(!''.endsWith('planet')); 
    446       assert('hello world world'.endsWith(' world')); 
    447       assert(!'z'.endsWith('az')); 
    448     }}
    449      
    450     testBlank: function() { with(this) { 
    451       assert(''.blank()); 
    452       assert(' '.blank()); 
    453       assert('\t\r\n '.blank()); 
    454       assert(!'a'.blank()); 
    455       assert(!'\t y \n'.blank()); 
    456     }}
    457      
    458     testEmpty: function() { with(this) { 
    459       assert(''.empty()); 
    460       assert(!' '.empty()); 
    461       assert(!'\t\r\n '.empty()); 
    462       assert(!'a'.empty()); 
    463       assert(!'\t y \n'.empty()); 
    464     }}
    465      
    466     testSucc: function() {with(this) { 
    467       assertEqual('b', 'a'.succ()); 
    468       assertEqual('B', 'A'.succ()); 
    469       assertEqual('1', '0'.succ()); 
    470       assertEqual('abce', 'abcd'.succ()); 
    471       assertEqual('{', 'z'.succ()); 
    472       assertEqual(':', '9'.succ()); 
    473     }}
    474  
    475     testTimes: function() {with(this) { 
    476  
    477       assertEqual('', ''.times(0)); 
    478       assertEqual('', ''.times(5)); 
    479       assertEqual('', 'a'.times(-1)); 
    480       assertEqual('', 'a'.times(0)); 
    481       assertEqual('a', 'a'.times(1)); 
    482       assertEqual('aa', 'a'.times(2)); 
    483       assertEqual('aaaaa', 'a'.times(5)); 
    484       assertEqual('foofoofoofoofoo', 'foo'.times(5)); 
    485       assertEqual('', 'foo'.times(-5)); 
     404      this.assertEnumEqual(['r', '', 'b'], 'c=r&c=&c=b'.toQueryParams()['c'], msg); 
     405      this.assertEnumEqual(['', 'blue'],   'c=&c=blue'.toQueryParams()['c'], msg); 
     406      this.assertEnumEqual(['blue', ''],   'c=blue&c='.toQueryParams()['c'], msg); 
     407    }
     408     
     409    testInspect: function() { 
     410      this.assertEqual('\'\'', ''.inspect()); 
     411      this.assertEqual('\'test\'', 'test'.inspect()); 
     412      this.assertEqual('\'test \\\'test\\\' "test"\'', 'test \'test\' "test"'.inspect()); 
     413      this.assertEqual('\"test \'test\' \\"test\\"\"', 'test \'test\' "test"'.inspect(true)); 
     414      this.assertEqual('\'\\b\\t\\n\\f\\r"\\\\\'', '\b\t\n\f\r"\\'.inspect()); 
     415      this.assertEqual('\"\\b\\t\\n\\f\\r\\"\\\\\"', '\b\t\n\f\r"\\'.inspect(true)); 
     416      this.assertEqual('\'\\b\\t\\n\\f\\r\'', '\x08\x09\x0a\x0c\x0d'.inspect()); 
     417      this.assertEqual('\'\\u001a\'', '\x1a'.inspect()); 
     418    }
     419     
     420    testInclude: function() { 
     421      this.assert('hello world'.include('h')); 
     422      this.assert('hello world'.include('hello')); 
     423      this.assert('hello world'.include('llo w')); 
     424      this.assert('hello world'.include('world'));       
     425      this.assert(!'hello world'.include('bye')); 
     426      this.assert(!''.include('bye')); 
     427    }
     428     
     429    testStartsWith: function() { 
     430      this.assert('hello world'.startsWith('h')); 
     431      this.assert('hello world'.startsWith('hello')); 
     432      this.assert(!'hello world'.startsWith('bye')); 
     433      this.assert(!''.startsWith('bye')); 
     434      this.assert(!'hell'.startsWith('hello')); 
     435    }
     436     
     437    testEndsWith: function() { 
     438      this.assert('hello world'.endsWith('d')); 
     439      this.assert('hello world'.endsWith(' world')); 
     440      this.assert(!'hello world'.endsWith('planet')); 
     441      this.assert(!''.endsWith('planet')); 
     442      this.assert('hello world world'.endsWith(' world')); 
     443      this.assert(!'z'.endsWith('az')); 
     444    }
     445     
     446    testBlank: function() { 
     447      this.assert(''.blank()); 
     448      this.assert(' '.blank()); 
     449      this.assert('\t\r\n '.blank()); 
     450      this.assert(!'a'.blank()); 
     451      this.assert(!'\t y \n'.blank()); 
     452    }
     453     
     454    testEmpty: function() { 
     455      this.assert(''.empty()); 
     456      this.assert(!' '.empty()); 
     457      this.assert(!'\t\r\n '.empty()); 
     458      this.assert(!'a'.empty()); 
     459      this.assert(!'\t y \n'.empty()); 
     460    }
     461     
     462    testSucc: function() { 
     463      this.assertEqual('b', 'a'.succ()); 
     464      this.assertEqual('B', 'A'.succ()); 
     465      this.assertEqual('1', '0'.succ()); 
     466      this.assertEqual('abce', 'abcd'.succ()); 
     467      this.assertEqual('{', 'z'.succ()); 
     468      this.assertEqual(':', '9'.succ()); 
     469    }
     470 
     471    testTimes: function() { 
     472 
     473      this.assertEqual('', ''.times(0)); 
     474      this.assertEqual('', ''.times(5)); 
     475      this.assertEqual('', 'a'.times(-1)); 
     476      this.assertEqual('', 'a'.times(0)); 
     477      this.assertEqual('a', 'a'.times(1)); 
     478      this.assertEqual('aa', 'a'.times(2)); 
     479      this.assertEqual('aaaaa', 'a'.times(5)); 
     480      this.assertEqual('foofoofoofoofoo', 'foo'.times(5)); 
     481      this.assertEqual('', 'foo'.times(-5)); 
    486482       
    487483      /*window.String.prototype.oldTimes = function(count) { 
     
    491487      }; 
    492488       
    493       benchmark(function() { 
     489      this.benchmark(function() { 
    494490        'foo'.times(15); 
    495491      }, 1000, 'new: '); 
    496492       
    497       benchmark(function() { 
     493      this.benchmark(function() { 
    498494        'foo'.oldTimes(15); 
    499495      }, 1000, 'previous: ');*/ 
    500     }}
    501      
    502     testToJSON: function() {with(this) { 
    503       assertEqual('\"\"', ''.toJSON()); 
    504       assertEqual('\"test\"', 'test'.toJSON()); 
    505     }}
    506      
    507     testIsJSON: function() {with(this) { 
    508       assert(!''.isJSON()); 
    509       assert(!'     '.isJSON()); 
    510       assert('""'.isJSON()); 
    511       assert('"foo"'.isJSON()); 
    512       assert('{}'.isJSON()); 
    513       assert('[]'.isJSON()); 
    514       assert('null'.isJSON()); 
    515       assert('123'.isJSON()); 
    516       assert('true'.isJSON()); 
    517       assert('false'.isJSON()); 
    518       assert('"\\""'.isJSON()); 
    519       assert(!'\\"'.isJSON()); 
    520       assert(!'new'.isJSON()); 
    521       assert(!'\u0028\u0029'.isJSON()); 
     496    }
     497     
     498    testToJSON: function() { 
     499      this.assertEqual('\"\"', ''.toJSON()); 
     500      this.assertEqual('\"test\"', 'test'.toJSON()); 
     501    }
     502     
     503    testIsJSON: function() { 
     504      this.assert(!''.isJSON()); 
     505      this.assert(!'     '.isJSON()); 
     506      this.assert('""'.isJSON()); 
     507      this.assert('"foo"'.isJSON()); 
     508      this.assert('{}'.isJSON()); 
     509      this.assert('[]'.isJSON()); 
     510      this.assert('null'.isJSON()); 
     511      this.assert('123'.isJSON()); 
     512      this.assert('true'.isJSON()); 
     513      this.assert('false'.isJSON()); 
     514      this.assert('"\\""'.isJSON()); 
     515      this.assert(!'\\"'.isJSON()); 
     516      this.assert(!'new'.isJSON()); 
     517      this.assert(!'\u0028\u0029'.isJSON()); 
    522518      // we use '@' as a placeholder for characters authorized only inside brackets, 
    523519      // so this tests make sure it is not considered authorized elsewhere. 
    524       assert(!'@'.isJSON()); 
    525     }}
    526  
    527     testEvalJSON: function() {with(this) { 
     520      this.assert(!'@'.isJSON()); 
     521    }
     522 
     523    testEvalJSON: function() { 
    528524      var valid = '{"test": \n\r"hello world!"}'; 
    529525      var invalid = '{"test": "hello world!"'; 
     
    536532      var huge = '[' + object.times(size) + '{"test": 123}]'; 
    537533       
    538       assertEqual('hello world!', valid.evalJSON().test); 
    539       assertEqual('hello world!', valid.evalJSON(true).test); 
    540       assertRaise('SyntaxError', function(){invalid.evalJSON();}); 
    541       assertRaise('SyntaxError', function(){invalid.evalJSON(true);}); 
    542  
    543       attackTarget = "scared";       
     534      this.assertEqual('hello world!', valid.evalJSON().test); 
     535      this.assertEqual('hello world!', valid.evalJSON(true).test); 
     536      this.assertRaise('SyntaxError', function() { invalid.evalJSON() }); 
     537      this.assertRaise('SyntaxError', function() { invalid.evalJSON(true) }); 
     538 
     539      attackTarget = "scared"; 
    544540      dangerous.evalJSON(); 
    545       assertEqual("attack succeeded!", attackTarget); 
     541      this.assertEqual("attack succeeded!", attackTarget); 
    546542       
    547543      attackTarget = "Not scared!"; 
    548       assertRaise('SyntaxError', function(){dangerous.evalJSON(true)}); 
    549       assertEqual("Not scared!", attackTarget); 
    550  
    551       assertEqual('hello world!', ('/*-secure- \r  \n ' + valid + ' \n  */').evalJSON().test); 
     544      this.assertRaise('SyntaxError', function(){dangerous.evalJSON(true)}); 
     545      this.assertEqual("Not scared!", attackTarget); 
     546 
     547      this.assertEqual('hello world!', ('/*-secure- \r  \n ' + valid + ' \n  */').evalJSON().test); 
    552548      var temp = Prototype.JSONFilter; 
    553549      Prototype.JSONFilter = /^\/\*([\s\S]*)\*\/$/; // test custom delimiters. 
    554       assertEqual('hello world!', ('/*' + valid + '*/').evalJSON().test); 
     550      this.assertEqual('hello world!', ('/*' + valid + '*/').evalJSON().test); 
    555551      Prototype.JSONFilter = temp; 
    556552       
    557       assertMatch(123, huge.evalJSON(true).last().test); 
    558        
    559       assertEqual('', '""'.evalJSON()); 
    560       assertEqual('foo', '"foo"'.evalJSON()); 
    561       assert('object', typeof '{}'.evalJSON()); 
    562       assert(Object.isArray('[]'.evalJSON())); 
    563       assertNull('null'.evalJSON()); 
    564       assert(123, '123'.evalJSON()); 
    565       assertIdentical(true, 'true'.evalJSON()); 
    566       assertIdentical(false, 'false'.evalJSON()); 
    567       assertEqual('"', '"\\""'.evalJSON()); 
    568     }} 
     553      this.assertMatch(123, huge.evalJSON(true).last().test); 
     554       
     555      this.assertEqual('', '""'.evalJSON()); 
     556      this.assertEqual('foo', '"foo"'.evalJSON()); 
     557      this.assert('object', typeof '{}'.evalJSON()); 
     558      this.assert(Object.isArray('[]'.evalJSON())); 
     559      this.assertNull('null'.evalJSON()); 
     560      this.assert(123, '123'.evalJSON()); 
     561      this.assertIdentical(true, 'true'.evalJSON()); 
     562      this.assertIdentical(false, 'false'.evalJSON()); 
     563      this.assertEqual('"', '"\\""'.evalJSON()); 
     564    } 
    569565  }); 
    570566// ]]> 
  • spinoffs/prototype/trunk/test/unit/unit_tests.html

    r8643 r9036  
    5757  new Test.Unit.Runner({ 
    5858     
    59     testIsRunningFromRake:  function() { with(this) { 
     59    testIsRunningFromRake:  function() { 
    6060      if (window.location.toString().startsWith('http')) { 
    61         assert(isRunningFromRake); 
    62         info('These tests are running from rake.') 
     61        this.assert(this.isRunningFromRake); 
     62        this.info('These tests are running from rake.') 
    6363      } else { 
    64         assert(!isRunningFromRake); 
    65         info('These tests are *not* running from rake.') 
     64        this.assert(!this.isRunningFromRake); 
     65        this.info('These tests are *not* running from rake.') 
    6666      } 
    67     }}
     67    }
    6868 
    6969    testBuildMessage:  function() { 
     
    7171    }, 
    7272     
    73     testAssertEqual: function() { with(this) { 
    74       assertEqual(0, 0); 
    75       assertEqual(0, 0, "test"); 
     73    testAssertEqual: function() { 
     74      this.assertEqual(0, 0); 
     75      this.assertEqual(0, 0, "test"); 
    7676       
    77       assertEqual(0,'0'); 
    78       assertEqual(65.0, 65); 
     77      this.assertEqual(0,'0'); 
     78      this.assertEqual(65.0, 65); 
    7979       
    80       assertEqual("a", "a"); 
    81       assertEqual("a", "a", "test"); 
     80      this.assertEqual("a", "a"); 
     81      this.assertEqual("a", "a", "test"); 
    8282       
    83       assertNotEqual(0, 1); 
    84       assertNotEqual("a","b"); 
    85       assertNotEqual({},{}); 
    86       assertNotEqual([],[]); 
    87       assertNotEqual([],{}); 
    88     }}
     83      this.assertNotEqual(0, 1); 
     84      this.assertNotEqual("a","b"); 
     85      this.assertNotEqual({},{}); 
     86      this.assertNotEqual([],[]); 
     87      this.assertNotEqual([],{}); 
     88    }
    8989 
    90     testAssertEnumEqual: function() { with(this) { 
    91       assertEnumEqual([], []); 
    92       assertEnumEqual(['a', 'b'], ['a', 'b']); 
    93       assertEnumEqual(['1', '2'], [1, 2]); 
    94       assertEnumNotEqual(['1', '2'], [1, 2, 3]); 
    95     }}
     90    testAssertEnumEqual: function() { 
     91      this.assertEnumEqual([], []); 
     92      this.assertEnumEqual(['a', 'b'], ['a', 'b']); 
     93      this.assertEnumEqual(['1', '2'], [1, 2]); 
     94      this.assertEnumNotEqual(['1', '2'], [1, 2, 3]); 
     95    }
    9696     
    97     testAssertHashEqual: function() { with(this) { 
    98       assertHashEqual({}, {}); 
    99       assertHashEqual({a:'b'}, {a:'b'}); 
    100       assertHashEqual({a:'b', c:'d'}, {c:'d', a:'b'}); 
    101       assertHashNotEqual({a:'b', c:'d'}, {c:'d', a:'boo!'}); 
    102     }}
     97    testAssertHashEqual: function() { 
     98      this.assertHashEqual({}, {}); 
     99      this.assertHashEqual({a:'b'}, {a:'b'}); 
     100      this.assertHashEqual({a:'b', c:'d'}, {c:'d', a:'b'}); 
     101      this.assertHashNotEqual({a:'b', c:'d'}, {c:'d', a:'boo!'}); 
     102    }
    103103     
    104     testAssertRespondsTo: function() { with(this) { 
    105       assertRespondsTo('isNice', testObj); 
    106       assertRespondsTo('isBroken', testObj); 
    107     }}
     104    testAssertRespondsTo: function() { 
     105      this.assertRespondsTo('isNice', testObj); 
     106      this.assertRespondsTo('isBroken', testObj); 
     107    }
    108108     
    109     testAssertIdentical: function() { with(this) {  
    110       assertIdentical(0, 0);  
    111       assertIdentical(0, 0, "test");  
    112       assertIdentical(1, 1);  
    113       assertIdentical('a', 'a');  
    114       assertIdentical('a', 'a', "test");  
    115       assertIdentical('', '');  
    116       assertIdentical(undefined, undefined);  
    117       assertIdentical(null, null);  
    118       assertIdentical(true, true);  
    119       assertIdentical(false, false);  
     109    testAssertIdentical: function() {  
     110      this.assertIdentical(0, 0);  
     111      this.assertIdentical(0, 0, "test");  
     112      this.assertIdentical(1, 1);  
     113      this.assertIdentical('a', 'a');  
     114      this.assertIdentical('a', 'a', "test");  
     115      this.assertIdentical('', '');  
     116      this.assertIdentical(undefined, undefined);  
     117      this.assertIdentical(null, null);  
     118      this.assertIdentical(true, true);  
     119      this.assertIdentical(false, false);  
    120120       
    121121      var obj = {a:'b'}; 
    122       assertIdentical(obj, obj); 
     122      this.assertIdentical(obj, obj); 
    123123       
    124       assertNotIdentical({1:2,3:4},{1:2,3:4}); 
     124      this.assertNotIdentical({1:2,3:4},{1:2,3:4}); 
    125125       
    126       assertIdentical(1, 1.0); // both are typeof == 'number' 
     126      this.assertIdentical(1, 1.0); // both are typeof == 'number' 
    127127       
    128       assertNotIdentical(1, '1'); 
    129       assertNotIdentical(1, '1.0'); 
    130     }}
     128      this.assertNotIdentical(1, '1'); 
     129      this.assertNotIdentical(1, '1.0'); 
     130    }
    131131     
    132     testAssertNullAndAssertUndefined: function() { with(this) { 
    133       assertNull(null); 
    134       assertNotNull(undefined); 
    135       assertNotNull(0); 
    136       assertNotNull(''); 
    137       assertNotUndefined(null); 
    138       assertUndefined(undefined); 
    139       assertNotUndefined(0); 
    140       assertNotUndefined(''); 
    141       assertNullOrUndefined(null); 
    142       assertNullOrUndefined(undefined); 
    143       assertNotNullOrUndefined(0); 
    144       assertNotNullOrUndefined(''); 
    145     }}
     132    testAssertNullAndAssertUndefined: function() { 
     133      this.assertNull(null); 
     134      this.assertNotNull(undefined); 
     135      this.assertNotNull(0); 
     136      this.assertNotNull(''); 
     137      this.assertNotUndefined(null); 
     138      this.assertUndefined(undefined); 
     139      this.assertNotUndefined(0); 
     140      this.assertNotUndefined(''); 
     141      this.assertNullOrUndefined(null); 
     142      this.assertNullOrUndefined(undefined); 
     143      this.assertNotNullOrUndefined(0); 
     144      this.assertNotNullOrUndefined(''); 
     145    }
    146146     
    147     testAssertMatch: function() { with(this) { 
    148       assertMatch(/knowmad.jpg$/, 'http://script.aculo.us/images/knowmad.jpg'); 
    149       assertMatch(/Fuc/, 'Thomas Fuchs'); 
    150       assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95'); 
    151       assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330'); 
    152       assertMatch(/^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$/, '2001-06-16'); 
    153       assertMatch(/^((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m\s*-\s*((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m$/i, '2:00PM-2:15PM'); 
    154       assertNoMatch(/zubar/, 'foo bar'); 
    155     }}
     147    testAssertMatch: function() { 
     148      this.assertMatch(/knowmad.jpg$/, 'http://script.aculo.us/images/knowmad.jpg'); 
     149      this.assertMatch(/Fuc/, 'Thomas Fuchs'); 
     150      this.assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95'); 
     151      this.assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330'); 
     152      this.assertMatch(/^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$/, '2001-06-16'); 
     153      this.assertMatch(/^((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m\s*-\s*((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m$/i, '2:00PM-2:15PM'); 
     154      this.assertNoMatch(/zubar/, 'foo bar'); 
     155    }
    156156     
    157     testAssertInstanceOf: function() { with(this) { 
    158       assertInstanceOf(String, new String); 
    159       assertInstanceOf(RegExp, /foo/); 
    160       assertNotInstanceOf(String, {}); 
    161     }}
     157    testAssertInstanceOf: function() { 
     158      this.assertInstanceOf(String, new String); 
     159      this.assertInstanceOf(RegExp, /foo/); 
     160      this.assertNotInstanceOf(String, {}); 
     161    }
    162162     
    163     testAssertVisible: function() { with(this) { 
    164       assertVisible('testcss1'); 
    165       assertNotVisible('testcss1_span'); 
    166       //assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari."); 
     163    testAssertVisible: function() { 
     164      this.assertVisible('testcss1'); 
     165      this.assertNotVisible('testcss1_span'); 
     166      //this.assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari."); 
    167167       
    168168      Element.hide('testcss1'); 
    169       assertNotVisible('testcss1'); 
    170       assertNotVisible('testcss1_span'); 
     169      this.assertNotVisible('testcss1'); 
     170      this.assertNotVisible('testcss1_span'); 
    171171      Element.show('testcss1'); 
    172       assertVisible('testcss1'); 
    173       assertNotVisible('testcss1_span'); 
     172      this.assertVisible('testcss1'); 
     173      this.assertNotVisible('testcss1_span'); 
    174174       
    175175      Element.show('testcss1_span'); 
    176       assertVisible('testcss1_span'); 
     176      this.assertVisible('testcss1_span'); 
    177177      Element.hide('testcss1'); 
    178       assertNotVisible('testcss1_span'); // hidd