forked from terralang/terra
-
Notifications
You must be signed in to change notification settings - Fork 2
/
coverage4.t
66 lines (54 loc) · 1.08 KB
/
coverage4.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local a = `-1.5
assert(a:asvalue() == -1.5)
function failit(match,fn)
local success,msg = xpcall(fn,debug.traceback)
if success then
error("failed to fail.",2)
elseif not string.match(msg,match) then
error("failed wrong: "..msg,2)
end
end
failit("expected a function pointer",function()
local terra foo :: int
end)
failit("expected a type but found",function()
tuple(1,2)
end)
failit("expected a label but found",function()
terra foo()
:: [ "string" ] ::
end
end)
failit("call to overloaded function does not apply to any arguments",
function()
local a = terralib.overloadedfunction("a")
a:adddefinition(terra() end)
a:adddefinition(terra(a : int) end)
terra foo()
a(2,3)
end
end)
failit("attempting to call overloaded",
function()
local a = terralib.overloadedfunction("a")
terra foo()
a(2,3)
end
end)
failit("no such method",
function()
struct A {}
terra what(a : A)
return A.foo()
end
end)
terra foo()
terralib.debuginfo("what",3)
end
failit("expected a single iteration",
function()
terra what()
for [{symbol(int),symbol(int)}] = 1,3 do
end
end
end)