hegeltest 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +182 -0
  3. data/README.ja.md +408 -0
  4. data/README.md +208 -102
  5. data/Rakefile +6 -3
  6. data/docs/README.md +9 -0
  7. data/docs/adr/0027-report-each-runs-test-location-from-the-callers-frame.md +63 -0
  8. data/docs/adr/0028-expose-settings-profiles-as-a-keyword-and-module-functions.md +91 -0
  9. data/docs/adr/0029-keep-notes-local-and-defer-run-error-kinds.md +72 -0
  10. data/docs/adr/0030-represent-a-duration-as-integer-nanoseconds.md +48 -0
  11. data/docs/adr/0031-take-the-alphabet-options-from-hegel-rust.md +52 -0
  12. data/docs/adr/0032-suppress-span-closes-while-an-abandoned-recursion-attempt-unwinds.md +147 -0
  13. data/docs/adr/0033-cache-compiled-grammars-for-the-length-of-a-run.md +80 -0
  14. data/docs/adr/0034-repeat-a-test-body-with-a-ruby-side-indent.md +120 -0
  15. data/docs/adr/0035-defer-concurrent-state-machines-and-the-engine-printer.md +136 -0
  16. data/docs/architecture.md +16 -1
  17. data/lib/hegel/errors.rb +24 -0
  18. data/lib/hegel/generator.rb +52 -25
  19. data/lib/hegel/generators.rb +715 -45
  20. data/lib/hegel/grammar_cache.rb +36 -0
  21. data/lib/hegel/lib_hegel/real.rb +320 -17
  22. data/lib/hegel/lib_hegel.rb +31 -6
  23. data/lib/hegel/libhegel_version.rb +1 -1
  24. data/lib/hegel/report.rb +13 -10
  25. data/lib/hegel/runner.rb +61 -27
  26. data/lib/hegel/settings.rb +92 -16
  27. data/lib/hegel/state_machine.rb +17 -4
  28. data/lib/hegel/stateful/pool.rb +52 -0
  29. data/lib/hegel/stateful.rb +2 -2
  30. data/lib/hegel/syntax/methods.rb +99 -15
  31. data/lib/hegel/test_case.rb +256 -35
  32. data/lib/hegel/test_location.rb +49 -0
  33. data/lib/hegel/version.rb +1 -1
  34. data/lib/hegel.rb +21 -5
  35. data/sig/hegel.rbs +295 -42
  36. data/skills/hegel-ruby/references/ruby/reference.md +463 -41
  37. metadata +13 -1
data/sig/hegel.rbs CHANGED
@@ -12,35 +12,48 @@ module Hegel
12
12
  class AssumeFailed < Exception
13
13
  end
14
14
 
15
- def self.test: (?test_cases: Integer?, ?seed: Integer?, ?derandomize: bool?, ?verbosity: Symbol?, ?database: String?, ?database_key: String?, ?phases: Array[Symbol]?, ?suppress_health_check: Array[Symbol]?, ?report_multiple_failures: bool, ?output: untyped, ?reproduce_failure: String?, ?impl: untyped) { (TestCase) -> void } -> nil
15
+ class LeafBudgetExceeded < Exception
16
+ attr_reader recursion: TestCase::Recursion
17
+ def initialize: (TestCase::Recursion recursion) -> void
18
+ end
19
+
20
+ class LoopDone < Exception
21
+ end
22
+
23
+ def self.test: (?profile: String?, ?test_cases: Integer?, ?seed: Integer?, ?derandomize: bool?, ?verbosity: Symbol?, ?database: String?, ?database_key: String?, ?phases: Array[Symbol]?, ?suppress_health_check: Array[Symbol]?, ?report_multiple_failures: bool, ?stop_on_first_failure: bool?, ?print_blob: bool?, ?show_statistics: bool?, ?nondeterminism_strictness: Symbol?, ?backend: Symbol?, ?output: untyped, ?reproduce_failure: String?, ?impl: untyped) { (TestCase) -> void } -> nil
16
24
  def self.default_impl: () -> untyped
17
25
 
18
26
  class TestCase
19
27
  DEFAULT_DRAW_NAME: String
20
28
  DRAW_METHOD_NAMES: Array[Symbol]
21
29
  DRAW_CALLER_DEPTH: Integer
30
+ REPEAT_MAX_MIN_SIZE: Integer
31
+ REPEAT_INDENT: Integer
22
32
 
23
- def initialize: (untyped impl, untyped ctx, untyped handle, ?record: bool) -> void
24
- def entries: () -> Array[[:draw, String, untyped] | [:note, untyped]]?
33
+ def initialize: (untyped impl, untyped ctx, untyped handle, ?record: bool, ?grammars: GrammarCache?) -> void
34
+ def entries: () -> Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]?
25
35
  def draw_integer: (Integer min_value, Integer max_value, ?label: String?) -> Integer
26
36
  def draw_boolean: (?Float p, ?label: String?) -> bool
27
37
  def draw: (Generator generator, ?label: String?) -> untyped
28
38
  def assume: (boolish condition) -> void
29
39
  def reject: () -> bot
30
40
  def note: (?untyped? message) ?{ () -> untyped } -> void
41
+ def repeat: () { () -> void } -> untyped
31
42
  def generate_integer: (Integer min_value, Integer max_value) -> Integer
32
43
  def generate_integer_big: (Integer min_value, Integer max_value) -> Integer
33
44
  def generate_boolean: (?Float p) -> bool
34
45
  def generate_float: (Integer width, Float min_value, Float max_value, allow_nan: bool, allow_infinity: bool, exclude_min: bool, exclude_max: bool, smallest_nonzero_magnitude: Float) -> Float
35
46
  def target: (Numeric value, ?label: String) -> nil
47
+ def event: (String label) -> nil
48
+ def event_value: (String label, Numeric value) -> nil
36
49
  def start_span: (Integer label) -> untyped
