mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-28 19:23:24 +03:00
resolve multiple chars in a char, tests for it
This commit is contained in:
parent
f36d9b960f
commit
53a668ae14
@ -114,6 +114,10 @@ impl Token {
|
||||
if unicode {
|
||||
let string = input_tendril.to_string();
|
||||
let unicode_number = &string[3..string.len() - 1];
|
||||
let len = unicode_number.len();
|
||||
if !(1..=6).contains(&len) {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Ok(hex) = u32::from_str_radix(&unicode_number, 16) {
|
||||
if let Some(character) = std::char::from_u32(hex) {
|
||||
@ -122,7 +126,9 @@ impl Token {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(character) = input_tendril.to_string().chars().next() {
|
||||
if input_tendril.to_string().chars().count() != 1 {
|
||||
return None;
|
||||
} else if let Some(character) = input_tendril.to_string().chars().next() {
|
||||
return Some(character);
|
||||
}
|
||||
|
||||
|
@ -6,3 +6,7 @@ outputs:
|
||||
- " --> test:1:1\n |\n 1 | 'a\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | ''\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | '\\x9'\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | 'abcdefg'\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | '\\t\\t'\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | '\\u{bbbbb}\\u{aaaa}'\n | ^\n |\n = unexpected token: '''"
|
||||
- " --> test:1:1\n |\n 1 | '😭😂😘'\n | ^\n |\n = unexpected token: '''"
|
||||
|
@ -10,3 +10,11 @@ expectation: Fail
|
||||
''
|
||||
|
||||
'\x9'
|
||||
|
||||
'abcdefg'
|
||||
|
||||
'\t\t'
|
||||
|
||||
'\u{bbbbb}\u{aaaa}'
|
||||
|
||||
'😭😂😘'
|
Loading…
Reference in New Issue
Block a user