initial commit

This commit is contained in:
2024-08-31 22:36:09 -06:00
commit 61460f0180
18 changed files with 1646 additions and 0 deletions

29
spec/codewriter_spec.lua Normal file
View File

@@ -0,0 +1,29 @@
local CodeWriter = require 'tt.codewriter'
describe('CodeWriter', function()
it('should write with indentation', function()
local cw = CodeWriter.new()
cw:write '{'
cw:indent(function(cw2) cw2:write 'x: 123' end)
cw:write '}'
assert.are.same(cw.lines, { '{', ' x: 123', '}' })
end)
it('should keep relative indentation', function()
local cw = CodeWriter.new()
cw:write '{'
cw:indent(function(cw2)
cw2:write 'x: 123'
cw2:write ' y: 123'
end)
cw:write '}'
assert.are.same(cw.lines, {
'{',
' x: 123',
' y: 123',
'}',
})
end)
end)