-
Notifications
You must be signed in to change notification settings - Fork 235
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
Test that nargo fmt
is idempotent
#4666
Labels
enhancement
New feature or request
Comments
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Apr 12, 2024
# 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]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
We currently lack tests that
nargo fmt
is idempotent, i.e. that running it twice is equivalent to running it once.This can catch bugs of the following forms:
nargo fmt
nargo fmt
Happy Case
Run
nargo fmt
an twice and check that the output is the same both timesProject Impact
Nice-to-have
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: