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/test-rawhash.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Tools/LuaMacro/tests/test-rawhash.lua (limited to 'Tools/LuaMacro/tests/test-rawhash.lua') diff --git a/Tools/LuaMacro/tests/test-rawhash.lua b/Tools/LuaMacro/tests/test-rawhash.lua new file mode 100644 index 0000000..6697cf8 --- /dev/null +++ b/Tools/LuaMacro/tests/test-rawhash.lua @@ -0,0 +1,35 @@ +require_ "rawhash" + +function test () + Tab mytable, another + + t = {1,3} + + -- Here # is short for #mytable + mytable[#+1] = 1 + mytable[#+1] = 2 + + -- without indexing, behaves just like a table reference + assert(type(mytable)=='table') + + -- it is still possible to use #t explicitly + assert(mytable [#]==mytable[#t]) + + assert(mytable[#-1] == mytable[1]) + + for i = 1,10 do another[#+1] = i end + for i = 1,10 do assert(another[i] == i) end + +end + +test() + +-- although mytable is a macro, its scope is limited to test() +assert(mytable == nil) + + + + + + + -- cgit v1.1-26-g67d0