tests: add whitespace tests for vertical tab behavior#155028
tests: add whitespace tests for vertical tab behavior#155028Brace1000 wants to merge 40 commits intorust-lang:mainfrom
Conversation
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| let x = 5; | ||
| let y = 10; | ||
| let z = x + y; | ||
|
|
There was a problem hiding this comment.
Since vertical tab doesn't show up in GitHub's PR review rendering, please put a comment above each line containing the whitespace.
You might want to add lines with each of the 11 permitted whitespace characters:
https://doc.rust-lang.org/reference/whitespace.html
And then some lines with the other 14 disallowed whitespace characters (the ones from this list marked White_Space, that aren't in the first list):
https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
There was a problem hiding this comment.
Done! Added a comment above each line with an invisible whitespace character so they are visible in the diff. Also expanded the test to cover all 11 permitted Pattern_White_Space characters inline, and listed the 14 disallowed Unicode White_Space characters in comments since placing them between tokens would cause a compile error.
There was a problem hiding this comment.
You can create a separate test that fails, and put //@ check-fail at the top of the file:
https://rustc-dev-guide.rust-lang.org/tests/directives.html#controlling-outcome-expectations
This is how to test whitespace that is not allowed in Rust source code.
There was a problem hiding this comment.
Thanks for the feedback! I’ve added the failing UI test and updated it to match the full stderr output, including the help message. I’ll go through it again and make the remaining tweaks.
| @@ -0,0 +1,22 @@ | |||
| // This test checks that split_ascii_whitespace does NOT split on | |||
There was a problem hiding this comment.
I'm not sure if this test is relevant to the compiler?
There was a problem hiding this comment.
Fair point. The test documents the gap between what the lexer accepts and what the stdlib gives you. Happy to remove it if you think it doesn't belong here.
|
|
||
| Tests on `where` clauses. See [Where clauses | Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses). | ||
|
|
||
| ## `whitespace` |
There was a problem hiding this comment.
This will need an explanation of why the whitespace tests are needed. It's a good place to mention that is_ascii_whitespace and is_whitespace in the standard library don't match the Rust language's definition of whitespace.
There was a problem hiding this comment.
Added! The README now explains that the Rust lexer uses Unicode Pattern_White_Space, which differs from both is_ascii_whitespace (WhatWG, skips vertical tab) and is_whitespace (Unicode White_Space, broader set). That context makes it clearer why these tests exist
| // the standard library's is_ascii_whitespace does NOT include vertical | ||
| // tab, following the WhatWG Infra Standard instead. | ||
| // | ||
| // See: https://github.com/rust-lang/rust-project-goals/issues/53 |
There was a problem hiding this comment.
Where did you get this link? It's not the Outreachy tracking issue.
There was a problem hiding this comment.
Got it, Fixed it to point to the correct Outreachy tracking issue.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Add two small tests to highlight how vertical tab is handled differently. - vertical_tab_lexer.rs checks that the lexer treats vertical tab as whitespace - ascii_whitespace_excludes_vertical_tab.rs shows that split_ascii_whitespace does not split on it This helps document the difference between the Rust parser (which accepts vertical tab) and the standard library’s ASCII whitespace handling. See: rust-lang/rust-project-goals#53
make sure tabs and spaces are well checked
Updated error message to clarify invisible characters.
This comment has been minimized.
This comment has been minimized.
Updated error message for invisible characters in code.
This comment has been minimized.
This comment has been minimized.
Add error message for invalid whitespace in code
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Updated the test to check for invalid whitespace handling.
This comment has been minimized.
This comment has been minimized.
Fix formatting issue by adding space around '=' in variable declaration.
This comment has been minimized.
This comment has been minimized.
Update the error messages for invalid whitespace in the test.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| | | ||
| = help: invisible characters like '\u{200b}' are not usually visible in text editors | ||
|
|
||
| error: aborting due to 1 previous error |
There was a problem hiding this comment.
You need to update this file so it matches the test output exactly.
The easiest way to do this is ./x test ui/whitespace --bless
There was a problem hiding this comment.
Got it, thanks! I ran "./x test ui/whitespace --bless" and updated the file to match the expected output. Everything is passing on my end now
Removed unnecessary blank lines from the test file.
This comment has been minimized.
This comment has been minimized.
|
Hi @teor2345 , Since today is the deadline, I just wanted to check , is it okay if I keep contributing to this PR while it’s still under review? It’s almost there, so I’d be happy to address any remaining feedback if that works. |
|
You can put links to incomplete PRs in your final application, and you can continue to work on those PRs. What happens to your PR is up to the maintainers of the tool you're modifying or testing. Sometimes PRs (or parts of PRs) don't get accepted for good reasons, and that's ok. Sometimes there are review delays because reviewers are busy, and that's also ok. |
|
Hi @teor2345 , |
|
The next step is a review by someone with Rust merge rights. Please be patient, it is normal for reviewers to take 2 weeks or more to review your PR. If it has been more than 2 weeks, you can tag the assigned reviewer, or re-assign another review using the instructions at the top of this PR. |
|
Got it, thank you for the clarification. I’ll be patient and follow up if needed after some time. |
View all comments
This PR adds two small tests to highlight how vertical tab (\x0B)
is handled differently across Rust's whitespace definitions.
The Rust lexer treats vertical tab as whitespace (Unicode
Pattern_White_Space), while
split_ascii_whitespacefollows theWhatWG Infra Standard and does not include vertical tab.
These tests make that difference visible and easier to understand.
See: rust-lang/rust-project-goals#53