local matcher = require 'matcher' local function test(script) local start = script:find('', 1, true) - 1 local pos = script:find('', ' ') local suc, a, b = matcher.definition(new_script, pos) assert(suc) assert(a == start) assert(b == finish) end test [[ local = 1 ]] test [[ local z, y, = 1 ]] test [[ local = 1 = 1 ]] test [[ local z, y, = 1 = 1 ]] test [[ function () end = 1 ]] test [[ local function () end = 1 ]] test [[ local x local = 1 ]] test [[ local do = 1 end ]] test [[ local do local x end = 1 ]] test [[ local if then local x end ]] test [[ local if x then local x elseif then local x end ]] test [[ local if x then local x elseif x then local x else local x end = 1 ]] test [[ local if x then = 1 elseif x then local x else local x end ]] test [[ local for x = 1, 10 do end = 1 ]] test [[ local x for = 1, 10 do = 1 end ]] test [[ local for x in x do end = 1 ]] test [[ local for x in do end ]] test [[ local x for in x do = 1 end ]] test [[ local x for z, y, in x do = 1 end ]] test [[ local while do end ]] test [[ local while x do = 1 end ]] test [[ local while x do local x end = 1 ]] test [[ local repeat = 1 until true ]] test [[ local repeat local x until true = 1 ]] test [[ local repeat until ]] test [[ local x repeat local until ]] test [[ local function _() local x end = 1 ]] test [[ local return function () = 1 end ]] test [[ local local x = function () = 1 end ]] test [[ local x local function () = 1 end ]]