mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-15 13:56:15 +00:00
samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
17
samples/Terra/overloadmethod2.t
Normal file
17
samples/Terra/overloadmethod2.t
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
struct A { a : int }
|
||||
A.methods.foo = terra(self : A, a : int)
|
||||
return self.a + a
|
||||
end
|
||||
|
||||
terra A:foo()
|
||||
return self.a
|
||||
end
|
||||
|
||||
|
||||
terra doit()
|
||||
var a = A { 3 }
|
||||
return a:foo() + a:foo(1)
|
||||
end
|
||||
local test = require("test")
|
||||
test.eq(doit(),7)
|
||||
Reference in New Issue
Block a user