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-case.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Tools/LuaMacro/tests/test-case.lua (limited to 'Tools/LuaMacro/tests/test-case.lua') diff --git a/Tools/LuaMacro/tests/test-case.lua b/Tools/LuaMacro/tests/test-case.lua new file mode 100644 index 0000000..4f7eb25 --- /dev/null +++ b/Tools/LuaMacro/tests/test-case.lua @@ -0,0 +1,21 @@ +def_ OF_ def_ (of elseif _value ==) +def_ case(x) do OF_ local _value = x if false then _END_END_ + +function test(n) + local res + case(n) + of 10 then + res = 1 + of 20 then + res = 2 + else + res = 3 + end + return res +end + +assert(test(10)==1) +assert(test(20)==2) +assert(test(30)==3) + + -- cgit v1.1-26-g67d0