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

Ticket #11481: constructor_explicit_return.diff

File constructor_explicit_return.diff, 1.5 kB (added by cch1, 3 months ago)

Removed debugging code from test.

  • /Users/cch1/Documents/Development/prototype/src/base.js

    old new  
    66      parent = properties.shift(); 
    77     
    88    function klass() { 
    9       this.initialize.apply(this, arguments); 
     9      return this.initialize.apply(this, arguments); 
    1010    } 
    1111     
    1212    Object.extend(klass, Class.Methods); 
  • test/unit/base.html

    old new  
    564564      this.assert(gonzo.extinct, 'Dodo birds should be extinct'); 
    565565      this.assertEqual("Gonzo: hello honk honk", gonzo.say("hello")); 
    566566    }, 
     567         
     568        testConstructorExplicitReturn: function() { 
     569                var Dog = Class.create(Animal, {}); 
     570                Dog.akc_registry = $H(); 
     571                Dog.addMethods({ 
     572                        initialize: function($super, name, id) { 
     573                                if (instance = this.constructor.akc_registry.get(id)) return instance; 
     574                                $super(name); 
     575                                this.id = id; 
     576                                if (this.id) this.constructor.akc_registry.set(id, this); 
     577                        }, 
     578                        setBreed: function(s) { 
     579                                this.breed = s; 
     580                        } 
     581                }) 
     582                var spot = new Dog('Spot', 23456); 
     583                spot.setBreed('Weimaraner'); 
     584                var fido = new Dog('Fido', 23456); 
     585                this.assertEqual('Weimaraner', fido.breed, 'Cached value not returned -constructor returns ignored.'); 
     586        }, 
    567587 
    568588    testClassAddMethods: function() { 
    569589      var tom   = new Cat('Tom');