37
50
  def stop_span: (?discard: bool) -> untyped
38
51
  def new_collection: (Integer min_size, Integer max_size) -> untyped
39
52
  def collection_more: (untyped collection) -> bool
40
53
  def collection_reject: (untyped collection, ?why: String?) -> untyped
41
54
  def collection_free: (untyped collection) -> untyped
42
- def with_text_generator: [R] (min_size: Integer, max_size: Integer, ?codec: String?, ?min_codepoint: Integer, ?max_codepoint: Integer) { (untyped) -> R } -> R
43
- def with_regex_generator: [R] (String pattern, fullmatch: bool) { (untyped) -> R } -> R
55
+ def with_text_generator: [R] (min_size: Integer, max_size: Integer, ?codec: String?, ?min_codepoint: Integer, ?max_codepoint: Integer, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String, ?exclude_characters: String) { (untyped) -> R } -> R
56
+ def with_regex_generator: [R] (String pattern, fullmatch: bool, ?alphabet: untyped) { (untyped) -> R } -> R
44
57
  def with_email_generator: [R] () { (untyped) -> R } -> R
45
58
  def with_url_generator: [R] () { (untyped) -> R } -> R
46
59
  def with_domain_generator: [R] (max_length: Integer) { (untyped) -> R } -> R
@@ -60,20 +73,59 @@ module Hegel
60
73
  def new_pool: () -> untyped
61
74
  def pool_add: (untyped pool) -> Integer
62
75
  def pool_generate: (untyped pool, bool consume) -> Integer
76
+ def pool_restore: (untyped pool, Integer variable_id) -> nil
63
77
  def pool_free: (untyped pool) -> nil
64
78
  def free_pools: () -> void
65
- def new_state_machine: (Array[String] rule_names, Array[String] invariant_names, Array[bool] always_check, Integer step_count) -> untyped
79
+ def new_state_machine: (Array[String] rule_names, Array[Float] rule_weights, Array[String] invariant_names, Array[bool] always_check, Integer step_count) -> untyped
66
80
  def state_machine_next_group: (untyped state_machine) -> Integer
67
81
  def state_machine_next_rule: (untyped state_machine) -> Integer
68
82
  def state_machine_rule_rejected: (untyped state_machine) -> nil
69
83
  def state_machine_should_check_invariant: (untyped state_machine, Integer index) -> bool
70
84
  def state_machine_free: (untyped state_machine) -> nil
85
+ def with_grammar: [R] (untyped key, ^() -> GrammarCache::Compiled build) { (GrammarCache::Compiled) -> R } -> R
86
+ def grammar_builder_new: (String text) -> untyped
87
+ def grammar_builder_file: (untyped builder, Integer index) -> String?
88
+ def grammar_builder_provide: (untyped builder, Integer index, String? text) -> nil
89
+ def grammar_builder_free: (untyped builder) -> nil
90
+ def grammar_new: (untyped builder, String? start, Integer max_size, Integer max_depth, untyped alphabet, Array[String] names) -> untyped
91
+ def grammar_placeholder: (untyped grammar, String name) -> String
92
+ def grammar_free: (untyped grammar) -> nil
93
+ def generate_grammar: (untyped grammar, Integer max_size) -> String
94
+ def new_recursion: (Integer max_depth, Integer max_leaves) -> Recursion
95
+ def recursion_branch: (Recursion recursion, Integer depth) -> bool
96
+ def recursion_leaf: (Recursion recursion) -> nil
97
+ def abandoned_by?: (Recursion recursion) -> bool
98
+ def recursion_retry: (Recursion recursion) -> nil
99
+ def recursion_finish: (Recursion recursion) -> bool
100
+ def recursion_free: (Recursion recursion) -> nil
101
+
102
+ class Recursion < Struct[untyped]
103
+ attr_accessor handle: untyped
104
+ attr_accessor freed: bool
105
+ def initialize: (untyped handle, bool freed) -> void
106
+ end
107
+ end
108
+
109
+ class GrammarCache
110
+ class Compiled
111
+ attr_reader grammar: untyped
112
+ attr_reader markers: Array[String]
113
+
114
+ def initialize: (grammar: untyped, markers: Array[String]) -> void
115
+ end
116
+
117
+ def initialize: () -> void
118
+ def fetch: (untyped key) { () -> Compiled } -> Compiled
119
+ def free_all: (untyped impl, untyped ctx) -> void
71
120
  end
72
121
 
73
122
  class Generator
123
+ FILTER_ATTEMPT_LABEL: Integer
124
+
74
125
  def self.label: () -> Integer
75
126
  def self.label_of: (untyped part) -> Integer
76
127
  def do_draw: (untyped tc) -> untyped
128
+ def do_draw_filtered: (untyped tc, Proc predicate) -> untyped
77
129
  def label: () -> Integer
78
130
  def map: () { (untyped) -> untyped } -> Generator
79
131
  def filter: () { (untyped) -> boolish } -> Generator
@@ -88,12 +140,18 @@ module Hegel
88
140
 
89
141
  def initialize: (Generator source, Proc block) -> void
90
142
  def do_draw: (untyped tc) -> untyped
143
+ def do_draw_filtered: (untyped tc, Proc predicate) -> untyped
91
144
  end
92
145
  end
93
146
 
94
147
  module Generators
148
+ DEFAULT_MAX_SIZE: Integer
149
+
150
+ def self.default_max_size: (Integer min_size) -> Integer
95
151
  def self.first_nanosecond: (Array[Integer] parts) -> Array[Integer]
96
152
  def self.last_nanosecond: (Array[Integer] parts) -> Array[Integer]
153
+ def self.format_date: (Array[Integer] date) -> String
154
+ def self.format_time: (Array[Integer] time) -> String
97
155
 
98
156
  class BooleanGenerator < Generator
