mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
fixing super() calls, thanks to tolmasky
This commit is contained in:
23
test/fixtures/execution/calling_super.cs
vendored
Normal file
23
test/fixtures/execution/calling_super.cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Base: => .
|
||||
Base.prototype.func: string =>
|
||||
'zero/' + string.
|
||||
|
||||
FirstChild: => .
|
||||
FirstChild.prototype.__proto__: new Base()
|
||||
FirstChild.prototype.func: string =>
|
||||
super('one/') + string.
|
||||
|
||||
SecondChild: => .
|
||||
SecondChild.prototype.__proto__: new FirstChild()
|
||||
SecondChild.prototype.func: string =>
|
||||
super('two/') + string.
|
||||
|
||||
ThirdChild: => .
|
||||
ThirdChild.prototype.__proto__: new SecondChild()
|
||||
ThirdChild.prototype.func: string =>
|
||||
super('three/') + string.
|
||||
|
||||
result: (new ThirdChild()).func('four')
|
||||
|
||||
print(result is 'zero/one/two/three/four')
|
||||
|
||||
27
test/fixtures/execution/calling_super.js
vendored
Normal file
27
test/fixtures/execution/calling_super.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
(function(){
|
||||
var Base = function() {
|
||||
};
|
||||
Base.prototype.func = function(string) {
|
||||
return 'zero/' + string;
|
||||
};
|
||||
var FirstChild = function() {
|
||||
};
|
||||
FirstChild.prototype.__proto__ = new Base();
|
||||
FirstChild.prototype.func = function(string) {
|
||||
return FirstChild.prototype.__proto__.func.call(this, 'one/') + string;
|
||||
};
|
||||
var SecondChild = function() {
|
||||
};
|
||||
SecondChild.prototype.__proto__ = new FirstChild();
|
||||
SecondChild.prototype.func = function(string) {
|
||||
return SecondChild.prototype.__proto__.func.call(this, 'two/') + string;
|
||||
};
|
||||
var ThirdChild = function() {
|
||||
};
|
||||
ThirdChild.prototype.__proto__ = new SecondChild();
|
||||
ThirdChild.prototype.func = function(string) {
|
||||
return ThirdChild.prototype.__proto__.func.call(this, 'three/') + string;
|
||||
};
|
||||
var result = (new ThirdChild()).func('four');
|
||||
print(result === 'zero/one/two/three/four');
|
||||
})();
|
||||
Reference in New Issue
Block a user