19struct hegel_collection_t;
21struct hegel_state_machine_t;
22struct hegel_recursion_t;
29namespace hegel::internal {
46 enum class LabelName {
93 inline constexpr std::size_t label_name_count =
94 static_cast<std::size_t
>(LabelName::Spans) + 1;
98 uint64_t label(LabelName name);
102 uint64_t type_label(
const std::type_info& type);
113 void start_span(
const TestCase& tc, uint64_t label);
114 void stop_span(
const TestCase& tc,
bool discard =
false);
120 void pause_faults(
const TestCase& tc);
121 void unpause_faults(
const TestCase& tc);
126 class PauseFaultsScope {
128 PauseFaultsScope(
const TestCase& tc,
bool enabled);
130 PauseFaultsScope(
const PauseFaultsScope&) =
delete;
131 PauseFaultsScope& operator=(
const PauseFaultsScope&) =
delete;
138 int64_t draw_integer(
const TestCase& tc, int64_t min_value,
141 uint64_t draw_integer_unsigned(
const TestCase& tc, uint64_t min_value,
146 void draw_integer_bytes(
const TestCase& tc,
const uint8_t* min_value,
147 const uint8_t* max_value, std::size_t len,
149 bool draw_boolean(
const TestCase& tc,
double p,
150 std::optional<bool> forced = std::nullopt);
151 double draw_float(
const TestCase& tc, uint32_t width,
double min_value,
152 double max_value,
bool allow_nan,
bool allow_infinity,
153 bool exclude_min,
bool exclude_max,
154 double smallest_nonzero_magnitude);
159 inline constexpr int filter_attempts = 3;
161 inline constexpr uint64_t no_max_size = ~uint64_t{0};
162 class CollectionHandle {
164 CollectionHandle(
const TestCase& tc, uint64_t min_size,
167 CollectionHandle(
const CollectionHandle&) =
delete;
168 CollectionHandle& operator=(
const CollectionHandle&) =
delete;
170 bool more(
const TestCase& tc);
172 void reject(
const TestCase& tc,
const char* why);
175 hegel_collection_t* handle_ =
nullptr;
182 explicit RepeatHandle(
const TestCase& tc);
184 RepeatHandle(
const RepeatHandle&) =
delete;
185 RepeatHandle& operator=(
const RepeatHandle&) =
delete;
187 bool more(
const TestCase& tc);
189 void failed(
const TestCase& tc);
192 hegel_repeat_t* handle_ =
nullptr;
197 explicit PoolHandle(
const TestCase& tc);
199 PoolHandle(
const PoolHandle&) =
delete;
200 PoolHandle& operator=(
const PoolHandle&) =
delete;
203 int64_t add(
const TestCase& tc);
206 int64_t draw_variable(
const TestCase& tc,
bool consume);
208 void restore(
const TestCase& tc, int64_t variable);
209 void restore_unchecked(
const TestCase& tc, int64_t variable)
noexcept;
212 hegel_pool_t* handle_ =
nullptr;
218 class RecursionHandle {
220 RecursionHandle(
const TestCase& tc, uint64_t max_depth,
221 uint64_t max_leaves);
223 RecursionHandle(
const RecursionHandle&) =
delete;
224 RecursionHandle& operator=(
const RecursionHandle&) =
delete;
227 bool branch(
const TestCase& tc, uint64_t depth);
230 void leaf(
const TestCase& tc);
233 void retry(
const TestCase& tc);
236 void finish(
const TestCase& tc);
239 hegel_recursion_t* handle_ =
nullptr;
245 class LeafBudgetExceeded :
public std::exception {};
249 class AttemptMispriced :
public std::exception {};
251 inline constexpr int64_t state_machine_done = INT64_MIN;
255 std::vector<int64_t> groups;
259 struct InvariantSpec {
268 class StateMachineHandle {
270 StateMachineHandle(
const TestCase& tc,
271 const std::vector<RuleSpec>& rules,
272 const std::vector<InvariantSpec>& invariants,
273 int64_t min_concurrency, int64_t max_concurrency,
275 ~StateMachineHandle();
276 StateMachineHandle(
const StateMachineHandle&) =
delete;
277 StateMachineHandle& operator=(
const StateMachineHandle&) =
delete;
283 int64_t next_group(
const TestCase& tc);
286 int64_t next_rule(
const TestCase& tc, int64_t worker_index);
289 void rule_rejected(
const TestCase& tc, int64_t worker_index);
290 bool should_check_invariant(
const TestCase& tc,
291 int64_t invariant_index);
293 int64_t concurrency()
const {
return concurrency_; }
294 int64_t round_concurrency()
const {
return round_concurrency_; }
297 hegel_state_machine_t* handle_ =
nullptr;
298 int64_t concurrency_ = 0;
299 int64_t round_concurrency_ = 0;
302 struct CapturedException {
303 std::exception_ptr exception;
306 [[noreturn]]
void rethrow()
const;
309 CapturedException capture_current_exception();
316 explicit NestedDraw(
const TestCase& tc);
318 NestedDraw(
const NestedDraw&) =
delete;
319 NestedDraw& operator=(
const NestedDraw&) =
delete;
321 bool outermost()
const {
return outermost_; }
330 bool is_explicit(
const TestCase& tc);
332 void check_not_explicit(
const TestCase& tc,
const char* what);
339 const std::any& take_explicit_value(
const TestCase& tc,
340 std::string_view name,
341 const std::type_info& type);
345 bool records_output(
const TestCase& tc);
348 hegel::Printer test_case_printer(
const TestCase& tc);
352 std::string draw_display_name(
const TestCase& tc, std::string_view name);
358 TestCase block(
const TestCase& tc, uint64_t indent);
365 class HegelReject :
public std::exception {
367 const char* what() const noexcept
override {
368 return "test case rejected";
372 class UsageError :
public std::invalid_argument {
374 using std::invalid_argument::invalid_argument;
382 class HegelStopTest :
public std::exception {
384 const char* what() const noexcept
override {
385 return "test case stopped by backend";
392 class HegelLoopDone :
public std::exception {
394 const char* what() const noexcept
override {
395 return "test case ended by repeat";
uint64_t combine_labels(const std::vector< uint64_t > &labels)
The label of a generator built from other generators.
Definition core.h:947