jashkenas--coffeescript/test/test_calling_super.coffee

42 lines
780 B
CoffeeScript
Raw Normal View History

Base: ->
Base::func: (string) ->
2009-12-28 23:08:02 -05:00
'zero/' + string
FirstChild: ->
FirstChild extends Base
FirstChild::func: (string) ->
2009-12-28 23:08:02 -05:00
super('one/') + string
SecondChild: ->
SecondChild extends FirstChild
SecondChild::func: (string) ->
2009-12-28 23:08:02 -05:00
super('two/') + string
ThirdChild: ->
@array: [1, 2, 3]
this
ThirdChild extends SecondChild
ThirdChild::func: (string) ->
2009-12-28 23:08:02 -05:00
super('three/') + string
result: (new ThirdChild()).func 'four'
ok result is 'zero/one/two/three/four', 'successfully set up and called a four-level inheritance chain'
2010-01-08 10:54:44 -05:00
TopClass: (arg) ->
@prop: 'top-' + arg
this
2010-01-08 10:54:44 -05:00
SuperClass: (arg) ->
super 'super-' + arg
this
2010-01-08 10:54:44 -05:00
SubClass: ->
super 'sub'
this
2010-01-08 10:54:44 -05:00
SuperClass extends TopClass
SubClass extends SuperClass
ok (new SubClass()).prop is 'top-super-sub', 'inheritance'