Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.o
*.a
*.so
*.d.pln

# lua
vm/src/lua
Expand Down
3 changes: 3 additions & 0 deletions run-lint
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ for file in \
examples/*/*.lua \
examples/*/*.pln
do
case "$file" in
*.d.pln) continue ;;
esac
if grep -n "[$space$tab]$" "$file"; then
# Forbid trailing whitespace because some editors like to automatically delete it.
# Such whitespace can cause spurious diffs later down the road, when someone is working on
Expand Down
2 changes: 2 additions & 0 deletions spec/execution_tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function execution_tests.run(compile_file, backend, _ENV, only_compile)
local file_lua = modname..".lua"
local file_script = modname.."script.lua"
local file_output = modname.."output.txt"
local file_d_pln = modname..".d.pln"

local function compile(body)
local code = util.render([[
Expand Down Expand Up @@ -52,6 +53,7 @@ function execution_tests.run(compile_file, backend, _ENV, only_compile)
os.remove(file_lua)
os.remove(file_script)
os.remove(file_output)
os.remove(file_d_pln)
end)

local assert_test_output = function (expected)
Expand Down
15 changes: 15 additions & 0 deletions spec/pallenec_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

local util = require "pallene.util"

local function file_exists(name)
local f = io.open(name, "r")
return f ~= nil and io.close(f)
end


describe("pallenec", function()
before_each(function()
util.set_file_contents("__test__.pln", [[
Expand All @@ -29,7 +35,9 @@ describe("pallenec", function()
os.remove("__test__.c")
os.remove("__test__.s")
os.remove("__test__.so")
os.remove("__test__.d.pln")
os.remove("__test__flag__.so")
os.remove("__test__flag__.d.pln")
os.remove("__test__script__.lua")
os.remove("__test__script__flag__.lua")
end)
Expand Down Expand Up @@ -61,4 +69,11 @@ describe("pallenec", function()
assert.is_false(ok, err)
assert(string.find(abort_msg, "Error: option '--emit-lua' can not be used together with option '--emit-c'", nil, true))
end)

it("Can extract type declarations", function()
assert(util.execute("pallenec __test__.pln"))
assert(file_exists("__test__.d.pln"))
local types = util.get_file_contents("__test__.d.pln")
assert.equals("f: (integer) -> integer\n", types)
end)
end)
Loading