mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-24 18:25:32 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
24
samples/Terra/cnamespace.t
Normal file
24
samples/Terra/cnamespace.t
Normal file
@@ -0,0 +1,24 @@
|
||||
G,T = terralib.includecstring [[
|
||||
typedef struct {
|
||||
double c;
|
||||
} A;
|
||||
struct A {
|
||||
int b;
|
||||
};
|
||||
]]
|
||||
|
||||
G2,T2 = terralib.includecstring [[
|
||||
struct A;
|
||||
typedef struct C A;
|
||||
]]
|
||||
|
||||
assert(T2.A == T.A)
|
||||
assert(G2.A ~= T2.A and G2.A ~= G.A)
|
||||
terra foo()
|
||||
var a : G.A
|
||||
var b : T.A
|
||||
a.c = 4.5
|
||||
b.b = 4.5
|
||||
return a.c + b.b
|
||||
end
|
||||
assert(8.5 == foo())
|
||||
Reference in New Issue
Block a user