initial
This commit is contained in:
parent
2fe710621b
commit
6a2d16fecd
|
@ -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
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
rockspec_format = "3.0"
|
||||
package = "busted-tl"
|
||||
version = "dev-1"
|
||||
|
||||
source = {
|
||||
url = "*** please add URL for source tarball, zip or repository here ***",
|
||||
}
|
||||
|
||||
description = {
|
||||
homepage = "*** please enter a project homepage ***",
|
||||
license = "*** please specify a license ***",
|
||||
}
|
||||
|
||||
dependencies = {
|
||||
"lua >= 5.1",
|
||||
"penlight >= 1.3.2",
|
||||
"busted",
|
||||
"tl",
|
||||
}
|
||||
|
||||
build_dependencies = {
|
||||
"cyan",
|
||||
}
|
||||
|
||||
build = {
|
||||
type = "command",
|
||||
build_command = "cyan build",
|
||||
install = {
|
||||
lua = {
|
||||
["busted.modules.files.teal"] = "build/busted-tl/teal.lua",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
test_dependencies = {
|
||||
"busted",
|
||||
}
|
||||
|
||||
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…
Reference in New Issue