various tests

This commit is contained in:
Bill Currie 2001-07-25 21:48:20 +00:00
parent d44f60f17c
commit c553917c53
3 changed files with 58 additions and 0 deletions

View file

@ -112,6 +112,42 @@ bi_traceoff (progs_t *pr)
pr->pr_trace = false; pr->pr_trace = false;
} }
static void
bi_printf (progs_t *pr)
{
const char *fmt = G_STRING (pr, OFS_PARM0);
char c;
int count = 0;
float *v;
while ((c = *fmt++)) {
if (c == '%' && count < 7) {
switch (c = *fmt++) {
case 'i':
fprintf (stdout, "%i", G_INT (pr, OFS_PARM1 + count++ * 3));
break;
case 'f':
fprintf (stdout, "%f", G_FLOAT (pr, OFS_PARM1 + count++ * 3));
break;
case 's':
fputs (G_STRING (pr, OFS_PARM1 + count++ * 3), stdout);
break;
case 'v':
v = G_VECTOR (pr, OFS_PARM1 + count++ * 3);
fprintf (stdout, "'%f %f %f'", v[0], v[1], v[2]);
break;
default:
fputc ('%', stdout);
fputc (c, stdout);
count = 7;
break;
}
} else {
fputc (c, stdout);
}
}
}
builtin_t builtins[] = { builtin_t builtins[] = {
bi_fixme, bi_fixme,
bi_print, bi_print,
@ -125,6 +161,7 @@ builtin_t builtins[] = {
bi_seek, bi_seek,
bi_traceon, bi_traceon,
bi_traceoff, bi_traceoff,
bi_printf,
}; };
void void

View file

@ -11,6 +11,8 @@ integer (integer handle, integer pos, integer whence) seek = #9;
void() traceon = #10; // turns statment trace on void() traceon = #10; // turns statment trace on
void() traceoff = #11; void() traceoff = #11;
void (...) printf = #12;
float time; float time;
entity self; entity self;

View file

@ -58,6 +58,11 @@ void () blarg =
{ {
local float foo = -1; local float foo = -1;
local float bar; local float bar;
local entity te;
while (te) {
if (bar)
bar = 0;
}
do { do {
foo = 1; foo = 1;
} while (foo); } while (foo);
@ -78,6 +83,8 @@ entity sent;
void () eek = void () eek =
{ {
local string bop = ""; local string bop = "";
local vector v = '1 2 3';
traceon(); traceon();
if (sent && sent.owner != self ) if (sent && sent.owner != self )
self.origin = '0 0 0'; self.origin = '0 0 0';
@ -85,6 +92,13 @@ void () eek =
test_int (1); test_int (1);
if (bop) if (bop)
traceoff(); traceoff();
printf ("%v\n", v);
v = 2 * v;
printf ("%v\n", v);
v = v * 2;
printf ("%v\n", v);
v = -v;
printf ("%v\n", v);
}; };
void () assign = void () assign =
@ -97,4 +111,9 @@ void () assign =
foo = bar = bar + 1; foo = bar = bar + 1;
foo = self.nextthink = self.nextthink + 1.0; foo = self.nextthink = self.nextthink + 1.0;
self.frame = self.nextthink = self.nextthink + 1.0; self.frame = self.nextthink = self.nextthink + 1.0;
foo = self.nextthink = foo + 1.0;
self.nextthink = foo = foo + 1.0;
self.frame = self.nextthink = foo + 1.0;
foo = self.nextthink = foo;
self.frame = self.nextthink = foo;
}; };