Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portability: add doc on testing #16

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/portability.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ When given fixed inputs,
- For portable items, any change of output across versions is considered
equivalent to an API breaking change.

## Portability of usize
### Testing

We expect all pseudo-random algorithms to test the value-stability of their
output, where possible:

- PRNGs should be compared with a reference vector ([example](https://github.com/rust-random/rngs/blob/master/rand_xoshiro/src/xoshiro256starstar.rs#L113))
- Other algorithms should include their own test vectors within a
`value_stability` test or similar ([example](https://github.com/rust-random/rand/blob/master/src/distributions/bernoulli.rs#L168))

## Limitations

### Portability of usize

There is unfortunately one non-portable item baked into the heart of the Rust
language: `usize` (and `isize`). For example, the size of an empty
Expand All @@ -47,7 +58,7 @@ code requiring a bounded `usize` value will sample a `u32` value unless the
upper bound exceeds `u32::MAX`.
(Note that this actually improves benchmark performance in many cases.)

## Portability of floats
### Portability of floats

The results of floating point arithmetic depend on rounding modes and
implementation details. Especially the results of transcendental functions vary
Expand Down