Commit Graph

48 Commits

Author SHA1 Message Date
Enrique García Cota
ccab332079 isInstanceOf works on primitives.
Fixes #55
2018-03-07 09:27:56 -08:00
kikito
2bcef2b9ff simplifies isInstanceOf & isSubclassOf. Fixes #39 2016-07-02 06:00:03 +02:00
kikito
bffb00b195 fixes luacheck errors 2016-01-02 09:57:00 +01:00
kikito
958cae6c1c restores :allocate and adds more documentation 2015-12-31 00:47:37 +01:00
kikito
7894eb7790 Refactor & remove class:allocate 2015-12-27 23:53:10 +01:00
kikito
0f20fc4288 removes default includes(mixin) method and __mixins attribute 2015-12-13 01:13:49 +01:00
kikito
d5776a20ed makes Object a mixin instead of a global variable 2015-12-13 01:06:23 +01:00
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
f331dc4248 Fix __gc tests
Tests for inherited __gc used to pass even without the feature being
implemented, most likely because objects from previous tests got
collected just in time.
2015-11-19 13:53:51 +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
d15cc25194 added subclassOf, instanceOf and includes specs to object 2013-09-18 23:42:16 +02:00
kikito
157ebac7e7 ported tests to busted 2013-09-17 20:55:50 +02:00
kikito
f5aac38418 made includes a private method 2013-09-17 01:14:57 +02:00
kikito
3ac8aa167f fixed the rest of the tests 2013-09-17 01:06:24 +02:00
kikito
583a3d29e1 fixed subclasOf_spec 2013-09-17 01:04:54 +02:00
kikito
219550cd58 started working on 3.0 2013-09-16 10:37:56 +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
c2e4fce043 mixins now support static methods 2011-09-18 17:40:50 +02:00
Enrique García Cota
1df9ccf178 added list of subclasses per class 2011-08-14 18:39:57 +02:00
Enrique García Cota
252b63f8f6 removed mixin parameters. Added possibility of including several mixins simultaneously 2011-08-14 18:07:44 +02:00
Enrique García Cota
69d469b67a added subclassed hook method 2011-08-14 00:08:33 +02:00
Enrique García Cota
6c9f6a0074 added mixin support 2011-08-13 23:58:55 +02:00
Enrique García Cota
ce3be2d45b Class.superclass -> Class.super . YEAH 2011-08-13 03:38:31 +02:00
Enrique García Cota
af03b4f6d8 fixed error in Object_spec that made other tests fail in some cases. Added some minor optimizations & fixes 2011-08-13 03:12:21 +02:00
Enrique García Cota
da557bb207 split tests more. refactorized class creation. included metamethod support 2011-08-12 10:33:58 +02:00
Enrique García Cota
90bef60d86 fixed test with Object() 2011-08-11 11:36:23 +02:00
Enrique Garcia Cota
40e14838a2 added instanceOf and subclassOf, as well as splitted into more files. Having issues with Object() (call metamethod) 2011-08-10 21:45:15 +02:00
Enrique García Cota
02f5f05b6a class methods and attributes work. Object spec is nearly finished 2011-08-09 00:06:05 +02:00
Enrique García Cota
0e637ea8da separated into more files added instancemethods and attributes 2011-08-08 23:59:23 +02:00
Enrique García Cota
fc682e12dd initial implementation of allocate and new done 2011-08-08 23:18:15 +02:00
Enrique García Cota
7487c9ba79 added the initial subclass implementation. renamed Class.class to Class.static 2011-08-08 22:29:18 +02:00
Enrique García Cota
3461767eba discarded static() approach due to syntax error. Using Class.class for static variables 2011-08-08 07:38:11 +02:00
Enrique García Cota
25fcd5e030 bootstrapping and little else 2011-08-08 00:07:02 +02:00