summaryrefslogtreecommitdiff
path: root/Tools/LuaMacro/tests/test-case.lua
blob: 4f7eb255a2218f9536679a5192f39341924f3003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)