lune/tests/process/args.luau

31 lines
856 B
Lua
Raw Normal View History

local process = require("@lune/process")
2023-01-21 04:40:31 +00:00
assert(#process.args > 0, "No process arguments found")
assert(process.args[1] == "Foo", "Invalid first argument to process")
assert(process.args[2] == "Bar", "Invalid second argument to process")
2023-01-21 06:37:31 +00:00
local success, message = pcall(function()
2023-01-21 04:40:31 +00:00
process.args[1] = "abc"
end)
2023-01-21 06:37:31 +00:00
assert(
success == false and type(message) == "string" and #message > 0,
"Trying to set process arguments should throw an error with a message"
)
assert(
string.find(message, "read") ~= nil,
"Setting process args error message should mention that they are read-only"
)
assert(
string.find(message, "only") ~= nil,
"Setting process args error message should mention that they are read-only"
)
2023-01-21 04:40:31 +00:00
local foundValue = false
for _, _ in process.args do
foundValue = true
break
end
assert(foundValue, "Iterating using generalized iteration")