| 1 |
/* Copyright (c) 1993 by Michael J. Roberts. All Rights Reserved. */ |
| 2 |
/* |
| 3 |
Name |
| 4 |
bugs.t - regression for various bugs |
| 5 |
Function |
| 6 |
tests a number of operations that have been buggy in the past, |
| 7 |
plus some assorted new features |
| 8 |
Notes |
| 9 |
none |
| 10 |
Modified |
| 11 |
01/15/93 MJRoberts - creation |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <adv.t> |
| 15 |
#include <std.t> |
| 16 |
|
| 17 |
startroom: room |
| 18 |
sdesc = "Start Room" |
| 19 |
ldesc = "There's nowhere to go." |
| 20 |
; |
| 21 |
|
| 22 |
bones: item |
| 23 |
location = startroom |
| 24 |
noun = 'bone' 'bones' 'skeleton' |
| 25 |
sdesc = "skeleton" |
| 26 |
ldesc = "It's the skeleton of a previous explorer. " |
| 27 |
iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); } |
| 28 |
doOpen(actor) = { "You can't open a skeleton!!!!!"; } |
| 29 |
dobjGen(a, v, i, p) = |
| 30 |
{ |
| 31 |
if (v <> inspectVerb) |
| 32 |
{ |
| 33 |
"A bolt of lightning leaps across the room as you |
| 34 |
disturb the skeleton. \"Fool! You shall be punished |
| 35 |
for this desecration!\" a voice bellows. "; |
| 36 |
exit; |
| 37 |
} |
| 38 |
} |
| 39 |
; |
| 40 |
|
| 41 |
rustyKnife: item |
| 42 |
location = startroom |
| 43 |
noun = 'knife' |
| 44 |
adjective = 'rusty' |
| 45 |
sdesc = "rusty knife" |
| 46 |
; |
| 47 |
|
| 48 |
fuse1: function(parm) |
| 49 |
{ |
| 50 |
/* tmp := parm; */ |
| 51 |
"\bThis is fuse1\b"; |
| 52 |
} |
| 53 |
|
| 54 |
testobj: object testprop = { "\bThis is testobj.testprop\b"; }; |
| 55 |
|
| 56 |
showlist: function(l) |
| 57 |
{ |
| 58 |
local i, tot; |
| 59 |
|
| 60 |
"[ "; |
| 61 |
for (tot := length(l), i := 1 ; i <= tot ; ++i) |
| 62 |
"<< l[i] >> "; |
| 63 |
"]"; |
| 64 |
} |
| 65 |
|
| 66 |
andlist: function(l1, l2) |
| 67 |
{ |
| 68 |
showlist(l1); " and "; showlist(l2); " = "; |
| 69 |
showlist(intersect(l1, l2)); "\n"; |
| 70 |
} |
| 71 |
|
| 72 |
isectVerb: deepverb verb = 'isect' |
| 73 |
action(actor) = |
| 74 |
{ |
| 75 |
andlist([1 2 3 4 5 6], [3 5 7]); |
| 76 |
andlist([3 5 7], [1 2 3 4 5 6]); |
| 77 |
andlist([1 1 1], [2 2 2]); |
| 78 |
andlist([1 1 1], [1 1]); |
| 79 |
andlist([1 1 1], [1 2]); |
| 80 |
andlist(['abc' 'def' 'ghi'], ['xyz' 'abc' 'zzz']); |
| 81 |
} |
| 82 |
; |
| 83 |
|
| 84 |
testVerb: deepverb verb = 'test' action(actor) = { foo3(); } ; |
| 85 |
test2Verb: deepverb verb = 'test2' |
| 86 |
action(actor) = |
| 87 |
{ |
| 88 |
"Setting fuse fuse1 in 3 turns\n"; |
| 89 |
setfuse(fuse1, 3, nil); |
| 90 |
|
| 91 |
"Setting notify testobj, &testprop, 3\n"; |
| 92 |
notify(testobj, &testprop, 3); |
| 93 |
} |
| 94 |
; |
| 95 |
|
| 96 |
test3verb: deepverb verb = 'runfuses' |
| 97 |
action(actor) = |
| 98 |
{ |
| 99 |
rundaemons(); |
| 100 |
if (runfuses()) "Fuses ran.\n"; else "No fuses ran.\n"; |
| 101 |
} |
| 102 |
; |
| 103 |
|
| 104 |
foo4verb: deepverb verb = 'foo4' action(actor) = { foo4(); } ; |
| 105 |
foo4: function |
| 106 |
{ |
| 107 |
local t := gettime(); |
| 108 |
local i; |
| 109 |
|
| 110 |
"The time is: "; showlist(t); "\n"; |
| 111 |
|
| 112 |
for (i := 1 ; i <= 9 ; ++i) "<< t[i] >> "; "\n"; |
| 113 |
|
| 114 |
"getfuse(fuse1, nil) = "; say(getfuse(fuse1, nil)); |
| 115 |
"\ngetfuse(testobj, &testprop) = "; say(getfuse(testobj, &testprop)); |
| 116 |
"\n"; |
| 117 |
} |
| 118 |
|
| 119 |
foo3a: function(a, b) { "foo3a: << a >>...<< b >>...\n"; } |
| 120 |
|
| 121 |
foo3: function |
| 122 |
{ |
| 123 |
local l := [1 2 3 4 5]; |
| 124 |
local x; |
| 125 |
|
| 126 |
foo3a(1 = 1 ? '1 = 1' : '1 <> 1!!!', 2); |
| 127 |
|
| 128 |
l[3] := 9; |
| 129 |
showlist(l); " - should be [1 2 9 4 5]\n"; |
| 130 |
l[5] := 10; |
| 131 |
showlist(l); " - should be [1 2 9 4 10]\n"; |
| 132 |
|
| 133 |
l[4] += 3; |
| 134 |
showlist(l); " - should be [1 2 9 7 10]\n"; |
| 135 |
x := --l[2]; |
| 136 |
showlist(l); " - should be [1 1 9 7 10]\n"; |
| 137 |
|
| 138 |
global.tp := [1 2 3]; |
| 139 |
global.tp[2] += 3; |
| 140 |
showlist(global.tp); " - should be [1 5 3]\n"; |
| 141 |
} |
| 142 |
|
| 143 |
foo2verb: deepverb verb = 'foo2' action(actor) = { foo2(); } ; |
| 144 |
foo2: function |
| 145 |
{ |
| 146 |
local i; |
| 147 |
"Enter number> "; i := cvtnum(input()); |
| 148 |
switch(i) |
| 149 |
{ |
| 150 |
case 1: |
| 151 |
"One"; |
| 152 |
break; |
| 153 |
case 2: |
| 154 |
"Two"; |
| 155 |
break; |
| 156 |
case 3: |
| 157 |
"Three"; |
| 158 |
break; |
| 159 |
default: |
| 160 |
"Not 1, 2, or 3"; |
| 161 |
} |
| 162 |
"\n"; |
| 163 |
|
| 164 |
switch(i) |
| 165 |
{ |
| 166 |
case 4: |
| 167 |
"Four - enter another> "; |
| 168 |
switch(cvtnum(input())) |
| 169 |
{ |
| 170 |
case 1: |
| 171 |
"The second number is one"; |
| 172 |
break; |
| 173 |
case 2: |
| 174 |
"The second number is two"; |
| 175 |
break; |
| 176 |
default: |
| 177 |
"The second number is not 1 or 2"; |
| 178 |
} |
| 179 |
break; |
| 180 |
default: |
| 181 |
"Not 4"; |
| 182 |
} |
| 183 |
"\n"; |
| 184 |
} |
| 185 |
|
| 186 |
fooverb: deepverb verb = 'foo' action(actor) = { foo(); } ; |
| 187 |
foo: function |
| 188 |
{ |
| 189 |
local i; |
| 190 |
|
| 191 |
"Before goto...\n"; |
| 192 |
goto testlabel; |
| 193 |
"After goto (should never be here!)...\n"; |
| 194 |
testlabel: |
| 195 |
"After testlabel...\n"; |
| 196 |
|
| 197 |
for (i := 0 ; i < 10 ; ++i) |
| 198 |
{ |
| 199 |
if (i = 5) continue; |
| 200 |
"i = << i >>\n"; |
| 201 |
} |
| 202 |
|
| 203 |
i := [1 2 3]; |
| 204 |
"datatype(i) = <<datatype(i)>>\n"; |
| 205 |
i := rand(5); |
| 206 |
"datatype(i) = <<datatype(i)>>\n"; |
| 207 |
} |