-
Notifications
You must be signed in to change notification settings - Fork 13.4k
impl FromStr for proc_macro::Literal #84717
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
39441bb
Make a ui test to take the role of libproc_macro #[test] tests
dtolnay 3c16c0e
Move proc_macro tests to ui test
dtolnay faad7e2
Make a more meaningful test for Punct eq
dtolnay 965bce4
Add proc macro Literal parse test
dtolnay 34585cb
impl FromStr for proc_macro::Literal
dtolnay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
#![crate_name = "proc_macro_api_tests"] | ||
#![feature(proc_macro_span)] | ||
#![deny(dead_code)] // catch if a test function is never called | ||
|
||
extern crate proc_macro; | ||
|
||
mod cmp; | ||
mod parse; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro] | ||
pub fn run(input: TokenStream) -> TokenStream { | ||
assert!(input.is_empty()); | ||
|
||
cmp::test(); | ||
parse::test(); | ||
|
||
TokenStream::new() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use proc_macro::Literal; | ||
|
||
pub fn test() { | ||
test_parse_literal(); | ||
} | ||
|
||
fn test_parse_literal() { | ||
assert_eq!("1".parse::<Literal>().unwrap().to_string(), "1"); | ||
assert_eq!("1.0".parse::<Literal>().unwrap().to_string(), "1.0"); | ||
assert_eq!("'a'".parse::<Literal>().unwrap().to_string(), "'a'"); | ||
assert_eq!("\"\n\"".parse::<Literal>().unwrap().to_string(), "\"\n\""); | ||
assert_eq!("b\"\"".parse::<Literal>().unwrap().to_string(), "b\"\""); | ||
assert_eq!("r##\"\"##".parse::<Literal>().unwrap().to_string(), "r##\"\"##"); | ||
assert_eq!("10ulong".parse::<Literal>().unwrap().to_string(), "10ulong"); | ||
|
||
dtolnay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert!("0 1".parse::<Literal>().is_err()); | ||
assert!("'a".parse::<Literal>().is_err()); | ||
assert!(" 0".parse::<Literal>().is_err()); | ||
assert!("0 ".parse::<Literal>().is_err()); | ||
assert!("/* comment */0".parse::<Literal>().is_err()); | ||
assert!("0/* comment */".parse::<Literal>().is_err()); | ||
assert!("0// comment".parse::<Literal>().is_err()); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// check-pass | ||
// aux-build:api/mod.rs | ||
|
||
//! This is for everything that *would* be a #[test] inside of libproc_macro, | ||
//! except for the fact that proc_macro objects are not capable of existing | ||
//! inside of an ordinary Rust test execution, only inside a macro. | ||
|
||
extern crate proc_macro_api_tests; | ||
|
||
proc_macro_api_tests::run!(); | ||
|
||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.