mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 01:30:22 +00:00
29 lines
524 B
Perl
29 lines
524 B
Perl
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") |