samples: add Terra samples

source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
Bayu Aldi Yansyah
2016-01-28 11:22:27 +07:00
parent e32a837fb2
commit 9b8b39f444
370 changed files with 11921 additions and 0 deletions

27
samples/Terra/vec.t Normal file
View File

@@ -0,0 +1,27 @@
terra foo(a : double)
var v0 : vector(double,3) = a
var v1 : vector(int,3) = 4
var v2 = v0 / v1
var v3 = (v0 <= v1) or (v1 >= v0)
var ptr = [&double](&v2)
return v3[0] or v3[1] or v3[2]
--return ptr[0] + ptr[1] + ptr[2]
end
N = 64
terra addsomevecs(a : vector(double,N), b : vector(double,N), c : vector(double,N) )
return (a + b) / c
end
terra foo2(a : double, b : double)
var c = addsomevecs(a,b,b)
return c[0] + c[1]
end
local test = require("test")
test.eq(foo(3), true)
test.eq(foo2(3,4), 3.5)