-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_base.t
65 lines (56 loc) · 1.19 KB
/
test_base.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- SPDX-FileCopyrightText: 2024 René Hiemstra <[email protected]>
-- SPDX-FileCopyrightText: 2024 Torsten Keßler <[email protected]>
--
-- SPDX-License-Identifier: MIT
import "terratest/terratest"
local base = require("base")
testenv "New Base" do
local Foo = base.Base:new("Foo", function(T) error("Catch me if you can!") end)
local ok, ret = pcall(Foo, int)
local i,j = ret:find("Catch me if you can!")
test ok == false
test i > 0
test j > 0
end
testenv "Multiple Base" do
local counter = 1
local Foo = base.Base:new("Foo", function(T) counter = counter + 3 end)
local Bar = base.Base:new("Bar", function(T) counter = 2 * counter end)
local FooBar = Foo * Bar
FooBar()
terracode
var res1 = counter
end
counter = 1
local BarFoo = Bar * Foo
BarFoo()
terracode
var res2 = counter
end
testset "Ordering" do
test res1 == 8
test res2 == 5
end
end
testenv "Operation on terra structs" do
local B = base.Base:new("B", function(T)
terra T:inc()
self.a = self.a + 1
end
end)
local struct A(B){
a: int
}
terracode
var a = A {2}
end
testset "Initial state" do
test a.a == 2
end
testset "Call to base methods" do
terracode
a:inc()
end
test a.a == 3
end
end