Skip to content

Commit

Permalink
Add changelog line and tests for grandparent _init
Browse files Browse the repository at this point in the history
  • Loading branch information
mcclure committed Feb 7, 2019
1 parent f2115ee commit dc2bb9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Fixed placeholder expressions being evaluated assuming wrong binary operator associativity (e.g. `_1-(_2+_3)` was evaluated as `(_1-_2)+_3`.
- Fixed placeholder expressions being evaluated as if unary operators take precedence over power operator (e.g. `(-_1)^_2`) was evaluated as `-(_1^2)`).
- Fixed vulnerable backtracking pattern in `pl.stringx.strip` (#275)
- In `pl.class`, `_init` can now be inherited from grandparent (or older ancestor) classes. (#289)

## 1.5.4 (2017-07-17)

Expand Down
30 changes: 30 additions & 0 deletions tests/test-class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,36 @@ c = C()
c:foo()

asserteq(c,{a=1,b=2,c=3,eee=1})

-- test indirect inherit

D = class(C)

E = class(D)

function E:_init ()
self:super()
self.e = 4
end

function E:foo ()
-- recommended way to call inherited version of method...
self.eeee = 5
C.foo(self)
end

F = class(E)

function F:_init ()
self:super()
self.f = 6
end

f = F()
f:foo()

asserteq(f,{a=1,b=2,c=3,eee=1,e=4,eeee=5,f=6})

--- class methods!
assert(c:is_a(C))
assert(c:is_a(B))
Expand Down

0 comments on commit dc2bb9b

Please sign in to comment.