tests: Coverage and cleanup/speedup

- Improved test coverage to >80% of lines, functions
  - When doctests are included.
  - Wrote new unit tests:
    - Explicit tests for invalid instructions in the
      ranges {`5xyn`, `8xyn`, `9xyn`, `Fxbb`}
    - `rand` Tests for 1052671 cycles, to ensure
      randomly generated number is < ANDed byte
    - `Ex9E` (sek), `ExA1`(snek) will press only the expected key,
      then every key except the expected key, for every address
    - `Fx0A` (waitk) asserts based on the waveform of a keypress.
      After all, an A press is an A press.
- Improved test performance by printing slightly less
- Removed nightly requirement
  - (now optional, with feature = "unstable")
- Amended justfile to test with `cargo nextest` (nice)
- Changed release builds to optlevel 3
This commit is contained in:
2023-03-28 07:33:17 -05:00
parent 66bed02a5e
commit fbc0a0b2ea
9 changed files with 435 additions and 97 deletions

View File

@@ -74,10 +74,35 @@ pub struct ControlFlags {
impl ControlFlags {
/// Toggles debug mode
///
/// # Examples
/// ```rust
///# use chirp::prelude::*;
///# fn main() -> Result<()> {
/// let mut cpu = CPU::default();
/// assert_eq!(true, cpu.flags.debug);
/// cpu.flags.debug();
/// assert_eq!(false, cpu.flags.debug);
///# Ok(())
///# }
/// ```
pub fn debug(&mut self) {
self.debug = !self.debug
}
/// Toggles pause
///
/// # Examples
/// ```rust
///# use chirp::prelude::*;
///# fn main() -> Result<()> {
/// let mut cpu = CPU::default();
/// assert_eq!(false, cpu.flags.pause);
/// cpu.flags.pause();
/// assert_eq!(true, cpu.flags.pause);
///# Ok(())
///# }
/// ```
pub fn pause(&mut self) {
self.pause = !self.pause
}