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,33 @@
struct A {
a : int;
b : int;
c : &B
} and struct B {
a : &A
}
local a = global(A)
terra foo()
var b : B
return a.a + a.b
end
function A.metamethods.__staticinitialize(self)
print("A")
assert(A:iscomplete())
a:get().a = 4
end
function B.metamethods.__staticinitialize(self)
print("B")
assert(B:iscomplete())
a:get().b = 3
foo:gettype(function()
assert(foo() == 7)
a:get().a = a:get().a + 1
end)
end
assert(foo() == 8)