99
157
  def initialize: (p: Float) -> void
@@ -111,17 +169,42 @@ module Hegel
111
169
  class FloatGenerator < Generator
112
170
  WIDTH: Integer
113
171
 
114
- def initialize: (min_value: Float?, max_value: Float?, allow_nan: bool?, allow_infinity: bool?, exclude_min: bool, exclude_max: bool) -> void
172
+ def initialize: (min_value: Float?, max_value: Float?, allow_nan: bool?, allow_infinity: bool?, exclude_min: bool, exclude_max: bool, allow_subnormal: bool?) -> void
115
173
  def do_draw: (untyped tc) -> Float
174
+
175
+ private
176
+
177
+ def smallest_nonzero_magnitude: () -> Float
178
+ def only_subnormals_between_bounds?: () -> bool
179
+ def subnormal_default: () -> bool
180
+ end
181
+
182
+ CODECS: Array[String]
183
+ SURROGATE_CATEGORIES: Array[String]
184
+
185
+ class CharactersGenerator < Generator
186
+ def initialize: (?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String?, ?exclude_characters: String?) -> void
187
+ def do_draw: (untyped tc) -> String
188
+ def options: () -> Hash[Symbol, untyped]
189
+ def options_given?: () -> bool
190
+ def with_alphabet: [R] (untyped tc, String name, Integer min_size, Integer max_size) { (untyped) -> R } -> R
191
+
192
+ private
193
+
194
+ def engine_options: (String name) -> Hash[Symbol, untyped]
116
195
  end
117
196
 
118
197
  class TextGenerator < Generator
119
- def initialize: (min_size: Integer, max_size: Integer?, codec: String?, min_codepoint: Integer?, max_codepoint: Integer?) -> void
198
+ def initialize: (min_size: Integer, max_size: Integer?, ?alphabet: String?, ?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String?, ?exclude_characters: String?) -> void
120
199
  def do_draw: (untyped tc) -> String
200
+
201
+ private
202
+
203
+ def alphabet_generator: () -> CharactersGenerator
121
204
  end
122
205
 
123
206
  class ArrayGenerator < Generator
124
- def initialize: (Generator elements, min_size: Integer, max_size: Integer?) -> void
207
+ def initialize: (Generator elements, min_size: Integer, max_size: Integer?, ?unique: bool) -> void
125
208
  def do_draw: (untyped tc) -> Array[untyped]
126
209
 
127
210
  private
@@ -135,6 +218,40 @@ module Hegel
135
218
  def do_draw: (untyped tc) -> untyped
136
219
  end
137
220
 
221
+ module SequenceDrawing
222
+ private
223
+
224
+ def check_sizes: (String name, Integer min_size, Integer? max_size) -> void
225
+ def with_span: (untyped tc) { () -> untyped } -> untyped
226
+ def draw_index_sample: (untyped tc, Integer size, Integer min_size, Integer? max_size) -> Array[Integer]
227
+ end
228
+
229
+ class PermutationsGenerator < Generator
230
+ include SequenceDrawing
231
+
232
+ def initialize: (untyped elements) -> void
233
+ def do_draw: (untyped tc) -> Array[untyped]
234
+ end
235
+
236
+ class SubsequencesGenerator < Generator
237
+ include SequenceDrawing
238
+
239
+ def initialize: (untyped elements, min_size: Integer, max_size: Integer?) -> void
240
+ def do_draw: (untyped tc) -> Array[untyped]
241
+ end
242
+
243
+ class SamplesGenerator < Generator
244
+ include SequenceDrawing
245
+
246
+ def initialize: (untyped elements, min_size: Integer, max_size: Integer?, replacement: bool) -> void
247
+ def do_draw: (untyped tc) -> Array[untyped]
248
+
249
+ private
250
+
251
+ def validate_for: (Integer size) -> void
252
+ def draw_with_replacement: (untyped tc, Array[untyped] elements) -> Array[untyped]
253
+ end
254
+
138
255
  class SampledFromGenerator < Generator
139
256
  def initialize: (untyped collection) -> void
140
257
  def do_draw: (untyped tc) -> untyped
@@ -176,19 +293,44 @@ module Hegel
176
293
  def draw_entry: (untyped tc) -> [untyped, untyped]
177
294
  end
178
295
 
179
- class CharactersGenerator < Generator
180
- def initialize: (codec: String?, min_codepoint: Integer?, max_codepoint: Integer?) -> void
181
- def do_draw: (untyped tc) -> String
182
- end
183
-
184
296
  class BinaryGenerator < Generator
185
297
  def initialize: (min_size: Integer, max_size: Integer?) -> void
186
298
  def do_draw: (untyped tc) -> String
187
299
  end
188
300
 
189
301
  class FromRegexGenerator < Generator
190
- def initialize: (untyped pattern, fullmatch: bool) -> void
302
+ def initialize: (untyped pattern, fullmatch: bool, ?alphabet: CharactersGenerator?) -> void
191
303
  def do_draw: (untyped tc) -> String
