samples: add Terra samples

source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
Bayu Aldi Yansyah
2016-01-28 11:22:27 +07:00
parent e32a837fb2
commit 9b8b39f444
370 changed files with 11921 additions and 0 deletions

47
samples/Terra/coverage.t Normal file
View File

@@ -0,0 +1,47 @@
function failit(match,fn)
local success,msg = pcall(fn)
if success then
error("failed to fail.",2)
elseif not string.match(msg,match) then
error("failed wrong: "..msg,2)
end
end
local test = require("test")
local erd = "Errors reported during"
local terra f1()
return test
end
failit(erd,function()
f1:compile()
end)
failit("referencing a function which failed to compile",function()
f1:compile()
end)
failit(erd,function()
local terra foo()
f1()
end
foo()
end)
local struct A {
a : int
}
A.metamethods.__getentries = function(self)
error("I AM BAD")
end
failit(erd,function()
A:complete()
end)
failit(erd,function()
local terra foo()
var a : A
end
foo()
end)