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

23
samples/Terra/twolang.t Normal file
View File

@@ -0,0 +1,23 @@
do
import "lib/foolang"
a = foo bar
import "lib/barlang"
b = bar foo
assert( foo bar + bar foo == 3)
assert(a + b == 3)
end
local function failparse(str,match)
local r,msg = terralib.loadstring(str)
assert(not r)
local match = msg:match(match)
if not match then print(msg) end
assert(match)
end
failparse("return (foo bar + bar foo)", "near 'bar'")
failparse('import "lib/foolang";return (foo bar + bar foo)', "near foo")
failparse('import "lib/foolang"; import "lib/foolang";',"entrypoint 'foo' already defined")
do import "lib/foolang" end do import "lib/foolang" end