304
+
305
+ private
306
+
307
+ def draw_regex: (untyped tc, untyped alphabet) -> String
308
+ end
309
+
310
+ class FromLarkGenerator < Generator
311
+ DEFAULT_MAX_SIZE: Integer
312
+ ATTEMPTS: Integer
313
+ ATTEMPT_LABEL: Integer
314
+ MAX_SIZE_LIMIT: Integer
315
+ MAX_DEPTH_LIMIT: Integer
316
+
317
+ def initialize: (untyped grammar, start: untyped, explicit: untyped, alphabet: untyped, max_size: Integer?, max_depth: Integer?, import_path: untyped) -> void
318
+ def do_draw: (untyped tc) -> String
319
+
320
+ private
321
+
322
+ def frozen: [T] (T value) -> T
323
+ def lark_label: (Array[untyped]? names) -> Integer
324
+ def text_label: (untyped value) -> Integer
325
+ def explicit_terminals: () -> Array[[String, Generator]]
326
+ def explicit_terminal: (untyped name, untyped generator) -> [String, Generator]
327
+ def compile: (untyped tc, Array[String] names) -> GrammarCache::Compiled
328
+ def compile_with: (untyped tc, Array[String] names, untyped alphabet) -> GrammarCache::Compiled
329
+ def provide_files: (untyped tc, untyped builder) -> void
330
+ def read_import: (String file) -> String?
331
+ def draw_with_values: (untyped tc, GrammarCache::Compiled compiled, Array[[String, Generator]] terminals) -> String
332
+ def splice: (untyped tc, GrammarCache::Compiled compiled, Regexp pattern, Array[[String, Generator]] terminals, Integer budget) -> [String, Integer, Integer, Integer]
333
+ def draw_value: (untyped tc, String name, Generator generator) -> String
192
334
  end
193
335
 
194
336
  class EmailsGenerator < Generator
@@ -247,6 +389,25 @@ module Hegel
247
389
  def do_draw: (untyped tc) -> Time
248
390
  end
249
391
 
392
+ class DateStringsGenerator < Generator
393
+ def do_draw: (untyped tc) -> String
394
+ end
395
+
396
+ class TimeStringsGenerator < Generator
397
+ def do_draw: (untyped tc) -> String
398
+ end
399
+
400
+ class DatetimeStringsGenerator < Generator
401
+ def do_draw: (untyped tc) -> String
402
+ end
403
+
404
+ class DurationsGenerator < Generator
405
+ MAX_NANOSECONDS: Integer
406
+
407
+ def initialize: (min_value: Integer, max_value: Integer) -> void
408
+ def do_draw: (untyped tc) -> Integer
409
+ end
410
+
250
411
  class CompositeGenerator < Generator
251
412
  def initialize: () { (CompositeGenerator::BlockTestCase) -> untyped } -> void
252
413
  def do_draw: (untyped tc) -> untyped
@@ -265,17 +426,41 @@ module Hegel
265
426
  def do_draw: (untyped tc) -> untyped
266
427
  end
267
428
 
429
+ class RecursiveGenerator < Generator
430
+ UINT64_MAX: Integer
431
+
432
+ def initialize: (untyped leaf, max_depth: untyped, max_leaves: untyped) ?{ (SubtreeGenerator) -> untyped } -> void
433
+ def do_draw: (untyped tc) -> untyped
434
+
435
+ private
436
+
437
+ def validate_bound: (String name, untyped value) -> void
438
+ def draw_recursion: (untyped tc) -> untyped
439
+ end
440
+
441
+ class SubtreeGenerator < Generator
442
+ def initialize: (Generator leaf, ^(SubtreeGenerator) -> untyped branch, TestCase::Recursion recursion, Integer depth, Integer label) -> void
443
+ def do_draw: (untyped tc) -> untyped
444
+ def draw_subtree: (untyped tc) -> untyped
445
+ end
446
+
268
447
  extend Syntax::Methods
269
448
  end
270
449
 
271
450
  class StateMachine
272
451
  include Syntax::Methods
273
452
 
274
- def self.rule: (Symbol | String name) { (TestCase) -> untyped } -> void
453
+ def self.rule: (Symbol | String name, ?weight: Numeric) { (TestCase) -> untyped } -> void
275
454
  def self.invariant: (Symbol | String name, ?always_run: bool) { (TestCase) -> untyped } -> void
276
- def self.rule_definitions: () -> Hash[String, Proc]
455
+ def self.rule_definitions: () -> Hash[String, Rule]
277
456
  def self.invariant_definitions: () -> Hash[String, Invariant]
278
457
 
458
+ class Rule
459
+ attr_reader block: Proc
460
+ attr_reader weight: Numeric
461
+ def initialize: (block: Proc, weight: Numeric) -> void
462
+ end
463
+
279
464
  class Invariant
280
465
  attr_reader block: Proc
281
466
  attr_reader always_run: bool
@@ -288,7 +473,7 @@ module Hegel
288
473
  DEFAULT_STEP_COUNT: Integer
289
474
 
290
475
  def self.run: (StateMachine machine, TestCase tc, ?step_count: Integer) -> void
291
- def self.drive: (StateMachine machine, Hash[String, Proc] rules, Array[StateMachine::Invariant] invariants, untyped state_machine, TestCase tc) -> void
476
+ def self.drive: (StateMachine machine, Hash[String, StateMachine::Rule] rules, Array[StateMachine::Invariant] invariants, untyped state_machine, TestCase tc) -> void
292
477
  def self.apply_rule: (StateMachine machine, Proc block, untyped state_machine, TestCase tc) -> bool
293
478
  def self.run_invariants: (StateMachine machine, Array[StateMachine::Invariant] invariants, TestCase tc) -> void
294
479
  def self.run_sampled_invariants: (StateMachine machine, Array[StateMachine::Invariant] invariants, untyped state_machine, TestCase tc) -> void
@@ -309,6 +494,11 @@ module Hegel
309
494
  class ValuesConsumed < Generator
310
495
  def initialize: (untyped pool, Hash[Integer, untyped] values) -> void
311
496
  def do_draw: (untyped tc) -> untyped
497
+ def do_draw_filtered: (untyped tc, Proc predicate) -> untyped
498
+
499
+ private
500
+
501
+ def filtered_attempt: (untyped tc, Proc predicate, Array[Integer] attempted) -> Integer?
312
502
  end
313
503
  end
314
504
  end
@@ -317,19 +507,23 @@ module Hegel
317
507
  module Methods
318
508
  def booleans: (?p: Float) -> Generators::BooleanGenerator
319
509
  def integers: (?min_value: Integer?, ?max_value: Integer?) -> Generators::IntegerGenerator
