diff options
author | chai <chaifix@163.com> | 2021-11-17 23:03:07 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-17 23:03:07 +0800 |
commit | 27d6efb5f5a076f825fe2da1875e0cabaf02b4e7 (patch) | |
tree | 44f301110bc2ea742908ed92a78eba0803cd3b60 /Tools/LuaMacro/tests/class1.lc | |
parent | b34310c631989551054d456eb47aaab5ded266a4 (diff) |
+ LuaMacro
Diffstat (limited to 'Tools/LuaMacro/tests/class1.lc')
-rw-r--r-- | Tools/LuaMacro/tests/class1.lc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Tools/LuaMacro/tests/class1.lc b/Tools/LuaMacro/tests/class1.lc new file mode 100644 index 0000000..60a73a0 --- /dev/null +++ b/Tools/LuaMacro/tests/class1.lc @@ -0,0 +1,40 @@ +// preprocess using luam -C -llc class1.lc > class1.c +module "class1" { + +class A { + int handle; + + constructor (Int i) { + this->handle = i; + } + + def geth () { + lua_pushinteger(L, this->handle); + return 1; + } + + def __eq(A other) { + lua_pushboolean(L, this->handle == other->handle); + return 1; + } +} + +def A (Int i) { + push_new_A(L,i); + return 1; +} + +constants { + Int MAGIC = 42 +} + +} + +lua_tests { + require 'class1' + M = class1.MAGIC + o = class1.A(M) + assert(o:geth() == M) + a = class1.A(M) + assert(a == o); +} |