15struct hegel_collection_t;
17struct hegel_state_machine_t;
23namespace hegel::internal {
39 enum class SpanLabel {
51 inline constexpr std::size_t span_label_count =
52 static_cast<std::size_t
>(SpanLabel::StatefulRule) + 1;
57 void start_span(
const TestCase& tc, SpanLabel label);
58 void stop_span(
const TestCase& tc,
bool discard =
false);
60 int64_t draw_integer(
const TestCase& tc, int64_t min_value,
63 uint64_t draw_integer_unsigned(
const TestCase& tc, uint64_t min_value,
65 bool draw_boolean(
const TestCase& tc,
double p,
66 std::optional<bool> forced = std::nullopt);
67 double draw_float(
const TestCase& tc, uint32_t width,
double min_value,
68 double max_value,
bool allow_nan,
bool allow_infinity,
69 bool exclude_min,
bool exclude_max,
70 double smallest_nonzero_magnitude);
72 inline constexpr uint64_t no_max_size = ~uint64_t{0};
73 class CollectionHandle {
75 CollectionHandle(
const TestCase& tc, uint64_t min_size,
78 CollectionHandle(
const CollectionHandle&) =
delete;
79 CollectionHandle& operator=(
const CollectionHandle&) =
delete;
81 bool more(
const TestCase& tc);
83 void reject(
const TestCase& tc,
const char* why);
86 hegel_collection_t* handle_ =
nullptr;
91 explicit PoolHandle(
const TestCase& tc);
93 PoolHandle(
const PoolHandle&) =
delete;
94 PoolHandle& operator=(
const PoolHandle&) =
delete;
97 int64_t add(
const TestCase& tc);
100 int64_t draw_variable(
const TestCase& tc,
bool consume);
103 hegel_pool_t* handle_ =
nullptr;
106 inline constexpr int64_t state_machine_done = INT64_MIN;
107 class StateMachineHandle {
109 StateMachineHandle(
const TestCase& tc,
110 const std::vector<std::string>& rule_names,
111 const std::vector<int64_t>& rule_groups,
112 const std::vector<std::string>& invariant_names,
113 int64_t min_concurrency, int64_t max_concurrency);
114 ~StateMachineHandle();
115 StateMachineHandle(
const StateMachineHandle&) =
delete;
116 StateMachineHandle& operator=(
const StateMachineHandle&) =
delete;
121 int64_t next_group(
const TestCase& tc);
124 int64_t next_rule(
const TestCase& tc, int64_t worker_index);
127 void rule_rejected(
const TestCase& tc, int64_t worker_index);
128 bool should_check_invariant(
const TestCase& tc,
129 int64_t invariant_index);
131 int64_t concurrency()
const {
return concurrency_; }
134 hegel_state_machine_t* handle_ =
nullptr;
135 int64_t concurrency_ = 0;
138 void set_concurrent_worker(TestCase& tc, std::size_t worker_index);
140 struct CapturedException {
141 std::exception_ptr exception;
144 [[noreturn]]
void rethrow()
const;
147 CapturedException capture_current_exception();
149 class NoteIndentScope {
151 explicit NoteIndentScope(
const TestCase& tc);
153 NoteIndentScope(
const NoteIndentScope&) =
delete;
154 NoteIndentScope& operator=(
const NoteIndentScope&) =
delete;
162 DrawLogScope(
const TestCase& tc, std::string_view name,
165 DrawLogScope(
const DrawLogScope&) =
delete;
166 DrawLogScope& operator=(
const DrawLogScope&) =
delete;
168 bool should_log()
const;
170 void log(
const std::string& rendered)
const;
175 std::string display_;
182 class HegelReject :
public std::exception {
184 const char* what() const noexcept
override {
185 return "test case rejected";
194 class HegelStopTest :
public std::exception {
196 const char* what() const noexcept
override {
197 return "test case stopped by backend";