local matcher = require 'matcher' local parser = require 'parser' rawset(_G, 'TEST', true) function TEST(fullkey) return function (script) local start = script:find('', 1, true) local pos = (start + finish) // 2 + 1 local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') local ast = parser:ast(new_script) assert(ast) local vm = matcher.vm(ast) assert(vm) local result = matcher.findResult(vm.results, pos) local _, name = matcher.findLib(result.object) assert(name == fullkey) end end TEST 'require' [[ 'xxx' ]] TEST 'require' [[ local = require ]] TEST 'require' [[ local req = require local t = { xx = req, } t[]() ]] TEST 'table' [[ .unpack() ]] TEST 'table' [[ local = require 'table' ]] TEST 'table' [[ local rq = require local lib = 'table' local = rq(lib) ]] TEST 'table.insert' [[ table.() ]] TEST 'table.insert' [[ local t = table t.() ]] TEST 'table.insert' [[ local insert = table.insert () ]] TEST 'table.insert' [[ local t = require 'table' t.() ]] TEST 'table.insert' [[ require 'table'.() ]] TEST '*string:sub' [[ local str = 'xxx' str.() ]] TEST '*string:sub' [[ local str = 'xxx' str:(1, 1) ]] TEST '*string:sub' [[ ('xxx').() ]] TEST 'bee::filesystem' [[ local = require 'bee.filesystem' ]] TEST 'fs.current_path' [[ local filesystem = require 'bee.filesystem' ROOT = filesystem.() ]] TEST(nil)[[ print() ]] TEST '_G' [[ local x = ]]