1
+
2
+ runs = {}
3
+ local ResourceTypeA = world .get_type_by_name (" TestResource" )
4
+ local ResourceTypeB = world .get_type_by_name (" TestResourceWithVariousFields" )
5
+ local ComponentA = world .get_type_by_name (" CompWithFromWorldAndComponentData" )
6
+ local ComponentB = world .get_type_by_name (" CompWithDefaultAndComponentData" )
7
+
8
+ function on_test ()
9
+ local post_update_schedule = world .get_schedule_by_name (" PostUpdate" )
10
+
11
+ local entity = world .spawn ()
12
+ local entity2 = world .spawn ()
13
+
14
+
15
+ world .add_default_component (entity , ComponentA )
16
+ world .add_default_component (entity , ComponentB )
17
+ world .add_default_component (entity2 , ComponentA )
18
+ world .add_default_component (entity2 , ComponentB )
19
+
20
+ world .add_system (
21
+ post_update_schedule ,
22
+ system_builder (" my_parameterised_system" , script_id )
23
+ :resource (ResourceTypeA )
24
+ :query (world .query ():component (ComponentA ):with (ComponentB ))
25
+ :resource (ResourceTypeB )
26
+ )
27
+
28
+ return true
29
+ end
30
+
31
+ function my_parameterised_system (resourceA ,query ,resourceB )
32
+ print (" my_parameterised_system" )
33
+ runs [# runs + 1 ] = " my_non_exclusive_system"
34
+
35
+ assert (resourceA ~= nil , " Expected to get resource but got nil" )
36
+ assert (query ~= nil , " Expected to get query but got nil" )
37
+ assert (resourceB ~= nil , " Expected to get resource but got nil" )
38
+
39
+ assert (# resourceA .bytes == 6 , " Expected 6 bytes, got: " .. # resourceA .bytes )
40
+ assert (resourceB .string == " Initial Value" , " Expected 'Initial Value', got: " .. resourceB .string )
41
+ assert (# query == 2 , " Expected 3 results, got: " .. # query )
42
+ end
43
+
44
+
45
+ function on_test_post_update ()
46
+ return true
47
+ end
48
+
49
+ function on_test_last ()
50
+ assert (# runs == 1 , " Expected 1 runs, got: " .. # runs )
51
+ return true
52
+ end
0 commit comments