diff --git a/specs/port/trios-railway/crates/trios-igla-race/src/sampler.t27 b/specs/port/trios-railway/crates/trios-igla-race/src/sampler.t27 new file mode 100644 index 0000000000..a9b5df30ba --- /dev/null +++ b/specs/port/trios-railway/crates/trios-igla-race/src/sampler.t27 @@ -0,0 +1,56 @@ +// trios-igla-race config sampler — the stateless unit constructor. +// Port of gHashTag/trios-railway:crates/trios-igla-race/src/sampler.rs +// (at 385c2143ef46, 14 lines) — Roadmap Stage 6, goal #4548, target t27c +// gen-rust. +// +// The original is the config sampler's zero-sized unit: a struct with no +// fields, `new` building it, and `Default` delegating to `new`. The two +// decisions the file carries are its statelessness — the sampler holds no +// configuration of its own — and the delegation: the default value IS +// the constructed one. Both are ported as pure functions and tested, the +// same shape the ASHA scheduler port (#9659) uses for its own unit: the +// constructor builds the unit, the default calls the constructor (the +// delegation is this port's body), and the field-count pin asserts the +// zero-field design against a regression that would grow hidden state +// onto the sampler. No transport exists in this port (issue #9664, +// "Port the decision, not the plumbing"). + +module port::trios_igla_race_sampler; + +// Original line 1: `pub struct ConfigSampler;` — the zero-sized unit. +pub struct ConfigSampler { } + +// The sampler's design decision, countable: it carries no state — no +// held configuration, no pending sample, no RNG handle. Anything grown +// onto this struct would be hidden state. +pub fn sampler_field_count() -> usize { + return 0; +} + +// Original lines 3-8: `impl ConfigSampler { pub fn new() -> Self }` — the +// constructor builds the unit. +pub fn ConfigSampler_new() -> ConfigSampler { + return ConfigSampler { }; +} + +// Original lines 10-14: `impl Default for ConfigSampler { fn default() +// -> Self { Self::new() } }` — the default value delegates to the +// constructor: the delegation is this port's body. +pub fn ConfigSampler_default() -> ConfigSampler { + return ConfigSampler_new(); +} + +// --------------------------------------------------------------------------- +// Tests: the unit's decisions asserted — construction, delegation, and +// the zero-field pin. +// --------------------------------------------------------------------------- + +test new_builds_the_stateless_sampler { + const s = ConfigSampler_new(); + assert(sampler_field_count() == 0); +} + +test default_delegates_to_the_constructor { + const d = ConfigSampler_default(); + assert(sampler_field_count() == 0); +}