Commit Graph

21 Commits

Author SHA1 Message Date
mpeterv
ab1699bb05 Do not wrap __newindex 2015-11-28 18:10:35 +03:00
mpeterv
7574380519 Add tests for custom __index and __newindex 2015-11-24 18:48:17 +03:00
mpeterv
524d0ddc8c Fix not inheriting metamethods from grandparent class 2015-11-23 15:42:49 +03:00
mpeterv
b66ba54ccb Add tests for __mode 2015-11-19 14:10:38 +03:00
mpeterv
b0b655d1c0 Add tests for __metatable 2015-11-19 13:59:19 +03:00
mpeterv
0f9d5c8e61 Add tests for overriding metamethods 2015-11-19 13:13:04 +03:00
mpeterv
d9f00351b2 Implement inheritable metamethods without stubs
In __newindex metamethods of each Class detect if
a metamethod is assigned. In that case, propogate assignment
to all child classes that do not overwrite the metamethod.
Track set of metamethods each class defines itself.
On subclassing, copy all parent metamethods to child.

Benefits of this approach:

* Objects only have metamethods when they are, in fact, defined.
  Ignoring overhead, the problem with stubs is that other libraries,
  seeing a stub metamethod, could try to call it and get an error
  if it's missing in the class. E.g. various deep comparison functions
  often try to detect and use __eq.
* Non-function metafields such as __metatable can be used.
* Less overhead when using metamethods (but more when defining them).
2015-11-19 13:05:09 +03:00
kikito
a5a334c775 splits 5.2 and 5.3 metamethods into separate files. Fixes 5.3 errors 2015-11-01 17:09:15 +01:00
kikito
cd8ce449e1 make lua < 5.3 not fret about new operators by using eval in 5.3 sections 2015-10-31 17:16:10 +01:00
kikito
1a9d1146cf add missing parenthesis to two function calls 2015-10-31 16:53:19 +01:00
kikito
4c1f15c055 adds failing lua 5.3 metamethods tests 2015-10-31 16:50:11 +01:00
kikito
6dd3294b70 modify metamethod test to account for new initialization 2015-10-12 23:45:32 +02:00
kikito
2561f0b26b attempts to fix failing travis 2015-10-12 13:49:50 +02:00
kikito
512e6c2968 __gc metamethod for 5.3 2015-10-12 13:39:35 +02:00
kikito
b7b1b47980 skip 5.2 tests on 5.1 mode 2013-12-05 01:15:28 +01:00
kenshin
b89bf82db4 supplement unit test for __len, __pairs, __ipairs 2013-12-04 18:09:54 +08:00
kikito
157ebac7e7 ported tests to busted 2013-09-17 20:55:50 +02:00
kikito
3ac8aa167f fixed the rest of the tests 2013-09-17 01:06:24 +02:00
kikito
cd9609e1ae made Object non-global 2013-09-15 23:18:08 +02:00
kikito
88e84d13c2 made class non-global 2013-09-15 23:14:00 +02:00
Enrique García Cota
da557bb207 split tests more. refactorized class creation. included metamethod support 2011-08-12 10:33:58 +02:00