mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-28 20:25:35 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
26
samples/Terra/globals.t
Normal file
26
samples/Terra/globals.t
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
struct A { a : int }
|
||||
local a = terralib.global(A)
|
||||
a:set({3})
|
||||
local b = terralib.global(true)
|
||||
local c = terralib.global(int[3])
|
||||
local d = terralib.global(3.5)
|
||||
|
||||
terra foobar()
|
||||
c[0] = 3
|
||||
return a.a + d
|
||||
end
|
||||
|
||||
e = global(int)
|
||||
terra doihaveaname()
|
||||
e = 10
|
||||
return e
|
||||
end
|
||||
|
||||
assert(doihaveaname() == 10)
|
||||
assert(6.5 == foobar())
|
||||
print("HERE")
|
||||
assert(true == b:get())
|
||||
assert(3 == c:get()[0])
|
||||
|
||||
print("TODO - fix handling of initializers for array-like things and literal strings")
|
||||
Reference in New Issue
Block a user