More tests

This commit is contained in:
Bill Currie 2011-03-09 20:34:23 +09:00
parent cbbbf87e20
commit 8d69c5c898
9 changed files with 122 additions and 5 deletions

View file

@ -0,0 +1,13 @@
float (float val, float inc, float max) inc = #0;
entity self;
float (.string fld) foo = { return 0; };
float (.float fld) inc_field =
{
local float new;
new = inc (self.fld, 2, 3);
if (new == self.fld)
return 0;
self.fld = new;
return 1;
}

View file

@ -0,0 +1,30 @@
typedef struct foo_s {
integer a, b;
} foo_t;
entity self;
foo_t a, b;
vector x, y;
integer i, j;
.vector v;
.foo_t foo;
void bar (entity other)
{
#if 0
self.foo = a;
b = self.foo;
self.foo = other.foo;
a = b;
self.v = x;
y = self.v;
self.v = other.v;
x = y;
#endif
self.foo.b = i;
j = self.foo.b;
self.foo.a = self.foo.b;
self.foo.b = self.foo.a;
}

10
tools/qfcc/test/forward.r Normal file
View file

@ -0,0 +1,10 @@
@extern void a (void);
void b (void)
{
a ();
}
void a (void)
{
}

View file

@ -0,0 +1,10 @@
.float () th_takeitem;
void (entity e1, entity e2)
_override_swap =
{
local float () t_f_v;
t_f_v = e1.th_takeitem;
e1.th_takeitem = e2.th_takeitem;
e2.th_takeitem = t_f_v;
}

12
tools/qfcc/test/move.r Normal file
View file

@ -0,0 +1,12 @@
struct plitem_s {integer dummy;};
typedef struct plitem_s plitem_t;
typedef struct foo_s {
integer x;
plitem_t i;
} foo_t;
void bar (foo_t *foo, plitem_t item)
{
foo.i = item;
}

View file

@ -1,12 +1,19 @@
struct foobar_s = { struct foobar_s {
integer a; float a;
(struct foobar_s [])[4]b; struct foobar_s *b[2];
float c;
}; };
typedef struct foobar_s foobar_t; typedef struct foobar_s foobar_t;
typedef foobar_t [] foobar_p; typedef foobar_t *foobar_p;
void (foobar_p foo, vector x, integer y) bar = void (foobar_p foo, vector x, integer y, foobar_t z) bar =
{ {
foo.a = x.z; foo.a = x.z;
foo.b[1] = (foobar_p)(integer)x.y; foo.b[1] = (foobar_p)(integer)x.y;
z.a = x_z;
z.c = x.x;
x.y = z.c;
x_x = 0;
x_y = 0;
x.z = 0;
}; };

View file

@ -0,0 +1,8 @@
@extern {
float x;
void () main =
{
x = 1;
return;
};
};

23
tools/qfcc/test/vector.r Normal file
View file

@ -0,0 +1,23 @@
entity self;
.vector velocity;
.vector oldorigin;
.float speed;
@extern .vector avel;
@extern vector vel;
void (vector tdest, float speed, void () func) SUB_CalcMove = {}
vector normalize (vector x) = #0;
float vlen (vector x) = #0;
void oof (void)
{
}
void foo (void)
{
float forward = vlen (self.velocity);
forward *= 0.8;
self.velocity = forward * normalize (self.velocity);
SUB_CalcMove(self.oldorigin, self.speed, oof);
self.avel_y = vel_z;
}

View file

@ -0,0 +1,4 @@
void () foo =
{
return;
};