fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
theft_types_internal.h
(2587B)
1 #ifndef THEFT_TYPES_INTERNAL_H
2 #define THEFT_TYPES_INTERNAL_H
3
4 typedef struct theft theft;
5
6 #define THEFT_MAX_TACTICS ((uint32_t)-1)
7 #define DEFAULT_THEFT_SEED 0xa600d16b175eedL
8
9 typedef enum {
10 ALL_GEN_OK, /* all arguments generated okay */
11 ALL_GEN_SKIP, /* skip due to user constraints */
12 ALL_GEN_DUP, /* skip probably duplicated trial */
13 ALL_GEN_ERROR, /* memory error or other failure */
14 } all_gen_res_t;
15
16 typedef enum {
17 SHRINK_OK, /* simplified argument further */
18 SHRINK_DEAD_END, /* at local minima */
19 SHRINK_ERROR, /* hard error during shrinking */
20 } shrink_res;
21
22 /* Testing context for a specific property function. */
23 struct theft_propfun_info {
24 const char *name; /* property name, can be NULL */
25 theft_propfun *fun; /* property function under test */
26
27 /* Type info for ARITY arguments. */
28 uint8_t arity; /* number of arguments */
29 struct theft_type_info *type_info[THEFT_MAX_ARITY];
30
31 /* Optional array of seeds to always run.
32 * Can be used for regression tests. */
33 int always_seed_count; /* number of seeds */
34 theft_seed *always_seeds; /* seeds to always run */
35 };
36
37 static theft_trial_res
38 call_fun(struct theft_propfun_info *info, void **args);
39
40 static bool run_trial(struct theft *t, struct theft_propfun_info *info,
41 void **args, theft_progress_cb *cb, void *env,
42 struct theft_trial_report *r, struct theft_trial_info *ti,
43 theft_progress_callback_res *cres);
44
45 static void mark_called(theft *t, struct theft_propfun_info *info,
46 void **args, void *env);
47
48 static bool check_called(theft *t, struct theft_propfun_info *info,
49 void **args, void *env);
50
51 static theft_progress_callback_res report_on_failure(theft *t,
52 struct theft_propfun_info *info,
53 struct theft_trial_info *ti, theft_progress_cb *cb, void *env);
54
55 static all_gen_res_t gen_all_args(theft *t, struct theft_propfun_info *info,
56 theft_seed seed, void *args[THEFT_MAX_ARITY], void *env);
57
58 static void free_args(struct theft_propfun_info *info,
59 void **args, void *env);
60
61 static theft_run_res theft_run_internal(struct theft *t,
62 struct theft_propfun_info *info,
63 int trials, theft_progress_cb *cb, void *env,
64 struct theft_trial_report *r);
65
66 static bool attempt_to_shrink(theft *t, struct theft_propfun_info *info,
67 void *args[], void *env);
68
69 static shrink_res
70 attempt_to_shrink_arg(theft *t, struct theft_propfun_info *info,
71 void *args[], void *env, int ai);
72
73 #endif