From 7aa63b2b61c90c26f1f742356fc28269978923eb Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sun, 6 Dec 2015 11:24:42 -0800 Subject: [PATCH] update specs for new class super --- spec/inputs/class.moon | 19 +++++++++-- spec/outputs/class.lua | 74 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/spec/inputs/class.moon b/spec/inputs/class.moon index 27fde65..af03994 100644 --- a/spec/inputs/class.moon +++ b/spec/inputs/class.moon @@ -186,13 +186,28 @@ class Cool extends Thing world: -> super.one } - -- -class Cool extends Thing +class Whack extends Thing dang: do_something => super! +--- +class Wowha extends Thing + @butt: -> + super! + super.hello + super\hello! + super\hello + + + @butt: cool { + -> + super! + super.hello + super\hello! + super\hello + } nil diff --git a/spec/outputs/class.lua b/spec/outputs/class.lua index e9ce06b..aebacbd 100644 --- a/spec/outputs/class.lua +++ b/spec/outputs/class.lua @@ -126,7 +126,7 @@ do local _parent_0 = Hi local _base_0 = { cool = function(self) - return _class_0.__parent.cool(self, 120302) + return _class_0.__parent.__base.cool(self, 120302) end } _base_0.__index = _base_0 @@ -193,7 +193,7 @@ do local _parent_0 = Okay local _base_0 = { something = function(self) - _class_0.__parent.something(self, 1, 2, 3, 4) + _class_0.__parent.__base.something(self, 1, 2, 3, 4) _class_0.__parent.something(another_self, 1, 2, 3, 4) return assert(_class_0.__parent == Okay) end @@ -336,7 +336,7 @@ do local _class_0 local _base_0 = { hi = function(self) - _class_0.__parent.hi(self, 1, 2, 3, 4)(1, 2, 3, 4) + _class_0.__parent.__base.hi(self, 1, 2, 3, 4)(1, 2, 3, 4) _class_0.__parent.something(1, 2, 3, 4) local _ = _class_0.__parent.something(1, 2, 3, 4).world _class_0.__parent.yeah(self, "world").okay(hi, hi, hi) @@ -768,7 +768,7 @@ do dang = function(self) return { hello = function() - return _class_0.__parent.dang(self) + return _class_0.__parent.__base.dang(self) end, world = function() return _class_0.__parent.one @@ -814,7 +814,7 @@ do local _parent_0 = Thing local _base_0 = { dang = do_something(function(self) - return _class_0.__parent.dang(self) + return _class_0.__parent.__base.dang(self) end) } _base_0.__index = _base_0 @@ -824,7 +824,7 @@ do return _class_0.__parent.__init(self, ...) end, __base = _base_0, - __name = "Cool", + __name = "Whack", __parent = _parent_0 }, { __index = function(cls, name) @@ -848,6 +848,66 @@ do if _parent_0.__inherited then _parent_0.__inherited(_parent_0, _class_0) end - Cool = _class_0 + Whack = _class_0 +end +do + local _class_0 + local _parent_0 = Thing + local _base_0 = { } + _base_0.__index = _base_0 + setmetatable(_base_0, _parent_0.__base) + _class_0 = setmetatable({ + __init = function(self, ...) + return _class_0.__parent.__init(self, ...) + end, + __base = _base_0, + __name = "Wowha", + __parent = _parent_0 + }, { + __index = function(cls, name) + local val = rawget(_base_0, name) + if val == nil then + local parent = rawget(cls, "__parent") + if parent then + return parent[name] + end + else + return val + end + end, + __call = function(cls, ...) + local _self_0 = setmetatable({}, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end + }) + _base_0.__class = _class_0 + local self = _class_0 + self.butt = function() + _class_0.__parent.butt(self) + _ = _class_0.__parent.hello + _class_0.__parent.hello(self) + local _base_1 = _class_0.__parent + local _fn_0 = _base_1.hello + return function(...) + return _fn_0(self, ...) + end + end + self.butt = cool({ + function() + _class_0.__parent.butt(self) + _ = _class_0.__parent.hello + _class_0.__parent.hello(self) + local _base_1 = _class_0.__parent + local _fn_0 = _base_1.hello + return function(...) + return _fn_0(self, ...) + end + end + }) + if _parent_0.__inherited then + _parent_0.__inherited(_parent_0, _class_0) + end + Wowha = _class_0 end return nil \ No newline at end of file