Ticket #11481: constructor_explicit_return.diff
| File constructor_explicit_return.diff, 1.5 kB (added by cch1, 3 months ago) |
|---|
-
/Users/cch1/Documents/Development/prototype/src/base.js
old new 6 6 parent = properties.shift(); 7 7 8 8 function klass() { 9 this.initialize.apply(this, arguments);9 return this.initialize.apply(this, arguments); 10 10 } 11 11 12 12 Object.extend(klass, Class.Methods); -
test/unit/base.html
old new 564 564 this.assert(gonzo.extinct, 'Dodo birds should be extinct'); 565 565 this.assertEqual("Gonzo: hello honk honk", gonzo.say("hello")); 566 566 }, 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 }, 567 587 568 588 testClassAddMethods: function() { 569 589 var tom = new Cat('Tom');