320
- def floats: (?min_value: Float?, ?max_value: Float?, ?allow_nan: bool?, ?allow_infinity: bool?, ?exclude_min: bool, ?exclude_max: bool) -> Generators::FloatGenerator
321
- def text: (?min_size: Integer, ?max_size: Integer?, ?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?) -> Generators::TextGenerator
322
- def arrays: (Generator elements, ?min_size: Integer, ?max_size: Integer?) -> Generators::ArrayGenerator
510
+ def floats: (?min_value: Float?, ?max_value: Float?, ?allow_nan: bool?, ?allow_infinity: bool?, ?exclude_min: bool, ?exclude_max: bool, ?allow_subnormal: bool?) -> Generators::FloatGenerator
511
+ def text: (?min_size: Integer, ?max_size: Integer?, ?alphabet: String?, ?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String?, ?exclude_characters: String?) -> Generators::TextGenerator
512
+ def arrays: (Generator elements, ?min_size: Integer, ?max_size: Integer?, ?unique: bool) -> Generators::ArrayGenerator
323
513
  def just: (untyped value) -> Generators::JustGenerator
324
514
  def sampled_from: (untyped collection) -> Generators::SampledFromGenerator
515
+ def permutations: (untyped elements) -> Generators::PermutationsGenerator
516
+ def subsequences: (untyped elements, ?min_size: Integer, ?max_size: Integer?) -> Generators::SubsequencesGenerator
517
+ def samples: (untyped elements, ?min_size: Integer, ?max_size: Integer?, ?replacement: bool) -> Generators::SamplesGenerator
325
518
  def one_of: (*Generator generators) -> Generators::OneOfGenerator
326
519
  def optional: (Generator generator) -> Generators::OptionalGenerator
327
520
  def tuples: (*Generator generators) -> Generators::TupleGenerator
328
521
  def sets: (Generator elements, ?min_size: Integer, ?max_size: Integer?) -> Generators::SetGenerator
329
522
  def hashes: (Generator keys, Generator values, ?min_size: Integer, ?max_size: Integer?) -> Generators::HashGenerator
330
- def characters: (?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?) -> Generators::CharactersGenerator
523
+ def characters: (?codec: String?, ?min_codepoint: Integer?, ?max_codepoint: Integer?, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String?, ?exclude_characters: String?) -> Generators::CharactersGenerator
331
524
  def binary: (?min_size: Integer, ?max_size: Integer?) -> Generators::BinaryGenerator
332
- def from_regex: (untyped pattern, ?fullmatch: bool) -> Generators::FromRegexGenerator
525
+ def from_regex: (untyped pattern, ?fullmatch: bool, ?alphabet: Generators::CharactersGenerator?) -> Generators::FromRegexGenerator
526
+ def from_lark: (untyped grammar, ?start: String?, ?explicit: Hash[String | Symbol, Generator], ?alphabet: Generators::CharactersGenerator?, ?max_size: Integer?, ?max_depth: Integer?, ?import_path: untyped) -> Generators::FromLarkGenerator
333
527
  def emails: () -> Generators::EmailsGenerator
334
528
  def urls: () -> Generators::UrlsGenerator
335
529
  def domains: (?max_length: Integer) -> Generators::DomainsGenerator
@@ -338,8 +532,13 @@ module Hegel
338
532
  def dates: (?min_value: untyped, ?max_value: untyped) -> Generators::DatesGenerator
339
533
  def times: (?min_value: String?, ?max_value: String?) -> Generators::TimesGenerator
340
534
  def datetimes: (?min_value: Time?, ?max_value: Time?) -> Generators::DatetimesGenerator
535
+ def date_strings: () -> Generators::DateStringsGenerator
536
+ def time_strings: () -> Generators::TimeStringsGenerator
537
+ def datetime_strings: () -> Generators::DatetimeStringsGenerator
538
+ def durations: (?min_value: Integer, ?max_value: Integer) -> Generators::DurationsGenerator
341
539
  def composite: () { (Generators::CompositeGenerator::BlockTestCase) -> untyped } -> Generators::CompositeGenerator
342
540
  def deferred: () -> Generators::DeferredGenerator
541
+ def recursive: (Generator leaf, ?max_depth: Integer, ?max_leaves: Integer) { (Generators::SubtreeGenerator) -> Generator } -> Generators::RecursiveGenerator
343
542
  end
344
543
  end
345
544
 
@@ -357,30 +556,50 @@ module Hegel
357
556
 
358
557
  module Report
359
558
  class Failure
360
- def initialize: (test_cases: Integer, discarded: Integer, entries: Array[[:draw, String, untyped] | [:note, untyped]], blob: String?, caveat: String?) -> void
559
+ def initialize: (test_cases: Integer, discarded: Integer, entries: Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]], blob: String?, caveat: String?) -> void
361
560
  def test_cases: () -> Integer
362
561
  def discarded: () -> Integer
363
- def entries: () -> Array[[:draw, String, untyped] | [:note, untyped]]
562
+ def entries: () -> Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]
364
563
  def blob: () -> String?
365
564
  def caveat: () -> String?
366
565
  end
367
566
 
368
- def self.assign_names: (Array[[:draw, String, untyped] | [:note, untyped]] entries) -> Array[[:draw, String, untyped] | [:note, untyped]]
567
+ def self.assign_names: (Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]] entries) -> Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]
369
568
  def self.render_failure: (Failure failure) -> String
370
569
  def self.render: (Array[Failure] failures) -> String
371
570
  end
372
571
 
373
572
  module Settings
374
573
  VERBOSITY_CODES: Hash[Symbol, Integer]
574
+ NONDETERMINISM_STRICTNESS_CODES: Hash[Symbol, Integer]
575
+ BACKEND_CODES: Hash[Symbol, Integer]
375
576
  PHASE_CODES: Hash[Symbol, Integer]
