1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00
CC-Tweaked/src/test/resources/test-rom/spec/programs/mkdir_spec.lua
Jonathan Coates 8e4d311cd9
Refactor shell completion into a separate module (#281)
- Adds cc.completions module, with a couple of helper functions for
   working with the more general completion functionality (i.e. that
   provided by read).
 - Adds cc.shell.completions module, which provides shell-specific
   completion functions.
 - Add a "program completion builder", which allows you to write stuff
   like this:

       shell.setCompletionFunction( "rom/programs/redstone.lua", 
         completion.build(
           { completion.choice, { "probe", "set ", "pulse " } },
           completion.side) )

Closes #232
2019-09-15 18:48:40 +01:00

30 lines
938 B
Lua

describe("The mkdir program", function()
it("creates a directory", function()
fs.delete("/test-files")
shell.run("mkdir /test-files/a")
expect(fs.isDir("/test-files/a")):eq(true)
end)
it("creates many directories", function()
fs.delete("/test-files")
shell.run("mkdir /test-files/a /test-files/b")
expect(fs.isDir("/test-files/a")):eq(true)
expect(fs.isDir("/test-files/b")):eq(true)
end)
it("can be completed", function()
fs.delete("/test-files")
fs.makeDir("/test-files/a")
fs.makeDir("/test-files/b")
io.open("/test-files.a.txt", "w"):close()
local complete = shell.getCompletionInfo()["rom/programs/mkdir.lua"].fnComplete
expect(complete(shell, 1, "/test-files/", {})):same { "a/", "a", "b/", "b" }
expect(complete(shell, 2, "/test-files/", { "/" })):same { "a/", "a", "b/", "b" }
end)
end)