Skip to content

Commit 2c4cb17

Browse files
committed
(multi_)lookup first impl
1 parent e49a339 commit 2c4cb17

2 files changed

Lines changed: 237 additions & 36 deletions

File tree

develop/testing/lookup_tests.lua

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,85 +6,85 @@ do
66
local e1, e2, e3 = evo.id(3)
77

88
do
9-
assert(evo.lookup('hello') == nil)
10-
assert(evo.lookup('world') == nil)
9+
assert(evo.lookup('lookup_hello') == nil)
10+
assert(evo.lookup('lookup_world') == nil)
1111

1212
do
13-
local entity_list, entity_count = evo.multi_lookup('hello')
13+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
1414
assert(entity_list and #entity_list == 0 and entity_count == 0)
1515
end
1616

1717
do
18-
local entity_list, entity_count = evo.multi_lookup('world')
18+
local entity_list, entity_count = evo.multi_lookup('lookup_world')
1919
assert(entity_list and #entity_list == 0 and entity_count == 0)
2020
end
2121
end
2222

23-
evo.set(e1, evo.NAME, 'hello')
23+
evo.set(e1, evo.NAME, 'lookup_hello')
2424

2525
do
26-
assert(evo.lookup('hello') == e1)
27-
assert(evo.lookup('world') == nil)
26+
assert(evo.lookup('lookup_hello') == e1)
27+
assert(evo.lookup('lookup_world') == nil)
2828

2929
do
30-
local entity_list, entity_count = evo.multi_lookup('hello')
30+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
3131
assert(entity_list and #entity_list == 1 and entity_count == 1)
3232
assert(entity_list[1] == e1)
3333
end
3434

3535
do
36-
local entity_list, entity_count = evo.multi_lookup('world')
36+
local entity_list, entity_count = evo.multi_lookup('lookup_world')
3737
assert(entity_list and #entity_list == 0 and entity_count == 0)
3838
end
3939
end
4040

41-
evo.set(e2, evo.NAME, 'hello')
42-
evo.set(e3, evo.NAME, 'hello')
41+
evo.set(e2, evo.NAME, 'lookup_hello')
42+
evo.set(e3, evo.NAME, 'lookup_hello')
4343

4444
do
45-
assert(evo.lookup('hello') == e3)
46-
assert(evo.lookup('world') == nil)
45+
assert(evo.lookup('lookup_hello') == e1)
46+
assert(evo.lookup('lookup_world') == nil)
4747

4848
do
49-
local entity_list, entity_count = evo.multi_lookup('hello')
49+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
5050
assert(entity_list and #entity_list == 3 and entity_count == 3)
5151
assert(entity_list[1] == e1 and entity_list[2] == e2 and entity_list[3] == e3)
5252
end
5353
end
5454

55-
evo.set(e2, evo.NAME, 'world')
55+
evo.set(e2, evo.NAME, 'lookup_world')
5656

5757
do
58-
assert(evo.lookup('hello') == e3)
59-
assert(evo.lookup('world') == e2)
58+
assert(evo.lookup('lookup_hello') == e1)
59+
assert(evo.lookup('lookup_world') == e2)
6060

6161
do
62-
local entity_list, entity_count = evo.multi_lookup('hello')
62+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
6363
assert(entity_list and #entity_list == 2 and entity_count == 2)
6464
assert(entity_list[1] == e1 and entity_list[2] == e3)
6565
end
6666

6767
do
68-
local entity_list, entity_count = evo.multi_lookup('world')
68+
local entity_list, entity_count = evo.multi_lookup('lookup_world')
6969
assert(entity_list and #entity_list == 1 and entity_count == 1)
7070
assert(entity_list[1] == e2)
7171
end
7272
end
7373

74-
evo.set(e3, evo.NAME, 'world')
74+
evo.set(e3, evo.NAME, 'lookup_world')
7575

7676
do
77-
assert(evo.lookup('hello') == e1)
78-
assert(evo.lookup('world') == e3)
77+
assert(evo.lookup('lookup_hello') == e1)
78+
assert(evo.lookup('lookup_world') == e2)
7979

8080
do
81-
local entity_list, entity_count = evo.multi_lookup('hello')
81+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
8282
assert(entity_list and #entity_list == 1 and entity_count == 1)
8383
assert(entity_list[1] == e1)
8484
end
8585

8686
do
87-
local entity_list, entity_count = evo.multi_lookup('world')
87+
local entity_list, entity_count = evo.multi_lookup('lookup_world')
8888
assert(entity_list and #entity_list == 2 and entity_count == 2)
8989
assert(entity_list[1] == e2 or entity_list[1] == e3)
9090
end
@@ -93,18 +93,84 @@ do
9393
evo.remove(e1, evo.NAME)
9494

9595
do
96-
assert(evo.lookup('hello') == nil)
97-
assert(evo.lookup('world') == e3)
96+
assert(evo.lookup('lookup_hello') == nil)
97+
assert(evo.lookup('lookup_world') == e2)
9898

9999
do
100-
local entity_list, entity_count = evo.multi_lookup('hello')
100+
local entity_list, entity_count = evo.multi_lookup('lookup_hello')
101101
assert(entity_list and #entity_list == 0 and entity_count == 0)
102102
end
103103

104104
do
105-
local entity_list, entity_count = evo.multi_lookup('world')
105+
local entity_list, entity_count = evo.multi_lookup('lookup_world')
106106
assert(entity_list and #entity_list == 2 and entity_count == 2)
107107
assert(entity_list[1] == e2 or entity_list[1] == e3)
108108
end
109109
end
110110
end
111+
112+
do
113+
local e1, e2, e3 = evo.id(3)
114+
115+
evo.set(e1, evo.NAME, 'lookup_e')
116+
117+
do
118+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
119+
assert(entity_list and #entity_list == 1 and entity_count == 1)
120+
assert(entity_list[1] == e1)
121+
end
122+
123+
evo.set(e2, evo.NAME, 'lookup_e')
124+
125+
do
126+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
127+
assert(entity_list and #entity_list == 2 and entity_count == 2)
128+
assert(entity_list[1] == e1 and entity_list[2] == e2)
129+
end
130+
131+
evo.set(e3, evo.NAME, 'lookup_e')
132+
133+
do
134+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
135+
assert(entity_list and #entity_list == 3 and entity_count == 3)
136+
assert(entity_list[1] == e1 and entity_list[2] == e2 and entity_list[3] == e3)
137+
end
138+
139+
evo.clear(e1, e2, e3)
140+
141+
do
142+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
143+
assert(entity_list and #entity_list == 0 and entity_count == 0)
144+
end
145+
146+
evo.set(e3, evo.NAME, 'lookup_e')
147+
148+
do
149+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
150+
assert(entity_list and #entity_list == 1 and entity_count == 1)
151+
assert(entity_list[1] == e3)
152+
end
153+
154+
evo.set(e2, evo.NAME, 'lookup_e')
155+
156+
do
157+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
158+
assert(entity_list and #entity_list == 2 and entity_count == 2)
159+
assert(entity_list[1] == e3 and entity_list[2] == e2)
160+
end
161+
162+
evo.set(e1, evo.NAME, 'lookup_e')
163+
164+
do
165+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
166+
assert(entity_list and #entity_list == 3 and entity_count == 3)
167+
assert(entity_list[1] == e3 and entity_list[2] == e2 and entity_list[3] == e1)
168+
end
169+
170+
evo.destroy(e3, e2, e1)
171+
172+
do
173+
local entity_list, entity_count = evo.multi_lookup('lookup_e')
174+
assert(entity_list and #entity_list == 0 and entity_count == 0)
175+
end
176+
end

0 commit comments

Comments
 (0)