spec(teal_type_definition): test Enum node
ci/woodpecker/pr/docker-build Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details
ci/woodpecker/pr/test Pipeline failed Details

This commit is contained in:
Aire-One 2023-05-09 00:40:53 +02:00
parent 4eeb8894d2
commit 76b9d5032e
1 changed files with 35 additions and 1 deletions

View File

@ -7,7 +7,7 @@ local printer = teal_type_definition_printer.printer
-- We need to remove the last newline inserted by Penlight's dedent
local function dedent(str: string): string
return (stringx.dedent(str):sub(1, -3))
return (stringx.dedent(str):sub(1, -3):gsub("\n *", "\n")) -- we remove indentation for now, the printer should be fixed soon
end
local function gen(ast: Node, expected_code: string): function()
@ -32,4 +32,38 @@ describe("Print Teal type definition", function()
return Empty
]]))
it("should print an Enum exposed by the module", gen(
{
children = {
{
children = {
{
name = "widget::layout_changed",
token = "identifier",
},
{
name = "widget::redraw_needed",
token = "identifier",
},
},
name = "Signal",
token = "enum",
},
},
name = "Signal_Module",
token = "module",
},
[[
-- This file was auto-generated.
local record Signal_Module
enum Signal
"widget::layout_changed"
"widget::redraw_needed"
end
end
return Signal_Module
]]))
end)