Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: testing that nargo fmt is idempotent (#4765)
# Description ## Problem\* Resolves #4666 ## Summary\* Ensures that `nargo_fmt(nargo_fmt(source_code)) == nargo_fmt(source_code)`. Because we have expected outputs, we can avoid re-running on the unformatted inputs: ```rust nargo_fmt(expected_output) == expected_output ``` ### Bugs found - #4766 - #4767 - #4768 Currently failing on arrays and tuples: ```bash ---- tests::format_idempotent_array stdout ---- thread 'tests::format_idempotent_array' panicked at /Users/michaelklein/Coding/rust/noir/target/debug/build/nargo_fmt-14fb91f269fc38b6/out/execute.rs:3418:9: assertion failed: `(left == right)`' left: `"fn big_array() {\n [\n 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 1..."` (truncated) right: `"fn big_array() {\n [\n 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 1..."` (truncated) Differences (-left|+right): [ // hello! 1, // asd - 10 + 10 // asdasd ]; [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]], [[13, 14, 15], [16, 17, 18]]]; note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- tests::format_idempotent_tuple stdout ---- thread 'tests::format_idempotent_tuple' panicked at /Users/michaelklein/Coding/rust/noir/target/debug/build/nargo_fmt-14fb91f269fc38b6/out/execute.rs:776:9: assertion failed: `(left == right)`' left: `"fn main() {\n (1,);\n (// hello\n 1,);\n (/*hello*/ 1,);\n (1/*hello*/,);\n (1,);\n (/*test*/ 1,);\n (/*a*/ 1/*b*/,);\n (/*a*/ 1/*b*/, /*c*/ 2/*d*/, /*c*/ 2/*d*/);\n (/*a*/ 1/*..."` (truncated) right: `"fn main() {\n (1,);\n (// hello\n 1,);\n (/*hello*/ 1,);\n (1/*hello*/,);\n (1,);\n (/*test*/ 1,);\n (/*a*/ 1/*b*/,);\n (/*a*/ 1/*b*/, /*c*/ 2/*d*/, /*c*/ 2/*d*/);\n (/*a*/ 1/*..."` (truncated) Differences (-left|+right): (// 1,); (// 1 - 1,// 2, + 1, // 2, 2); (/*1*/ 1, /*2*/ 2); // FIXME: (((//2 1,),),); (/*a*/ - 1/*b*/, /*c*/ 2/*d*/, /*c*/ 2/*d*/, /*e*/ 3/*f*/); + 1/*b*/, +/*c*/ 2/*d*/, /*c*/ 2/*d*/, /*e*/ 3/*f*/); } ``` ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French <[email protected]>
- Loading branch information