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

Fix pixels-mocks crate #80

Open
parasyte opened this issue May 22, 2020 · 0 comments
Open

Fix pixels-mocks crate #80

parasyte opened this issue May 22, 2020 · 0 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@parasyte
Copy link
Owner

We have cargo doctests enabled in CI, but many of them do not run because they are tagged with no_run. The reason for this is the pixels-mocks crate doesn't generate valid code (it just compiles).

This has resulted in at least one bad example that would have hit an assertion failure:

pixels/src/lib.rs

Lines 352 to 367 in de21862

/// ```no_run
/// # use pixels::Pixels;
/// # let surface = wgpu::Surface::create(&pixels_mocks::RWH);
/// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, surface);
/// const WIDTH: u32 = 320;
/// const HEIGHT: u32 = 240;
///
/// let mut pixels = Pixels::new(WIDTH, HEIGHT, surface_texture)?;
///
/// let pixel_pos = pixels.clamp_pixel_pos((-19, 20));
/// assert_eq!(pixel_pos, (0, 20));
///
/// let pixel_pos = pixels.clamp_pixel_pos((11, 3000));
/// assert_eq!(pixel_pos, (11, 240));
/// # Ok::<(), pixels::Error>(())
/// ```

The last assertion should compare against (11, 239)

Fixing the pixels-mocks crate enough that the examples can run would have prevented this error.

@parasyte parasyte added bug Something isn't working documentation Improvements or additions to documentation labels May 22, 2020
parasyte added a commit that referenced this issue Jul 19, 2020
parasyte added a commit that referenced this issue Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant