5 ms·
Holy crap, this is f*ing awesome. Rust has made systems programming exciting for me again. Seeing well written Rust code like this (also, the repos on Github h
by temuze 12y ago
Holy crap, this is f*ing awesome. Rust has made systems programming exciting for me again.
Seeing well written Rust code like this (also, the repos on Github https://github.com/trending?l=rust https://github.com/trending?l=rust) has been a really good learning experience. As a Rust newbie, I only wish there were better examples of testing in public Rust repos.
- jnbiche 12y ago>As a Rust newbie, I only wish there were better examples of testing in public Rust repos. Testing is incredibly easy. The reason you may have missed the testing is that tests are often in the same file as tested code. Go back and check, it's very common in Rust to test your code. And it's as simple as writing: #[test] on the line before your unit test function, and then using some of the unit test macros in std like `assert` and `assert_eq` along with `fail` to perform the tests[1]. Then you test your code by running the normal rustc command but with the `--test` flag. A test runner with very attractive output is built into the compiler. Rust unit testing is just about the easiest testing I've ever used, right up there with golang. I love that it's built into the language. Also, the `cargo` package manager makes everything -- including unit testing -- incredibly convenient. And I say this as someone who cringes every time a language comes out with yet another package manager or build tool (ahem, .js). But in the case of rust's cargo, it's incredibly worth it to use a new package manager, and so much better than a Makefile (although it's quite easy to integrate makesfiles with cargo). 1. http://doc.rust-lang.org/std/index.html http://doc.rust-lang.org/std/index.html
- yen223 12y agoOne of the huge wins of rust is that the devs put a lot of effort into its basic infrastructure. Testing, documenting, and benchmarking are almost too easy.
- steveklabnik 12y agoThe guide has a whole section on this: http://doc.rust-lang.org/guide.html#testing http://doc.rust-lang.org/guide.html#testing And we even have a full guide on testing, though I haven't checked it lately: http://doc.rust-lang.org/guide-testing.html http://doc.rust-lang.org/guide-testing.html (it's on the todo list)