Add examples to CI workflow, register missing example metadata, and add comprehensive test suite#146
Conversation
…Cargo.toml Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
HyperCodec
left a comment
There was a problem hiding this comment.
When rewriting the genetic-rs crate, I had removed a lot of the old tests and had not put them back. Make a new test suite to help enforce invariants and such (which is particularly important with rng-based crates like this where buggy behaviors might not be immediately apparent).
Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Added four new integration-test files in commit 2641263, covering the main structural invariants across the crate:
All 63 tests pass and clippy is clean. |
HyperCodec
left a comment
There was a problem hiding this comment.
kind of excessive amount of comments imo, but LGTM
Tests had largely been replaced by manual verification via examples; this wires all examples into CI and introduces a new integration test suite to enforce invariants across the crate.
genetic-rs/Cargo.toml[[example]]entries forreadme_exandknockout(previously unregistered, so cargo wouldn't enforce their feature requirements)genrandtorequired-featuresforcrossoverandspeciation— both callVec::gen_randomwhich is gated behind that feature[[test]]targets with their respectiverequired-features.github/workflows/ci-cd.ymlexamplesjob runs all five examples (readme_ex,crossover,knockout,derive,speciation) with their declared minimal feature setspermissions: contents: readNew integration tests
tests/simulation.rs(builtin, genrand) —GeneticSimpopulation-size preservation over single and many generations;FitnessEliminatorsorting, threshold, highest/lowest-fitness invariants, custom threshold, builder pattern; observer called exactly once per generation;GenerateRandomcollection sizetests/knockout.rs(knockout, genrand) —KnockoutEliminatoroutput-size invariant for even input; all threeActionIfOddvariants;KnockoutWinnerNot/From<Ordering>/Into<usize>conversions; correct genome survives each pair;FitnessKnockoutFndelegation behaviourtests/repopulator.rs(crossover, genrand) —MitosisRepopulatorandCrossoverRepopulatorfill-to-target and no-op invariants; zero-mutation-rate cloning; deterministic crossover averaging;FromParentcount and first-element invariants; population stability over many generationstests/speciation.rs(speciation, genrand) — identical/different-class species grouping; high-threshold merging; every-genome-index-once invariant;insert_genomenew-species and join-existing paths;round_robinfull-cycle coverage;round_robin_enumeratepair validity;SpeciatedFitnessEliminatorpopulation-size stability; rare-species fitness-protection invariantOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.