376
577
  HEALTH_CHECK_CODES: Hash[Symbol, Integer]
377
578
 
378
- def self.apply: (untyped impl, untyped ctx, untyped settings, test_cases: Integer?, seed: Integer?, derandomize: bool?, verbosity: Symbol?, database: String?, database_key: String?, phases: Array[Symbol]?, suppress_health_check: Array[Symbol]?, report_multiple_failures: bool) -> void
579
+ def self.apply: (untyped impl, untyped ctx, untyped settings, database: String?, database_key: String?, report_multiple_failures: bool, test_cases: Integer?, seed: Integer?, derandomize: bool?, verbosity: Symbol?, phases: Array[Symbol]?, suppress_health_check: Array[Symbol]?, stop_on_first_failure: bool?, print_blob: bool?, show_statistics: bool?, nondeterminism_strictness: Symbol?, backend: Symbol?) -> void
580
+ def self.apply_shared: (untyped impl, untyped ctx, untyped settings, test_cases: Integer?, seed: Integer?, derandomize: bool?, verbosity: Symbol?, phases: Array[Symbol]?, suppress_health_check: Array[Symbol]?, stop_on_first_failure: bool?, print_blob: bool?, show_statistics: bool?, nondeterminism_strictness: Symbol?, backend: Symbol?) -> void
581
+ def self.new_handle: (untyped impl, untyped ctx, String? profile) -> untyped
582
+ def self.register_profile: (String name, ?profile: String?, ?test_cases: Integer?, ?seed: Integer?, ?derandomize: bool?, ?verbosity: Symbol?, ?database: String?, ?phases: Array[Symbol]?, ?suppress_health_check: Array[Symbol]?, ?report_multiple_failures: bool?, ?stop_on_first_failure: bool?, ?print_blob: bool?, ?show_statistics: bool?, ?nondeterminism_strictness: Symbol?, ?backend: Symbol?, ?impl: untyped) -> nil
583
+ def self.set_default_profile: (String name, ?impl: untyped) -> nil
379
584
  def self.apply_verbosity: (untyped impl, untyped ctx, untyped settings, Symbol verbosity) -> void
380
585
  def self.apply_database: (untyped impl, untyped ctx, untyped settings, database: String?, database_key: String?) -> void
381
586
  def self.apply_phases: (untyped impl, untyped ctx, untyped settings, Array[Symbol] phases) -> void
382
587
  def self.apply_suppress_health_check: (untyped impl, untyped ctx, untyped settings, Array[Symbol] checks) -> void
383
- def self.mask_for: (Array[Symbol] values, Hash[Symbol, Integer] codes) -> Integer
588
+ def self.mask_for: (Array[Symbol] values, Hash[Symbol, Integer] codes, String keyword) -> Integer
589
+ def self.lookup: (Hash[Symbol, Integer] codes, Symbol value, String keyword) -> Integer
590
+ end
591
+
592
+ class TestLocation
593
+ BLOCK_PREFIX: Regexp
594
+ METHOD_LABEL: Regexp
595
+
596
+ attr_reader file: String
597
+ attr_reader begin_line: Integer
598
+ attr_reader class_name: String
599
+ attr_reader function: String
600
+ def self.new: (file: String, begin_line: Integer, class_name: String, function: String) -> TestLocation
601
+ def self.from_locations: (Array[untyped] locations) -> TestLocation
602
+ def self.names: (String label, String file, Integer lineno) -> [String, String]
384
603
  end
385
604
 
386
605
  module Runner
@@ -393,8 +612,8 @@ module Hegel
393
612
 
394
613
  class Capture
395
614
  attr_reader exception: Exception
396
- attr_reader entries: Array[[:draw, String, untyped] | [:note, untyped]]?
397
- def initialize: (Exception exception, Array[[:draw, String, untyped] | [:note, untyped]]? entries) -> void
615
+ attr_reader entries: Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]?
616
+ def initialize: (Exception exception, Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]? entries) -> void
398
617
  end
399
618
 
400
619
  class GenerationStats
@@ -403,16 +622,16 @@ module Hegel
403
622
  def for: (String? origin) -> [Integer, Integer]
404
623
  end
405
624
 
