Compare commits

...

3 Commits

@ -0,0 +1,15 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{lua,tl,d.tl,rockspec,luacheckrc}]
indent_size = 3
[*.json]
indent_size = 2

5
.gitignore vendored

@ -0,0 +1,5 @@
/luarocks
/lua
/lua_modules
/.luarocks
/build

@ -0,0 +1,11 @@
std = "lua54"
cache = true
files[".luacheckrc"].std = "+luacheckrc"
files[".rockspec"].std = "+rockspec"
include_files = {
"src/",
"*.rockspec",
"*.luacheckrc",
}

@ -0,0 +1,9 @@
{
"cSpell.words": ["fname", "luacheckrc", "rockspec", "traceback"],
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"files.associations": {
".luacheckrc": "lua",
"*.rockspec": "lua"
}
}

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2023 Aire-One
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@ -0,0 +1,50 @@
rockspec_format = "3.0"
package = "busted-tl"
version = "dev-1"
source = {
url = "git+https://gitea.aireone.xyz/Aire-One/busted-tl.git",
}
description = {
summary = "Add Teal capabilities to Busted 🧙",
detailed = "Busted-tl is a new Loader for Busted that adds Teal support.",
license = "MIT",
homepage = "https://gitea.aireone.xyz/Aire-One/busted-tl",
issues_url = "https://gitea.aireone.xyz/Aire-One/busted-tl/issues",
maintainer = "Aire-One",
labels = {
"busted",
"teal",
"testing",
},
}
dependencies = {
"lua >= 5.1",
"penlight >= 1.3.2",
"busted >= 2.1.2-3",
"tl >= 0.15.1-1",
}
build_dependencies = {
"cyan >= 0.3.0-1",
}
build = {
type = "command",
build_command = "cyan build",
install = {
lua = {
["busted.modules.files.teal"] = "build/busted-tl/teal.lua",
},
},
}
test = {
type = "busted",
flags = {
"--loaders=teal",
},
}

@ -0,0 +1,20 @@
global describe: function(string, function)
global it: function(string, function)
-- Teal generates an empty table for record declaration.
-- For now we'll bypass any usage of the assert module and
-- use the global assert function instead.
-- global record assert
-- are_equal: function(any, any)
-- end
describe("Teal tests", function()
it("works", function()
-- This is a Teal specific syntax.
local a: number = 1
assert(a == 1, "This test uses Teal's syntax!")
-- assert.are_equal(a, 1)
end)
end)

@ -0,0 +1,53 @@
local file = require("pl.file")
local path = require("pl.path")
local type Busted = record
publish: function
end
local type Info = record
traceback: string
short_src: string
end
local teal_available, tl = pcall(require, 'tl')
local rewrite_filename = function(filename: string): string
return filename:match('string "(.+)"') or filename
end
local rewriteMessage = function(_filename: string, message: string): string
local fname, line, msg = message:match('^([^\n]-):(%d+): (.*)')
if not fname then
return message
end
fname = rewrite_filename(fname)
return fname .. ':' .. tostring(line) .. ': ' .. msg
end
local getTrace = function(_filename: string, info: Info): Info
local index = info.traceback:find('\n%s*%[C]')
info.traceback = info.traceback:sub(1, index)
info.short_src = rewrite_filename(info.short_src)
return info
end
local record ret
end
function ret.match(_busted: Busted, filename: string): boolean
return teal_available and path.extension(filename) == '.tl'
end
function ret.load(busted: Busted, filename: string): function, function, function
local content = file.read(filename)
local program, err = tl.load(content, filename)
if not program then
busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {})
end
return program, getTrace, rewriteMessage
end
return ret

@ -0,0 +1,6 @@
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 3
quote_style = "AutoPreferDouble"
no_call_parentheses = true

@ -0,0 +1,7 @@
return {
build_dir = "build",
source_dir = "src",
include_dir = {
"types",
},
}

@ -0,0 +1,10 @@
local record pl
record file
read: function(string): string
end
record path
extension: function(string): string
end
end
return pl

@ -0,0 +1 @@
return require("pl").file

@ -0,0 +1 @@
return require("pl").path
Loading…
Cancel
Save