root/1.8.2/trunk/test/testatree.pl

Revision 463, 13.6 KB (checked in by pennmush, 2 years ago)

PennMUSH 1.7.7p32 Archival

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