Skip to content

Commit 8330c2f

Browse files
committed
simple tests
1 parent 8e6250c commit 8330c2f

2 files changed

+65
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
runs = {}
3+
4+
function on_test()
5+
local post_update_schedule = world.get_schedule_by_name("PostUpdate")
6+
7+
world.add_system(
8+
post_update_schedule,
9+
system_builder("my_exclusive_system", script_id):exclusive()
10+
)
11+
12+
return true
13+
end
14+
15+
function my_exclusive_system()
16+
print("my_exclusive_system")
17+
runs[#runs + 1] = "my_non_exclusive_system"
18+
19+
local ResourceType = world.get_type_by_name("TestResource")
20+
local res = world.get_resource(ResourceType)
21+
assert(res ~= nil, "Expected to get resource but got nil")
22+
end
23+
24+
25+
function on_test_post_update()
26+
return true
27+
end
28+
29+
function on_test_last()
30+
assert(#runs == 1, "Expected 1 runs, got: " .. #runs)
31+
return true
32+
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
runs = {}
3+
4+
function on_test()
5+
local post_update_schedule = world.get_schedule_by_name("PostUpdate")
6+
7+
world.add_system(
8+
post_update_schedule,
9+
system_builder("my_non_exclusive_system", script_id)
10+
)
11+
12+
return true
13+
end
14+
15+
function my_non_exclusive_system()
16+
print("my_non_exclusive_system")
17+
runs[#runs + 1] = "my_non_exclusive_system"
18+
19+
local ResourceType = world.get_type_by_name("TestResource")
20+
assert_throws(function()
21+
local res = world.get_resource(ResourceType)
22+
end, ".*cannot claim access to.*")
23+
end
24+
25+
26+
function on_test_post_update()
27+
return true
28+
end
29+
30+
function on_test_last()
31+
assert(#runs == 1, "Expected 1 runs, got: " .. #runs)
32+
return true
33+
end

0 commit comments

Comments
 (0)