mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
21
samples/Terra/includetwice.t
Normal file
21
samples/Terra/includetwice.t
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
local C1 = terralib.includecstring [[
|
||||
typedef struct { int a; } A;
|
||||
int geta(A* a) { return a->a; }
|
||||
]]
|
||||
local C2 = terralib.includecstring [[
|
||||
typedef struct { int a; } A;
|
||||
void seta(A* a, int v) { a->a = v; }
|
||||
]]
|
||||
|
||||
assert(C1.A == C2.A)
|
||||
|
||||
|
||||
terra usethem()
|
||||
var a = C1.A { 1 }
|
||||
C2.seta(&a,C1.geta(&a) + 3)
|
||||
return a.a
|
||||
end
|
||||
|
||||
assert(usethem() == 4)
|
||||
Reference in New Issue
Block a user