mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
More tests
This commit is contained in:
parent
cbbbf87e20
commit
8d69c5c898
9 changed files with 122 additions and 5 deletions
13
tools/qfcc/test/entity-field2.r
Normal file
13
tools/qfcc/test/entity-field2.r
Normal 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;
|
||||
}
|
30
tools/qfcc/test/entity-struct.r
Normal file
30
tools/qfcc/test/entity-struct.r
Normal 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
10
tools/qfcc/test/forward.r
Normal file
|
@ -0,0 +1,10 @@
|
|||
@extern void a (void);
|
||||
|
||||
void b (void)
|
||||
{
|
||||
a ();
|
||||
}
|
||||
|
||||
void a (void)
|
||||
{
|
||||
}
|
10
tools/qfcc/test/local-func.r
Normal file
10
tools/qfcc/test/local-func.r
Normal 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
12
tools/qfcc/test/move.r
Normal 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;
|
||||
}
|
|
@ -1,12 +1,19 @@
|
|||
struct foobar_s = {
|
||||
integer a;
|
||||
(struct foobar_s [])[4]b;
|
||||
struct foobar_s {
|
||||
float a;
|
||||
struct foobar_s *b[2];
|
||||
float c;
|
||||
};
|
||||
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.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;
|
||||
};
|
||||
|
|
8
tools/qfcc/test/storage.r
Normal file
8
tools/qfcc/test/storage.r
Normal file
|
@ -0,0 +1,8 @@
|
|||
@extern {
|
||||
float x;
|
||||
void () main =
|
||||
{
|
||||
x = 1;
|
||||
return;
|
||||
};
|
||||
};
|
23
tools/qfcc/test/vector.r
Normal file
23
tools/qfcc/test/vector.r
Normal 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;
|
||||
}
|
4
tools/qfcc/test/void-return.qc
Normal file
4
tools/qfcc/test/void-return.qc
Normal file
|
@ -0,0 +1,4 @@
|
|||
void () foo =
|
||||
{
|
||||
return;
|
||||
};
|
Loading…
Reference in a new issue