<commit_before>Testing
=======

Rubyists love testing, so before we go any farther, let's talk about
testing. In Rust, there is a unit testing framework built in, and it's
pretty simple. Let's write some very simple code and tests to exercise
it.

In Rust, you annotate test methods like such:

~~~ {.rust}
    #[test]
    fn this_tests_code() {
        // SOMETHING HERE
    }
~~~

You'll note that tests take no arguments and return nothing. If the
function runs, the test passes, and if it errors in some way, the test
fails. Let's give it a shot: Open up `testing.rs` and put this in it:

~~~ {.rust}
    use std::io::println;

    #[test]
    fn this_tests_code() {
        println("")
    }
~~~

Then, use `rustc` with a special flag:

    $ rustc --test testing.rs

This tells `rustc` to compile your tests, and replaces the `main` function
with a test runner. Try it out:

    $ ./testing

You should get some output that looks like this:

    running 1 test

    test this_tests_code ... ok

    result: ok. 1 passed; 0 failed; 0 ignored

Bam! Now let's make it fail:

~~~ {.rust}
    use std::io::println;
<commit_msg>Add a semicolon to remove confusion about why it was left out<commit_after>Testing
=======

Rubyists love testing, so before we go any farther, let's talk about
testing. In Rust, there is a unit testing framework built in, and it's
pretty simple. Let's write some very simple code and tests to exercise
it.

In Rust, you annotate test methods like such:

~~~ {.rust}
    #[test]
    fn this_tests_code() {
        // SOMETHING HERE
    }
~~~

You'll note that tests take no arguments and return nothing. If the
function runs, the test passes, and if it errors in some way, the test
fails. Let's give it a shot: Open up `testing.rs` and put this in it:

~~~ {.rust}
    use std::io::println;

    #[test]
    fn this_tests_code() {
        println("");
    }
~~~

Then, use `rustc` with a special flag:

    $ rustc --test testing.rs

This tells `rustc` to compile your tests, and replaces the `main` function
with a test runner. Try it out:

    $ ./testing

You should get some output that looks like this:

    running 1 test

    test this_tests_code ... ok

    result: ok. 1 passed; 0 failed; 0 ignored

Bam! Now let's make it fail:

~~~ {.rust}
    use std::io::println;

{'fraction_non_alphanumeric': 0.1019522776572668, 'fraction_numerical': 0.0034707158351409977, 'mean_word_length': 3.0174216027874565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7442055', 'n_tokens_mistral': 757, 'n_tokens_neox': 699, 'n_words': 335}