406
- def self.run: (impl: untyped, ?test_cases: Integer?, ?seed: Integer?, ?derandomize: bool?, ?verbosity: Symbol?, ?database: String?, ?database_key: String?, ?phases: Array[Symbol]?, ?suppress_health_check: Array[Symbol]?, ?report_multiple_failures: bool, ?output: untyped, ?reproduce_failure: String?) { (TestCase) -> void } -> nil
407
- def self.run_and_finish: (untyped impl, untyped ctx, untyped run, reproducing: bool, quiet: bool, output: untyped) { (TestCase) -> void } -> nil
408
- def self.drive: (untyped impl, untyped ctx, untyped run, GenerationStats stats, Hash[String, Capture] captures) { (TestCase) -> void } -> void
409
- def self.with_test_case: [R] (untyped impl, untyped ctx, untyped tc) { (TestCase) -> R } -> R
410
- def self.run_case: (untyped impl, untyped ctx, untyped tc, GenerationStats stats, Hash[String, Capture] captures) { (TestCase) -> void } -> void
411
- def self.keep_capture: (Hash[String, Capture] captures, String origin, Exception exception, Array[[:draw, String, untyped] | [:note, untyped]]? entries) -> void
412
- def self.finish: (untyped impl, untyped ctx, untyped result, GenerationStats stats, Hash[String, Capture] captures, reproducing: bool, quiet: bool, output: untyped) -> nil
413
- def self.report_failures: (untyped impl, untyped ctx, untyped result, GenerationStats stats, Hash[String, Capture] captures, quiet: bool, output: untyped) -> bot
414
- def self.failure_report: (untyped impl, untyped ctx, untyped failure, GenerationStats stats, Hash[String, Capture] captures) -> [Exception, Report::Failure]
415
- def self.classify: (TestCase test_case) { (TestCase) -> void } -> [Integer, String?, Exception?, Array[[:draw, String, untyped] | [:note, untyped]]?]
625
+ def self.run: (impl: untyped, test_location: TestLocation, ?profile: String?, ?test_cases: Integer?, ?seed: Integer?, ?derandomize: bool?, ?verbosity: Symbol?, ?database: String?, ?database_key: String?, ?phases: Array[Symbol]?, ?suppress_health_check: Array[Symbol]?, ?report_multiple_failures: bool, ?stop_on_first_failure: bool?, ?print_blob: bool?, ?show_statistics: bool?, ?nondeterminism_strictness: Symbol?, ?backend: Symbol?, ?output: untyped, ?reproduce_failure: String?) { (TestCase) -> void } -> nil
626
+ def self.run_and_finish: (untyped impl, untyped ctx, untyped run, GrammarCache grammars, reproducing: bool, quiet: bool, print_blob: bool, output: untyped) { (TestCase) -> void } -> nil
627
+ def self.drive: (untyped impl, untyped ctx, untyped run, GrammarCache grammars, GenerationStats stats, Hash[String, Capture] captures) { (TestCase) -> void } -> void
628
+ def self.with_test_case: [R] (untyped impl, untyped ctx, untyped tc, GrammarCache grammars) { (TestCase) -> R } -> R
629
+ def self.run_case: (untyped impl, untyped ctx, untyped tc, GrammarCache grammars, GenerationStats stats, Hash[String, Capture] captures) { (TestCase) -> void } -> void
630
+ def self.keep_capture: (Hash[String, Capture] captures, String origin, Exception exception, Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]? entries) -> void
631
+ def self.finish: (untyped impl, untyped ctx, untyped result, GenerationStats stats, Hash[String, Capture] captures, reproducing: bool, quiet: bool, print_blob: bool, output: untyped) -> nil
632
+ def self.report_failures: (untyped impl, untyped ctx, untyped result, GenerationStats stats, Hash[String, Capture] captures, quiet: bool, print_blob: bool, output: untyped) -> bot
633
+ def self.failure_report: (untyped impl, untyped ctx, untyped failure, GenerationStats stats, Hash[String, Capture] captures, print_blob: bool) -> [Exception, Report::Failure]
634
+ def self.classify: (TestCase test_case) { (TestCase) -> void } -> [Integer, String?, Exception?, Array[[:draw, String, untyped, Integer] | [:note, untyped, Integer]]?]
416
635
  def self.origin_for: (Exception exception) -> String
417
636
  def self.infrastructure?: (String path) -> bool
418
637
  def self.not_reproduced_message: () -> String
@@ -451,6 +670,8 @@ module Hegel
451
670
  HEGEL_E_NOT_COMPLETE: Integer
452
671
  HEGEL_E_INTERNAL: Integer
453
672
  HEGEL_E_CONCURRENT_USE: Integer
673
+ HEGEL_E_RETRY: Integer
674
+ HEGEL_E_NOT_FOUND: Integer
454
675
  CODE_NAMES: Hash[Integer, String]
455
676
  HEGEL_STATUS_VALID: Integer
456
677
  HEGEL_STATUS_INVALID: Integer
@@ -463,6 +684,11 @@ module Hegel
463
684
  HEGEL_VERBOSITY_QUIET: Integer
464
685
  HEGEL_VERBOSITY_VERBOSE: Integer
465
686
  HEGEL_VERBOSITY_DEBUG: Integer
687
+ HEGEL_NONDETERMINISM_QUIET: Integer
688
+ HEGEL_NONDETERMINISM_WARN: Integer
689
+ HEGEL_NONDETERMINISM_ERROR: Integer
690
+ HEGEL_BACKEND_DEFAULT: Integer
691
+ HEGEL_BACKEND_URANDOM: Integer
466
692
  HEGEL_PHASE_EXPLICIT: Integer
467
693
  HEGEL_PHASE_REUSE: Integer
468
694
  HEGEL_PHASE_GENERATE: Integer
@@ -493,6 +719,9 @@ module Hegel
493
719
  def context_last_error: (untyped ctx) -> String
494
720
  def version: (untyped ctx) -> String
495
721
  def settings_new: (untyped ctx) -> untyped
722
+ def settings_new_for_profile: (untyped ctx, String name) -> untyped
723
+ def settings_register_profile: (untyped ctx, String name, untyped s) -> nil
724
+ def set_default_profile: (untyped ctx, String name) -> nil
496
725
  def settings_free: (untyped ctx, untyped s) -> nil
497
726
  def settings_set_test_cases: (untyped ctx, untyped s, Integer n) -> nil
498
727
  def settings_set_verbosity: (untyped ctx, untyped s, Integer v) -> nil
@@ -501,8 +730,15 @@ module Hegel
501
730
  def settings_set_database: (untyped ctx, untyped s, String? database) -> nil
502
731
  def settings_set_report_multiple_failures: (untyped ctx, untyped s, bool yes) -> nil
503
732
  def settings_set_database_key: (untyped ctx, untyped s, String? key) -> nil
733
+ def settings_set_test_location: (untyped ctx, untyped s, String file, Integer begin_line, String class_name, String function) -> nil
504
734
  def settings_set_phases: (untyped ctx, untyped s, Integer phases) -> nil
505
735
  def settings_set_suppress_health_check: (untyped ctx, untyped s, Integer checks) -> nil
