From 842ff0212e52f74b798e6e3fbff303955a2fb247 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 7 Sep 2023 12:02:50 +0200 Subject: [PATCH] Add Lexer emoji test case (#7213) --- crates/ruff_python_parser/src/lexer.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 167250179d..7d736d5ba7 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -1716,4 +1716,22 @@ def f(arg=%timeit a = b): let source = "[1"; let _ = lex(source, Mode::Module).collect::>(); } + + /// Emoji identifiers are a non-standard python feature and are not supported by our lexer. + #[test] + fn test_emoji_identifier() { + let source = "🐦"; + + let lexed: Vec<_> = lex(source, Mode::Module).collect(); + + match lexed.as_slice() { + [Err(error)] => { + assert_eq!( + error.error, + LexicalErrorType::UnrecognizedToken { tok: '🐦' } + ); + } + result => panic!("Expected an error token but found {result:?}"), + } + } }