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

View File

@@ -0,0 +1,30 @@
terra foo()
return 1,2
end
terra foo2()
return {a = 1, b = 2}
end
assert(unpacktuple(1) == 1)
assert(unpacktuple(foo()) == 1)
assert(unpacktuple(foo(),2) == 2)
assert(unpacktuple(foo(),nil,1) == 1)
assert(unpacktuple(foo2()).a == 1)
assert(2 == #{unpacktuple(foo())})
assert(1 == #{unpacktuple(foo(),2)})
terra usefoo()
var a = foo()
var c,d = unpacktuple(a)
var e = unpacktuple(a,2)
return e
end
assert(usefoo() == 2)