736
+ def settings_set_stop_on_first_failure: (untyped ctx, untyped s, bool yes) -> nil
737
+ def settings_set_print_blob: (untyped ctx, untyped s, bool yes) -> nil
738
+ def settings_get_print_blob: (untyped ctx, untyped s) -> bool
739
+ def settings_set_show_statistics: (untyped ctx, untyped s, bool yes) -> nil
740
+ def settings_set_nondeterminism_strictness: (untyped ctx, untyped s, Integer strictness) -> nil
741
+ def settings_set_backend: (untyped ctx, untyped s, Integer backend) -> nil
506
742
  def run_start: (untyped ctx, untyped settings) -> untyped
507
743
  def run_start_blob: (untyped ctx, untyped settings, String blob) -> untyped
508
744
  def test_case_should_capture: (untyped ctx, untyped tc) -> bool
@@ -511,6 +747,8 @@ module Hegel
511
747
  def test_case_free: (untyped ctx, untyped tc) -> nil
512
748
  def mark_complete: (untyped ctx, untyped tc, Integer status, String? origin) -> nil
513
749
  def target: (untyped ctx, untyped tc, Float value, String label) -> nil
750
+ def event: (untyped ctx, untyped tc, String label) -> nil
751
+ def event_value: (untyped ctx, untyped tc, String label, Numeric value) -> nil
514
752
  def generate_boolean: (untyped ctx, untyped tc, Float p, bool forced, bool has_forced) -> bool
515
753
  def generate_integer: (untyped ctx, untyped tc, Integer min_value, Integer max_value) -> Integer
516
754
  def generate_integer_big: (untyped ctx, untyped tc, Integer min_value, Integer max_value) -> Integer
@@ -533,15 +771,22 @@ module Hegel
533
771
  def new_pool: (untyped ctx, untyped tc) -> untyped
534
772
  def pool_add: (untyped ctx, untyped tc, untyped pool) -> Integer
535
773
  def pool_generate: (untyped ctx, untyped tc, untyped pool, bool consume) -> Integer
774
+ def pool_restore: (untyped ctx, untyped tc, untyped pool, Integer variable_id) -> nil
536
775
  def pool_free: (untyped ctx, untyped pool) -> nil
537
- def new_state_machine: (untyped ctx, untyped tc, Array[String] rule_names, Array[String] invariant_names, Array[bool] always_check, Integer step_count) -> untyped
776
+ def new_state_machine: (untyped ctx, untyped tc, Array[String] rule_names, Array[Float] rule_weights, Array[String] invariant_names, Array[bool] always_check, Integer step_count) -> untyped
538
777
  def state_machine_next_group: (untyped ctx, untyped tc, untyped state_machine) -> Integer
539
778
  def state_machine_next_rule: (untyped ctx, untyped tc, untyped state_machine) -> Integer
540
779
  def state_machine_rule_rejected: (untyped ctx, untyped tc, untyped state_machine) -> nil
541
780
  def state_machine_should_check_invariant: (untyped ctx, untyped tc, untyped state_machine, Integer index) -> bool
542
781
  def state_machine_free: (untyped ctx, untyped state_machine) -> nil
782
+ def new_recursion: (untyped ctx, untyped tc, Integer max_depth, Integer max_leaves) -> untyped
783
+ def recursion_branch: (untyped ctx, untyped tc, untyped recursion, Integer depth) -> bool
784
+ def recursion_leaf: (untyped ctx, untyped tc, untyped recursion) -> bool
785
+ def recursion_retry: (untyped ctx, untyped tc, untyped recursion) -> nil
786
+ def recursion_finish: (untyped ctx, untyped tc, untyped recursion) -> bool
787
+ def recursion_free: (untyped ctx, untyped recursion) -> nil
543
788
  def generate_float: (untyped ctx, untyped tc, Integer width, Float min_value, Float max_value, bool allow_nan, bool allow_infinity, bool exclude_min, bool exclude_max, Float smallest_nonzero_magnitude) -> Float
544
- def string_generator_text: (untyped ctx, min_size: Integer, max_size: Integer, ?codec: String?, ?min_codepoint: Integer, ?max_codepoint: Integer) -> untyped
789
+ def string_generator_text: (untyped ctx, min_size: Integer, max_size: Integer, ?codec: String?, ?min_codepoint: Integer, ?max_codepoint: Integer, ?categories: Array[String]?, ?exclude_categories: Array[String]?, ?include_characters: String, ?exclude_characters: String) -> untyped
545
790
  def string_generator_free: (untyped ctx, untyped generator) -> nil
546
791
  def generate_string: (untyped ctx, untyped tc, untyped generator) -> String
547
792
  def owned_string_free: (untyped ctx, untyped result) -> nil
@@ -557,6 +802,14 @@ module Hegel
557
802
  def generate_date: (untyped ctx, untyped tc, Array[Integer] min_value, Array[Integer] max_value) -> Array[Integer]
558
803
  def generate_time: (untyped ctx, untyped tc, Array[Integer] min_value, Array[Integer] max_value) -> Array[Integer]
559
804
  def generate_datetime: (untyped ctx, untyped tc, Array[Integer] min_date, Array[Integer] min_time, Array[Integer] max_date, Array[Integer] max_time) -> [Array[Integer], Array[Integer]]
805
+ def grammar_builder_new: (untyped ctx, String text) -> untyped
806
+ def grammar_builder_file: (untyped ctx, untyped builder, Integer index) -> String?
807
+ def grammar_builder_provide: (untyped ctx, untyped builder, Integer index, String? text) -> nil
808
+ def grammar_builder_free: (untyped ctx, untyped builder) -> nil
809
+ def grammar_new: (untyped ctx, untyped builder, String? start, Integer max_size, Integer max_depth, untyped alphabet, Array[String] names) -> untyped
810
+ def grammar_placeholder: (untyped ctx, untyped grammar, String name) -> String
811
+ def grammar_free: (untyped ctx, untyped grammar) -> nil
812
+ def generate_grammar: (untyped ctx, untyped tc, untyped grammar, Integer max_size) -> String
560
813
  end
561
814
  end
562
815
  end