Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-compat.lua « tests - github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4a27248048fa154300449591645a85e58a5bd86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local test = require 'pl.test'
local asserteq = test.asserteq

local compat = require "pl.compat"
local coroutine = require "coroutine"

local code_generator = coroutine.wrap(function()
    local result = {"ret", "urn \"Hello World!\""}
    for _,v in ipairs(result) do
        coroutine.yield(v)
    end
    coroutine.yield(nil)
end)

local f, err = compat.load(code_generator)
asserteq(err, nil)
asserteq(f(), "Hello World!")


-- package.searchpath
if compat.lua51 and not compat.jit then
  assert(package.searchpath("pl.compat", package.path):match("lua[/\\]pl[/\\]compat"))
  
  local path = "some/?/nice.path;another/?.path"
  local ok, err = package.searchpath("my.file.name", path, ".", "/")
  asserteq(err, "\tno file 'some/my/file/name/nice.path'\n\tno file 'another/my/file/name.path'")
  local ok, err = package.searchpath("my/file/name", path, "/", ".")
  asserteq(err, "\tno file 'some/my.file.name/nice.path'\n\tno file 'another/my.file.name.path'")
end