1describe("Lua version compatibility", function()
2 describe("os.execute return value", function()
3 it("returns true for successful commands", function()
4 local success = os.execute("true")
5 assert.is_true(success == true or success == 0)
6 end)
7
8 it("returns non-true for failed commands", function()
9 local success = os.execute("false")
10 assert.is_not_true(success == true)
11 end)
12 end)
13
14 describe("load() with 4 arguments", function()
15 it("works with mode and env parameters", function()
16 local chunk = load("return 42", "test", "t", {})
17 assert.is_function(chunk)
18 assert.are.equal(42, chunk())
19 end)
20
21 it("respects restricted environment", function()
22 local chunk = load("return { x = 1, y = 2 }", "test", "t", {})
23 assert.is_function(chunk)
24 local result = chunk()
25 assert.are.equal(1, result.x)
26 assert.are.equal(2, result.y)
27 end)
28 end)
29
30 describe("string patterns used in wt", function()
31 it("matches git URL project names", function()
32 local url = "git@github.com:user/project.git"
33 local name = url:match("([^/]+)%.git$") or url:match("([^/:]+)$")
34 assert.are.equal("project", name)
35 end)
36
37 it("matches https URL project names", function()
38 local url = "https://github.com/user/project.git"
39 local name = url:match("([^/]+)%.git$") or url:match("([^/:]+)$")
40 assert.are.equal("project", name)
41 end)
42
43 it("handles gitdir patterns", function()
44 local content = "gitdir: .bare"
45 assert.is_truthy(content:match("gitdir:%s*%.?/?%.bare"))
46 end)
47 end)
48
49 describe("io.popen", function()
50 it("captures command output", function()
51 local handle = io.popen("echo hello")
52 assert.is_not_nil(handle)
53 local output = handle:read("*a")
54 handle:close()
55 assert.are.equal("hello\n", output)
56 end)
57 end)
58end)