Compare commits

...

2 Commits

Author SHA1 Message Date
Aire-One 8603037516 chore: update LICENSE 1 year ago
Aire-One 27a9c98973 initial 1 year ago

@ -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

4
.gitignore vendored

@ -0,0 +1,4 @@
/luarocks
/lua
/lua_modules
/.luarocks

@ -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,53 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local pcall = _tl_compat and _tl_compat.pcall or pcall; local string = _tl_compat and _tl_compat.string or string; local file = require("pl.file")
local path = require("pl.path")
local teal_available, tl = pcall(require, 'tl')
local rewrite_filename = function(filename)
return filename:match('string "(.+)"') or filename
end
local rewriteMessage = function(_filename, message)
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, 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 ret = {}
function ret.match(_busted, filename)
return teal_available and path.extension(filename) == '.tl'
end
function ret.load(busted, filename)
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,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…
Cancel
Save