Move to an AST like data structure #76

Merged
Aire-One merged 39 commits from feat/refactor-ast into master 2023-08-03 21:03:16 +02:00
3 changed files with 22 additions and 40 deletions
Showing only changes of commit 5d45637954 - Show all commits

View File

@ -1,30 +0,0 @@
local assert = require("luassert")
describe("Busted unit testing framework", function()
describe("should be awesome", function()
it("should be easy to use", function()
assert.truthy "Yup."
end)
it("should have lots of features", function()
-- deep check comparisons!
assert.same({ table = "great" }, { table = "great" })
-- or check by reference!
assert.not_equal({ table = "great" }, { table = "great" })
assert.truthy "this is a string" -- truthy: not false or nil
assert.is_true(1 == 1)
assert.falsy(nil)
assert.has_error(function()
error "Wat"
end, "Wat")
end)
it("should provide some shortcuts to common functions", function()
assert.is_unique { { thing = 1 }, { thing = 2 }, { thing = 3 } }
end)
end)
end)

View File

@ -1,10 +0,0 @@
local assert = require("luassert")
local utils = require("utils")
describe("test", function()
it("has_item", function()
local t = {1, 2, 3}
assert.equal(utils.has_item(t, 1), 1)
assert.is_nil(utils.has_item(t, 4))
end)
end)

View File

@ -0,0 +1,22 @@
local assert = require("luassert")
local scraper = require("scraper").module_doc
local get_doc_from_page = scraper.get_doc_from_page
describe("Scrap documentation", function()
it("should return a valid AST for an empty module", function()
local ast <const>, nodes <const> = get_doc_from_page("", "empty")
assert.same(ast, {
children = {
{
children = {},
name = "Signal",
token = "enum",
}
},
name = "Empty",
token = "module",
})
assert.same(nodes, {})
end)
end)