spec(teal_type_definition): test Enum node
This commit is contained in:
parent
4eeb8894d2
commit
76b9d5032e
|
@ -7,7 +7,7 @@ local printer = teal_type_definition_printer.printer
|
||||||
|
|
||||||
-- We need to remove the last newline inserted by Penlight's dedent
|
-- We need to remove the last newline inserted by Penlight's dedent
|
||||||
local function dedent(str: string): string
|
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
|
end
|
||||||
|
|
||||||
local function gen(ast: Node, expected_code: string): function()
|
local function gen(ast: Node, expected_code: string): function()
|
||||||
|
@ -32,4 +32,38 @@ describe("Print Teal type definition", function()
|
||||||
|
|
||||||
return Empty
|
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)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue