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

45
samples/Terra/teststd.t Normal file
View File

@@ -0,0 +1,45 @@
local S = require "std"
c = global(int,0)
struct A(S.Object) {
a : int;
b : int[5];
}
struct C {
a : int
}
struct B(S.Object) {
a : A;
b : A[2];
c : C[3];
c2 : C;
c3 : C[2];
}
terra A:__destruct()
S.printf("A dtor!\n")
c = c + 1
end
terra B:__destruct()
c = c + 10
end
terra foo()
var a = A.salloc()
end
foo()
assert(c:get() == 1)
terra bar()
var b = B.salloc()
end
bar()
assert(c:get() == 14)
terra baz()
var b = B.alloc()
b:delete()
end
baz()
assert(c:get() == 27)