Repository navigation
Expand file tree
/
Copy pathgen_spec.lua
More file actions
66 lines (60 loc) · 1.83 KB
/
Copy pathgen_spec.lua
File metadata and controls
66 lines (60 loc) · 1.83 KB
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
30
31
32
33
34
35
3
7B88
6
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local util = require("spec.util")
describe("gen command", function()
it("should not compile when there are type errors", function()
util.run_mock_project(finally, {
cmd = "gen",
args = { "foo.tl" },
dir_structure = {
["foo.tl"] = [[local _x: number = "hello"]],
},
cmd_output_match = "Error",
generated_files = {},
exit_code = 1,
})
end)
it("should compile when there are no type errors", function()
util.run_mock_project(finally, {
cmd = "gen",
args = { "foo.tl" },
dir_structure = {
["foo.tl"] = [[local _x: string = "hello"]]
},
generated_files = { "foo.lua" },
cmd_output_match_lines = {
[1] = "Type checked .*foo%.tl",
[2] = "Wrote .*foo%.lua",
},
exit_code = 0,
})
end)
describe("--output", function()
it("should map a single input to a single output", function()
util.run_mock_project(finally, {
cmd = "gen",
args = { "foo.tl", "-o", "bar.lua" },
dir_structure = {
["foo.tl"] = [[]],
},
generated_files = { "bar.lua" },
cmd_output_match_lines = {
[1] = "Type checked .*foo%.tl",
[2] = "Wrote .*bar%.lua",
},
exit_code = 0,
})
end)
it("should error with multiple inputs", function()
util.run_mock_project(finally, {
cmd = "gen",
args = { "foo.tl", "bar.tl", "-o", "baz.lua" },
dir_structure = {
["foo.tl"] = [[]],
["bar.tl"] = [[]],
},
generated_files = {},
cmd_output_match = "1 output",
exit_code = 1,
})
end)
end)
end)