Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/syn-2.0.119/tests/test_ident.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / syn-2.0.119 / tests / test_ident.rs` 87 lines ยท 1320 bytes Raw Blame History 1 use proc_macro2::{Ident, Span, TokenStream}; 2 use std::str::FromStr; 3 use syn::Result; 4 5 #[track_caller] 6 fn parse(s: &str) -> Result { 7 syn::parse2(TokenStream::from_str(s).unwrap()) 8 } 9 10 #[track_caller] 11 fn new(s: &str) -> Ident { 12 Ident::new(s, Span::call_site()) 13 } 14 15 #[test] 16 fn ident_parse() { 17 parse("String").unwrap(); 18 } 19 20 #[test] 21 fn ident_parse_keyword() { 22 parse("abstract").unwrap_err(); 23 } 24 25 #[test] 26 fn ident_parse_empty() { 27 parse("").unwrap_err(); 28 } 29 30 #[test] 31 fn ident_parse_lifetime() { 32 parse("'static").unwrap_err(); 33 } 34 35 #[test] 36 fn ident_parse_underscore() { 37 parse("_").unwrap_err(); 38 } 39 40 #[test] 41 fn ident_parse_number() { 42 parse("255").unwrap_err(); 43 } 44 45 #[test] 46 fn ident_parse_invalid() { 47 parse("a#").unwrap_err(); 48 } 49 50 #[test] 51 fn ident_new() { 52 new("String"); 53 } 54 55 #[test] 56 fn ident_new_keyword() { 57 new("abstract"); 58 } 59 60 #[test] 61 #[should_panic(expected = "use Option")] 62 fn ident_new_empty() { 63 new(""); 64 } 65 66 #[test] 67 #[should_panic(expected = "not a valid Ident")] 68 fn ident_new_lifetime() { 69 new("'static"); 70 } 71 72 #[test] 73 fn ident_new_underscore() { 74 new("_"); 75 } 76 77 #[test] 78 #[should_panic(expected = "use Literal instead")] 79 fn ident_new_number() { 80 new("255"); 81 } 82 83 #[test] 84 #[should_panic(expected = "\"a#\" is not a valid Ident")] 85 fn ident_new_invalid() { 86 new("a#"); 87 }