From 27d6efb5f5a076f825fe2da1875e0cabaf02b4e7 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 17 Nov 2021 23:03:07 +0800 Subject: + LuaMacro --- Tools/LuaMacro/tests/class1.lc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Tools/LuaMacro/tests/class1.lc (limited to 'Tools/LuaMacro/tests/class1.lc') 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); +} -- cgit v1.1-26-g67d0