test: move tests to compiled file

This commit is contained in:
Aire-One 2023-04-17 00:05:15 +02:00
parent 93a61cc8a8
commit 94ea49cb3a
3 changed files with 16 additions and 4 deletions

View File

@ -46,6 +46,16 @@ validate:
--global-env-def "global_env" \
`find . -type f -iname '*.d.tl' | xargs`
test: build
rm -rf spec
mv build/spec spec
busted
# luarocks \
# --lua-version {{ lua_version }} \
# test \
# --tree {{ rocks_tree }} \
# {{ rockspec_file }}
# TODO : how to run a debugger on Teal code?
debug:
{{ lua }} debug.lua build/awesomewm.d.tl/init.lua

View File

@ -1,3 +1,5 @@
local assert = require("luassert")
describe("Busted unit testing framework", function()
describe("should be awesome", function()
it("should be easy to use", function()
@ -6,14 +8,13 @@ describe("Busted unit testing framework", function()
it("should have lots of features", function()
-- deep check comparisons!
assert.are.same({ table = "great" }, { table = "great" })
assert.same({ table = "great" }, { table = "great" })
-- or check by reference!
assert.are_not.equal({ table = "great" }, { table = "great" })
assert.not_equal({ table = "great" }, { table = "great" })
assert.truthy "this is a string" -- truthy: not false or nil
assert.True(1 == 1)
assert.is_true(1 == 1)
assert.falsy(nil)
@ -23,7 +24,7 @@ describe("Busted unit testing framework", function()
end)
it("should provide some shortcuts to common functions", function()
assert.are.unique { { thing = 1 }, { thing = 2 }, { thing = 3 } }
assert.is_unique { { thing = 1 }, { thing = 2 }, { thing = 3 } }
end)
end)
end)

View File

@ -5,4 +5,5 @@ return {
"src/awesomewm.d.tl",
"types",
},
global_env_def = "busted",
}