PennMUSH Community

root/1.8.3/trunk/test/testatree.pl

Revision 1117, 13.4 kB (checked in by shawnw, 1 year ago)

Merge with devel

Line 
1 login mortal
2 run tests:
3 # First, the basic tests enforcing tree-nature of the attributes.
4 # Attrs may not start or end in `
5 test("atree.basic.1", $god, "&foo` me=baz", "not a very good name");
6 test("atree.basic.2", $god, "&`bar me=baz", "not a very good name");
7 # Not even if there's a preexisting branch
8 test("atree.basic.3", $god, "&foo me=baz", "Set");
9 test("atree.basic.4", $god, "&foo` me=baz", "not a very good name");
10 # You may not have two ` in a row
11 test("atree.basic.5", $god, "&foo``bar me=baz", "not a very good name");
12 # Make a small tree
13 test("atree.basic.6", $god, "&foo me=baz", "Set");
14 test("atree.basic.7", $god, "&foo`bar me=baz", "Set");
15 test("atree.basic.8", $god, "&foo`bar`baz me=baz", "Set");
16 # Cannot clear branches with leaves until the leaves are cleared
17 test("atree.basic.9", $god, "&foo me", "!Cleared");
18 test("atree.basic.10", $god, "&foo`bar me", "!Cleared");
19 test("atree.basic.11", $god, "&foo`bar`baz me", "Cleared");
20 test("atree.basic.12", $god, "&foo`bar me", "Cleared");
21 test("atree.basic.13", $god, "&foo me", "Cleared");
22 # You can wipe, though.
23 test("atree.basic.14", $god, "&foo me=baz", "Set");
24 test("atree.basic.15", $god, "&foo`bar me=baz", "Set");
25 test("atree.basic.16", $god, "&foo`bar`baz me=baz", "Set");
26 test("atree.basic.17", $god, '@wipe me/foo', "wiped");
27
28 # Branch permissions
29 # May make a leaf without supporting branch
30 test("atree.branch.1", $god, "&foo`bar me=baz", "!You must set FOO first");
31 # And it must make the branch
32 test("atree.branch.2", $god, "think hasattr(me, foo)", "1");
33 # Another child should not wipe the previous values
34 test("atree.branch.3", $god, "&foo`bar`baz me=baz", "!You must set FOO first");
35 test("atree.branch.4", $god, "think get(me/foo`bar)", "baz");
36 # Clean up again
37 test("atree.branch.5", $god, '@wipe me/foo', "wiped");
38
39 # Wildcard attribute matching
40 # Rebuild a tree
41 test("atree.matching.1", $god, "&foo me=baz", "Set");
42 test("atree.matching.2", $god, "&foo`bar me=baz", "Set");
43 test("atree.matching.3", $god, "&foo`baz me=baz", "Set");
44 test("atree.matching.4", $god, "&foo`bar`baz me=baz", "Set");
45 # Examine should show a ` attribute flag for foo, foo`bar, but not foo`bar`baz
46 test("atree.matching.5", $god, "examine me/foo", 'FOO \[.*`\]');
47 test("atree.matching.6", $god, "examine me/foo`bar", 'FOO`BAR \[.*`\]');
48 test("atree.matching.7", $god, "examine me/foo`bar`baz", 'FOO`BAR`BAZ \[[^`]*\]');
49 # Examine doesn't show recursively, by default
50 test("atree.matching.8", $god, "examine me", ['FOO \[.*`\]', '!FOO`BAR']);
51 # But it will if you ask for it
52 test("atree.matching.9", $god, "examine me/**",
53      ['FOO \[.*`\]', 'FOO`BAR \[', 'FOO`BAR`BAZ \[[^`]+\]']);
54 # If you ask for an attribute, you don't get its children
55 test('atree.matching.10', $god, 'examine me/FOO',
56      ['FOO \[.*`\]', '!FOO`BAR \[', '!FOO`BAR`BAZ \[[^`]+\]']);
57 # You have to ask for the children
58 test('atree.matching.11', $god, 'examine me/FOO`',
59      ['!FOO \[.*`\]', 'FOO`BAR \[', 'FOO`BAZ \[', '!FOO`BAR`BAZ \[[^`]+\]']);
60 test('atree.matching.12', $god, 'examine me/FOO`BAR`',
61      ['!FOO \[.*`\]', '!FOO`BAR \[', '!FOO`BAZ \[', 'FOO`BAR`BAZ \[[^`]+\]']);
62 test('atree.matching.13', $god, 'examine me/FOO`*',
63      ['!FOO \[.*`\]', 'FOO`BAR \[', 'FOO`BAZ \[', '!FOO`BAR`BAZ \[[^`]+\]']);
64 # A single * doesn't match `
65 test('atree.matching.14', $god, 'examine me/FOO*Z',
66      ['!FOO \[.*`\]', '!FOO`BAR \[', '!FOO`BAZ \[', '!FOO`BAR`BAZ \[[^`]+\]']);
67 # A double * does match `
68 test('atree.matching.15', $god, 'examine me/FOO**Z',
69      ['!FOO \[.*`\]', '!FOO`BAR \[', 'FOO`BAZ \[', 'FOO`BAR`BAZ \[[^`]+\]']);
70 # @decompile gets everything by default
71 test('atree.matching.16', $god, '@decompile me',
72      ['&FOO ', '&FOO`BAR ', '&FOO`BAR`BAZ ']);
73 # But only the top layer if you say so
74 test('atree.matching.17', $god, '@decompile me/*',
75      ['&FOO ', '!&FOO`BAR ', '!&FOO`BAR`BAZ ']);
76 # lattr() works like examine, only top by default
77 test('atree.matching.18', $god, 'think lattr(me)',
78      ['\bFOO\b', '!\bFOO`BAR\b', '!\bFOO`BAR`BAZ\b']);
79 test('atree.matching.19', $god, 'think lattr(me/**)',
80      ['\bFOO\b', '\bFOO`BAR\b', '\bFOO`BAR`BAZ\b']);
81 test("atree.matching.20", $god, 'think flags(me/foo)', '`');
82
83 # Permissions checks
84 # Need a mortal for this...
85 # Build a tree from different places...
86 test('atree.perms.2', $god, '&foo mortal=baz', 'Set');
87 test('atree.perms.3', $god, '&foo`bar mortal=baz', 'Set');
88 test('atree.perms.4', $mortal, '@decompile me', ['&FOO ', '&FOO`BAR ']);
89 test('atree.perms.5', $mortal, '&foo`bar me=baz', 'Set');
90 test('atree.perms.6', $mortal, '&foo`bar`baz me=baz', 'Set');
91 # Start flipping perms...
92 test('atree.perms.7', $god, '@set mortal/foo`bar=wiz', 'set');
93 test('atree.perms.8', $mortal, '@decompile me',
94      ['&FOO ', '&FOO`BAR ', '&FOO`BAR`BAZ ']);
95 # Cannot overwrite wiz-only as mortal, or make stuff under it
96 test('atree.perms.9', $mortal, '&foo`bar me=baz', '!Set');
97 test('atree.perms.10', $mortal, '&foo`bar`baz me=baz', '!Set');
98 test('atree.perms.11', $mortal, '&foo`bar`qux me=baz', '!Set');
99 # Cannot see under mortal_dark as mortal
100 test('atree.perms.12', $god, '@set mortal/foo`bar=mortal_dark', 'set');
101 test('atree.perms.13', $mortal, '@decompile me',
102      ['&FOO ', '!&FOO`BAR ', '!&FOO`BAR`BAZ ', '!&FOO`BAR`QUX ']);
103 # Still can't write there (still wiz-only)
104 test('atree.perms.14', $mortal, '&foo`bar me=baz', '!Set');
105 test('atree.perms.15', $mortal, '&foo`bar`baz me=baz', '!Set');
106 test('atree.perms.16', $mortal, '&foo`bar`qux me=baz', '!Set');
107 # Turn off wiz-only, but still can't see it...
108 test('atree.perms.17', $god, '@set mortal/foo`bar=!wiz', 'reset');
109 test('atree.perms.18', $mortal, '@decompile me',
110      ['&FOO ', '!&FOO`BAR ', '!&FOO`BAR`BAZ ', '!&FOO`BAR`QUX ']);
111 # But you can write there again...
112 test('atree.perms.19', $mortal, '&foo`bar me=baz', 'Set');
113 test('atree.perms.20', $mortal, '&foo`bar`baz me=baz', 'Set');
114 test('atree.perms.21', $mortal, '&foo`bar`qux me=baz', 'Set');
115
116 # Parenting and ancestry
117 test('atree.parent.1', $mortal, '@create ancestor', 'Created');
118 test('atree.parent.2', $mortal, '@create parent', 'Created');
119 test('atree.parent.3', $mortal, '@create child', 'Created');
120 test('atree.parent.4', $mortal, 'drop child', '.');
121 test('atree.parent.5', $mortal, 'drop parent', '.');
122 test('atree.parent.6', $mortal, 'drop ancestor', '.');
123 test('atree.parent.7', $mortal, '@parent child=parent', 'Parent changed');
124 test('atree.parent.8', $god,
125      '@config/set ancestor_thing=[after(num(ancestor),#)]', 'set');
126 # Can we see stuff from the ancestor?
127 test('atree.parent.9', $mortal, '&foo ancestor=urk', 'Set');
128 test('atree.parent.10', $mortal, '&foo`bar ancestor=urk', 'Set');
129 test('atree.parent.11', $mortal, '&foo`bar`baz ancestor=urk', 'Set');
130 test('atree.parent.12', $mortal, 'think get(child/foo)', 'urk');
131 test('atree.parent.13', $mortal, 'think get(child/foo`bar)', 'urk');
132 # Can we see stuff from the parent?
133 test('atree.parent.14', $mortal, '&foo parent=wibble', 'Set');
134 test('atree.parent.15', $mortal, '&foo`bar parent=gleep', 'Set');
135 test('atree.parent.16', $mortal, 'think get(child/foo)', 'wibble');
136 test('atree.parent.17', $mortal, 'think get(child/foo`bar)', 'gleep');
137 test('atree.parent.18', $mortal, '&foo`bar`baz child=boom', 'Set');
138 test('atree.parent.19', $mortal, 'think -[get(child/foo)]-', '--');
139 test('atree.parent.20', $mortal, 'think -[get(child/foo`bar)]-', '--');
140 test('atree.parent.21', $mortal, '@wipe child/foo', 'wiped');
141 # Setting no_inherit puts it back to the ancestor
142 test('atree.parent.22', $mortal, '@set parent/foo=no_inherit', 'set');
143 test('atree.parent.23', $mortal, 'think get(child/foo)', '!wibble');
144 test('atree.parent.24', $god, 'think get(child/foo`bar)', '!gleep');
145 test('atree.parent.25', $god, 'think get(child/foo)', 'urk');
146 test('atree.parent.26', $god, 'think get(child/foo`bar)', 'urk');
147
148 # Mix permissions and parents
149 # If parent is inheritable again, and mortal_dark,
150 # then we can't see the ancestor through it
151 test('atree.parentperms.1', $mortal, '@set parent/foo=!no_inherit', 'set');
152 test('atree.parentperms.2', $god, '@set parent/foo`bar=mortal_dark', 'set');
153 test('atree.parentperms.3', $mortal, 'think get(child/foo`bar`baz)', '!urk');
154 # We can't see it, either
155 test('atree.parentperms.4', $mortal, 'think get(child/foo`bar)', '!gleep');
156 test('atree.parentperms.5', $mortal, '@set parent/foo=no_inherit', 'set');
157 # no_inherit trumps mortal_dark
158 test('atree.parentperms.6', $mortal, 'think get(child/foo`bar`baz)', 'urk');
159 test('atree.parentperms.7', $mortal, 'think get(child/foo`bar)', 'urk');
160 test('atree.parentperms.8', $god, '@set parent/foo=mortal_dark', 'set');
161 test('atree.parentperms.9', $mortal, 'think get(child/foo`bar)', 'urk');
162
163 # Command checks
164 # Need explicit grandparent, because ancestors aren't checked for commands
165 test('atree.command.1', $mortal, '@create grand', []);
166 test('atree.command.2', $mortal, 'drop grand', []);
167 test('atree.command.3', $mortal, '@parent parent=grand', []);
168 test('atree.command.4', $mortal, '&bar grand=$bar:say Grand Bar', 'Set');
169 test('atree.command.5', $mortal, '&bar`baz grand=$bar`baz:say Grand Baz', []);
170 test('atree.command.6', $mortal, '&bar parent=$bar:say Parent Bar', 'Set');
171 test('atree.command.7', $mortal, '&bar`baz parent=$bar`baz:say Parent Baz', []);
172 test('atree.command.8', $mortal, '@set child=!no_command', 'set');
173 # Do commands work from parent?
174 test('atree.command.9', $god, 'bar', '!Bar');
175 test('atree.command.10', $god, undef, 'Parent Bar');
176 test('atree.command.11', $god, 'bar`baz', []);
177 test('atree.command.12', $god, undef, 'Parent Baz');
178 # Child should block parent
179 test('atree.command.13', $mortal, '&bar child=$bar:say Child!', 'Set');
180 test('atree.command.14', $god, 'bar', '!Bar');
181 test('atree.command.15', $god, undef, ['!Bar', 'Child']);
182 # Child no_command blocks parent branch, too
183 test('atree.command.16', $mortal, '@set child/bar=no_command', 'set');
184 test('atree.command.17', $god, 'bar`baz', '!Baz');
185 test('atree.command.18', $god, undef, '!Baz');
186 # Parent no_command not masked by child not no_command...
187 test('atree.command.19', $mortal, '@set child/bar=!no_command', 'set');
188 test('atree.command.20', $mortal, '@set parent/bar=no_command', 'set');
189 test('atree.command.21', $god, 'bar`baz', '!Baz');
190 test('atree.command.22', $god, undef, '!Baz');
191 # no_command can be on the leaf, too
192 test('atree.command.23', $mortal, '@set parent/bar=!no_command', 'set');
193 test('atree.command.24', $mortal, '@set parent/bar`baz=no_command', 'set');
194 test('atree.command.25', $god, 'bar`baz', '!Baz');
195 test('atree.command.26', $god, undef, '!Baz');
196 # no_inherit trumps no_command
197 test('atree.command.27', $mortal, '@set parent/bar=no_inherit', 'set');
198 test('atree.command.28', $mortal, '@set parent/bar`baz=no_command', 'set');
199 test('atree.command.29', $god, 'bar`baz', '!Baz');
200 test('atree.command.30', $god, undef, 'Grand Baz');
201 test('atree.command.31', $mortal, '@set parent/bar=no_command', 'set');
202 test('atree.command.32', $mortal, '&bar child', []);
203 test('atree.command.33', $god, 'bar', '!Baz');
204 test('atree.command.34', $god, undef, 'Grand Bar');
205
206 # Test for the child recognition bugs:
207 test('atree.sortorder.1', $mortal, '&abc grand=$abc:say Grand ABC', 'Set');
208 test('atree.sortorder.2', $mortal, '&abcd grand=$abcd:say Grand D', 'Set');
209 test('atree.sortorder.3', $mortal, '&abc`xyz grand=$abc`xyz:say Grand XYZ', []);
210 test('atree.sortorder.4', $mortal, '&abc parent=$abc:say Parent ABC', 'Set');
211 test('atree.sortorder.5', $mortal, '&abcd parent=$abcd:say Parent D', 'Set');
212 test('atree.sortorder.6', $mortal, '&abc`xyz parent=$abc`xyz:say Parent XYZ', []);
213 test("atree.sortorder.7", $god, 'examine parent', 'ABC \[.*`\]');
214 test("atree.sortorder.8", $god, '&abc parent', '!Cleared');
215 test('atree.sortorder.9', $mortal, '@set child=!no_command', 'set');
216 # Do commands work from parent?
217 test('atree.sortorder.10', $god, 'abc', '!ABC');
218 test('atree.sortorder.11', $god, undef, 'Parent ABC');
219 test('atree.sortorder.12', $god, 'abc`xyz', []);
220 test('atree.sortorder.13', $god, undef, 'Parent XYZ');
221 # Child should block parent
222 test('atree.sortorder.14', $mortal, '&abc child=$abc:say Child!', 'Set');
223 test('atree.sortorder.15', $god, 'abc', '!ABC');
224 test('atree.sortorder.16', $god, undef, ['!ABC', 'Child']);
225 # Child no_command blocks parent branch, too
226 test('atree.sortorder.17', $mortal, '@set child/abc=no_command', 'set');
227 test('atree.sortorder.18', $god, 'abc`xyz', '!XYZ');
228 test('atree.sortorder.19', $god, undef, '!XYZ');
229 # Parent no_command not masked by child not no_command...
230 test('atree.sortorder.20', $mortal, '@set child/abc=!no_command', 'set');
231 test('atree.sortorder.21', $mortal, '@set parent/abc=no_command', 'set');
232 test('atree.sortorder.22', $god, 'abc`xyz', '!XYZ');
233 test('atree.sortorder.23', $god, undef, '!XYZ');
234 # no_command can be on the leaf, too
235 test('atree.sortorder.24', $mortal, '@set parent/abc=!no_command', 'set');
236 test('atree.sortorder.25', $mortal, '@set parent/abc`xyz=no_command', 'set');
237 test('atree.sortorder.26', $god, 'abc`xyz', '!XYZ');
238 test('atree.sortorder.27', $god, undef, '!XYZ');
239 # no_inherit trumps no_command
240 test('atree.sortorder.28', $mortal, '@set parent/abc=no_inherit', 'set');
241 test('atree.sortorder.29', $mortal, '@set parent/abc`xyz=no_command', 'set');
242 test('atree.sortorder.30', $god, 'abc`xyz', '!XYZ');
243 test('atree.sortorder.31', $god, undef, 'Grand XYZ');
244 test('atree.sortorder.32', $mortal, '@set parent/abc=no_command', 'set');
245 test('atree.sortorder.33', $mortal, '&abc child', []);
246 test('atree.sortorder.34', $god, 'abc', '!XYZ');
247 test('atree.sortorder.35', $god, undef, 'Grand ABC');
248 # wipe check
249 test("atree.sortorder.36", $god, '@wipe parent', 'wiped');
250 test("atree.sortorder.37", $god, '@wipe grand/abc', []);
251 test("atree.sortorder.38", $god, 'examine grand/**', '!ABC\b');
Note: See TracBrowser for help on using the browser.