X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/1c3b0c0e6f9339e76e42f6393e554c7dfc58e205..090f5235db47c11457de1d032271d7c01dd7d0b9:/t/declgen.c diff --git a/t/declgen.c b/t/declgen.c index 0e76348..459a68e 100644 --- a/t/declgen.c +++ b/t/declgen.c @@ -1,6 +1,6 @@ /* * Generate random C declarations for testing. - * Copyright © 2012, 2021-2022 Nick Bowler + * Copyright © 2012, 2021-2023 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,7 +105,7 @@ struct cdecl_declspec *gen_qualifiers(struct test_rng *rng, bool restrictqual) { struct cdecl_declspec *s = NULL; - while (test_rng_uniform(rng) < 0.5) { + while (test_rng_50_50(rng)) { s = new_specifier(s); switch (test_rng_uniform_int(rng, 2+restrictqual)) { @@ -134,7 +134,7 @@ struct cdecl_declspec *gen_funcspecs(struct test_rng *rng) { struct cdecl_declspec *s = NULL; - while (test_rng_uniform(rng) < 0.5) { + while (test_rng_50_50(rng)) { s = new_specifier(s); s->type = CDECL_FUNC_INLINE; } @@ -151,7 +151,7 @@ struct cdecl_declspec *gen_storspecs(struct test_rng *rng, bool registeronly) { struct cdecl_declspec *s; - if (test_rng_uniform(rng) < 0.5) + if (test_rng_50_50(rng)) return NULL; s = new_specifier(NULL); @@ -334,7 +334,7 @@ static void gen_function(struct test_rng *rng, struct cdecl_declarator *d) d->type = CDECL_DECL_FUNCTION; d->u.function.parameters = NULL; - while (test_rng_uniform(rng) < 0.5) { + while (test_rng_50_50(rng)) { unsigned flags = GEN_ONLY_REGISTER | GEN_NO_FUNCTION; struct cdecl *param; @@ -350,8 +350,8 @@ static void gen_function(struct test_rng *rng, struct cdecl_declarator *d) } if (d->u.function.parameters) { - d->u.function.variadic = test_rng_uniform(rng) < 0.5; - } else if (test_rng_uniform(rng) < 0.5) { + d->u.function.variadic = test_rng_50_50(rng); + } else if (test_rng_50_50(rng)) { struct cdecl *param; /* We will never generate (void) above; do it here. */ @@ -375,12 +375,12 @@ struct cdecl_declarator *gen_declarators(struct test_rng *rng) unsigned limit = 3; d = new_declarator(NULL); - if (test_rng_uniform(rng) < 0.5) { + if (test_rng_50_50(rng)) { d->type = CDECL_DECL_IDENT; d->u.ident = gen_identifier(rng); } - while (test_rng_uniform(rng) < 0.5) { + while (test_rng_50_50(rng)) { d = new_declarator((p = d)); switch (test_rng_uniform_int(rng, limit)) {