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

Add support for compiling examples with --test to rustdoc & update the testing guide #15039

Closed
wants to merge 3 commits into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Jun 19, 2014

```test_harness
#[test]
fn foo() {}
```

will now compile and run the tests, rather than just ignoring & stripping them (i.e. it is as if --test was passed).

Also, the specific example in #12242 was fixed (but that issue is broader than that example).

Fields have names, unlike an anonymous tuple.
This adds the `test_harness` directive that runs a code block using the
test runner, to allow for `#[test]` items to be demonstrated and still
tested (currently they are just stripped and not even compiled, let
alone run).
@huonw
Copy link
Member Author

huonw commented Jun 19, 2014

r? @alexcrichton

b.iter(|| {
// note lack of `;` (could also use an explicit `return`).
range(0, 1000).fold(0, |old, new| old ^ new)
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, could you de-indent these examples? I'm not sure why the body is indented twice and the last brace/paren is indented once.

@alexcrichton
Copy link
Member

r=me, just one minor comment

rustdoc now supports compiling things with `--test` so the examples in
this guide can be compiled & tested properly (revealing a few issues &
out-dated behaviours).

Also, reword an example to be clearer, cc rust-lang#12242.
bors added a commit that referenced this pull request Jun 20, 2014
    ```test_harness
    #[test]
    fn foo() {}
    ```

will now compile and run the tests, rather than just ignoring & stripping them (i.e. it is as if `--test` was passed).

Also, the specific example in #12242 was fixed (but that issue is broader than that example).
@bors bors closed this Jun 20, 2014
@huonw huonw deleted the rustdoc-testharnesss branch July 11, 2014 05:54
lnicola pushed a commit to lnicola/rust that referenced this pull request Jun 19, 2023
fix: Use a more obscure hasher name in derive expansion

Closes rust-lang#15039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants