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

View File

@@ -0,0 +1,29 @@
function failit(fn,err)
local success,msg = pcall(fn)
if success then
error("failed to fail.",2)
elseif not string.match(msg,err or "Errors reported during") then
error("failed wrong: "..msg,2)
end
end
failit(function()
local A = {}
terra A:foo() end
end,"expected a struct")
failit(function()
terra A.b() end
end,"failed attempting to index field")
failit(function()
terra A.b.c() end
end,"failed attempting to index field")
failit(function()
local A = 4
struct A.b {}
end,"failed attempting to index field")