move-language / move

Apache License 2.0
2.24k stars 677 forks source link

[Feature Request] Doctest #1044

Open alnoki opened 1 year ago

alnoki commented 1 year ago

@davidiw @sblackshear @wrwg

Ideally running move unit tests would also run doctests inside any doc comments in the package.

For comparison, consider the following from BCS:

//! ```rust
//! # use bcs::{Result, to_bytes};
//! # fn main() -> Result<()> {
//! let fixed: [u16; 3] = [1, 2, 3];
//! assert_eq!(to_bytes(&fixed)?, vec![1, 0, 2, 0, 3, 0]);
//!
//! let variable: Vec<u16> = vec![1, 2];
//! assert_eq!(to_bytes(&variable)?, vec![2, 1, 0, 2, 0]);
//!
//! let large_variable_length: Vec<()> = vec![(); 9_487];
//! assert_eq!(to_bytes(&large_variable_length)?, vec![0x8f, 0x4a]);
//! # Ok(())}
//! ```

See also: