spec(teal_type_definition): test Variable node
This commit is contained in:
parent
136560aad6
commit
5ae73bbbc6
|
@ -17,7 +17,7 @@ local function gen(ast: Node, expected_code: string): function()
|
|||
end
|
||||
end
|
||||
|
||||
describe("Print Teal type definition", function()
|
||||
describe("Teal type definition Printer", function()
|
||||
it("should print a simple module type definition", gen(
|
||||
{
|
||||
children = {},
|
||||
|
@ -66,4 +66,26 @@ describe("Print Teal type definition", function()
|
|||
|
||||
return Signal_Module
|
||||
]]))
|
||||
|
||||
it("should print a property exposed by the module", gen(
|
||||
{
|
||||
children = {
|
||||
{
|
||||
name = "text",
|
||||
types = { "string", "nil" },
|
||||
token = "variable",
|
||||
}
|
||||
},
|
||||
name = "Property_Module",
|
||||
token = "module",
|
||||
},
|
||||
[[
|
||||
-- This file was auto-generated.
|
||||
|
||||
local record Property_Module
|
||||
text: string | nil
|
||||
end
|
||||
|
||||
return Property_Module
|
||||
]]))
|
||||
end)
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
local ast = require "ast"
|
||||
local logger = require "logger"
|
||||
local type Node = require "types.Node"
|
||||
local ast = require("ast")
|
||||
local logger = require("logger")
|
||||
local type Node = require("types.Node")
|
||||
local stringx = require("pl.stringx")
|
||||
|
||||
local log = logger.log("scraper")
|
||||
|
||||
local function concatenate_strings(strings: { string }): string
|
||||
local result = ""
|
||||
for _, str in ipairs(strings) do
|
||||
result = result .. str
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
local function render_types(types: { string }): string
|
||||
if not types or #types == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
return ": " .. concatenate_strings(types)
|
||||
return ": " .. stringx.join(" | ", types)
|
||||
end
|
||||
|
||||
local record Node_Printer_Function
|
||||
|
|
Loading…
Reference in New Issue