mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
33
samples/Terra/hasbeenfrozen.t
Normal file
33
samples/Terra/hasbeenfrozen.t
Normal 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)
|
||||
Reference in New Issue
Block a user