-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
tests: add whitespace tests for vertical tab behavior #155028
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
base: main
Are you sure you want to change the base?
Changes from all commits
5c1a74e
21f0c4e
c6403d9
6c8b0bf
f8e9276
027201d
f2f460a
a5c0c3c
7b741a5
44df8f9
053f744
fde6f69
1bd1021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // This test checks that split_ascii_whitespace does NOT split on | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this test is relevant to the compiler? |
||
| // vertical tab (\x0B), because the standard library uses the WhatWG | ||
| // Infra Standard definition of ASCII whitespace, which excludes | ||
| // vertical tab. | ||
| // | ||
| // See: https://github.com/rust-lang/rust-project-goals/issues/53 | ||
|
|
||
| fn main() { | ||
| let s = "a\x0Bb"; | ||
|
|
||
| let parts: Vec<&str> = s.split_ascii_whitespace().collect(); | ||
|
|
||
| assert_eq!(parts.len(), 1, | ||
| "vertical tab should not be treated as ASCII whitespace"); | ||
|
|
||
| let s2 = "a b"; | ||
| let parts2: Vec<&str> = s2.split_ascii_whitespace().collect(); | ||
| assert_eq!(parts2.len(), 2, | ||
| "regular space should split correctly"); | ||
|
|
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // This test checks that the Rust lexer treats vertical tab (\x0B) as | ||
| // whitespace, consistent with Unicode Pattern_White_Space. Note that | ||
| // 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did you get this link? It's not the Outreachy tracking issue. |
||
|
|
||
| fn main() { | ||
| let x = 5; | ||
| let y = 10; | ||
| let z = x + y; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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: 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): |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.