$ the-wire · showcase
ExUnit parameterized tests now draw unique random sequences
By RepoJournal · Filed · About Elixir & Phoenix
ExUnit seeded each parameterized test run with the same random state, so every parameter value drew the same random sequence; a new change mixes test parameters into the per-test seed.
ExUnit's per-test `:rand` seeding changed for parameterized tests. Previously, `parameterize` re-ran the module once per parameter set, changing only `test.parameters` while leaving `test.name` intact, so every parameterized run started from the identical `:rand` state and produced the same random sequence. The seed is now `{phash2(module), phash2(name), suite_seed}` with parameters mixed in, giving each parameter set its own deterministic random stream [1]. If your parameterized tests rely on randomness differentiating per parameter, they will now behave differently; existing tests that assert on specific random output may need updates.
Elixir's compiler fixed an exception raised by `round/2`, `floor/2`, and `ceil/2` for invalid float precision. These functions used to raise the wrong exception; they now raise the correct one for invalid precision input [2]. Function domain disjointness checks in the compiler are deferred until nonemptiness succeeds, skipping pairwise disjointness checks when nonemptiness fails [3][4].
In Phoenix LiveView, redundant stream-rendering branches were removed from the rendering logic [5], and assets were updated [6]. Both changes are internal refactors with no expected behavior change for applications using streams.
Action items
- → If you use parameterized ExUnit tests that depend on randomness, verify assertions still hold with the new seeding behavior elixir-lang/elixir [plan]
- → Upgrade Elixir to include the float precision exception fix before relying on those functions with invalid precision elixir-lang/elixir [plan]
- → Monitor Phoenix LiveView's stream rendering after the branch removal to catch any regressions in your app phoenixframework/phoenix_live_view [monitor]
References
- [1] Mix test parameters into the per-test :rand seed ↗ elixir-lang/elixir
- [2] Fix float round/2, floor/2, ceil/2 raises wrong exception for invalid precision (#15872) ↗ elixir-lang/elixir
- [3] Defer function domain disjointness until nonemptiness succeeds ↗ elixir-lang/elixir
- [4] Defer function domain disjointness until nonemptiness succeeds (#15870) ↗ elixir-lang/elixir
- [5] Remove redundant stream-rendering branches (#4433) ↗ phoenixframework/phoenix_live_view
- [6] Update assets ↗ phoenixframework/phoenix_live_view