Mercurial > python-compiler.rs
changeset 93:c06d12a81637
Better test failure. Use assert_diff! instead of assert_eq! so we can actually see what the differences are.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Tue, 14 Jun 2016 02:53:29 +0200 |
parents | 7977a52c3202 |
children | e0368bea06a6 |
files | Cargo.lock Cargo.toml src/main.rs src/tests/test_parse_files.rs |
diffstat | 4 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Cargo.lock +++ b/Cargo.lock @@ -3,6 +3,7 @@ name = "python-compiler" version = "0.0.1" dependencies = [ "cpython 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "difference 0.4.1 (git+https://github.com/johannhof/difference.rs.git)", ] [[package]] @@ -31,6 +32,19 @@ dependencies = [ ] [[package]] +name = "difference" +version = "0.4.1" +source = "git+https://github.com/johannhof/difference.rs.git#d5b2ad5b9670b9b1e097113bb60c13894b94e33a" +dependencies = [ + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "getopts" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "interpolate_idents" version = "0.0.10" source = "registry+https://github.com/rust-lang/crates.io-index"
--- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ build = "build.rs" [dependencies] cpython = "0.0" +difference = { "git" = "https://github.com/johannhof/difference.rs.git" }
--- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ +#[macro_use(assert_diff)] +extern crate difference; extern crate cpython; + #[cfg(test)] mod tests;
--- a/src/tests/test_parse_files.rs +++ b/src/tests/test_parse_files.rs @@ -27,8 +27,8 @@ fn test_parse_file(filename: &str) { }; let module_ast = ast_convert::convert_ast("__main__".to_string(), &module); - let dumped_ast = ast_dump::dump_ast(&module_ast); - assert_eq!(code, dumped_ast + "\n"); + let dumped_ast = ast_dump::dump_ast(&module_ast) + "\n"; + assert_diff!(code.as_str(), dumped_ast.as_str(), "\n", 0); } include!(concat!(env!("OUT_DIR"), "/generated_parse_tests.rs"));