diff options
| author | lWarne | 2022-08-06 15:01:38 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-08-06 15:01:38 +0200 |
| commit | d8abff398bc45a791783c5c463838ba6fa3f030e (patch) | |
| tree | b9d1fea79c715cc881a83a2201343f50194d78ce /test/lisp/progmodes/python-tests.el | |
| parent | 83496888aaed10de35b3cbce695600300a30af84 (diff) | |
| download | emacs-d8abff398bc45a791783c5c463838ba6fa3f030e.tar.gz emacs-d8abff398bc45a791783c5c463838ba6fa3f030e.zip | |
Fontify python escape sequences in literals
* lisp/progmodes/python.el (python-rx): Add regular expressions
matching escape codes in string and byte literals
(python--string-bytes-literal-matcher): new function
(python--not-raw-bytes-literal-start-regexp): new constant
(python--not-raw-string-literal-start-regexp): new constant
* test/lisp/progmodes/python-tests.el: Add tests for new
fontification (bug#57004).
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 6f2ad87f81a..07f2c4f09a3 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -380,6 +380,83 @@ def f(x: CustomInt) -> CustomInt: | |||
| 380 | (128 . font-lock-builtin-face) (131) | 380 | (128 . font-lock-builtin-face) (131) |
| 381 | (144 . font-lock-keyword-face) (150)))) | 381 | (144 . font-lock-keyword-face) (150)))) |
| 382 | 382 | ||
| 383 | (ert-deftest python-font-lock-escape-sequence-string-newline () | ||
| 384 | (python-tests-assert-faces | ||
| 385 | "'\\n' | ||
| 386 | \"\\n\" | ||
| 387 | f'\\n' | ||
| 388 | f\"\\n\" | ||
| 389 | u'\\n' | ||
| 390 | u\"\\n\"" | ||
| 391 | '((1 . font-lock-doc-face) | ||
| 392 | (2 . font-lock-constant-face) | ||
| 393 | (4 . font-lock-doc-face) (5) | ||
| 394 | (6 . font-lock-doc-face) | ||
| 395 | (7 . font-lock-constant-face) | ||
| 396 | (9 . font-lock-doc-face) (10) | ||
| 397 | (12 . font-lock-string-face) | ||
| 398 | (13 . font-lock-constant-face) | ||
| 399 | (15 . font-lock-string-face) (16) | ||
| 400 | (18 . font-lock-string-face) | ||
| 401 | (19 . font-lock-constant-face) | ||
| 402 | (21 . font-lock-string-face) (22) | ||
| 403 | (24 . font-lock-string-face) | ||
| 404 | (25 . font-lock-constant-face) | ||
| 405 | (27 . font-lock-string-face) (28) | ||
| 406 | (30 . font-lock-string-face) | ||
| 407 | (31 . font-lock-constant-face) | ||
| 408 | (33 . font-lock-string-face)))) | ||
| 409 | |||
| 410 | (ert-deftest python-font-lock-escape-sequence-bytes-newline () | ||
| 411 | (python-tests-assert-faces | ||
| 412 | "b'\\n' | ||
| 413 | b\"\\n\"" | ||
| 414 | '((1) | ||
| 415 | (2 . font-lock-doc-face) | ||
| 416 | (3 . font-lock-constant-face) | ||
| 417 | (5 . font-lock-doc-face) (6) | ||
| 418 | (8 . font-lock-doc-face) | ||
| 419 | (9 . font-lock-constant-face) | ||
| 420 | (11 . font-lock-doc-face)))) | ||
| 421 | |||
| 422 | (ert-deftest python-font-lock-escape-sequence-hex-octal () | ||
| 423 | (python-tests-assert-faces | ||
| 424 | "b'\\x12 \\777' | ||
| 425 | '\\x12 \\777'" | ||
| 426 | '((1) | ||
| 427 | (2 . font-lock-doc-face) | ||
| 428 | (3 . font-lock-constant-face) | ||
| 429 | (7 . font-lock-doc-face) | ||
| 430 | (8 . font-lock-constant-face) | ||
| 431 | (12 . font-lock-doc-face) (13) | ||
| 432 | (14 . font-lock-doc-face) | ||
| 433 | (15 . font-lock-constant-face) | ||
| 434 | (19 . font-lock-doc-face) | ||
| 435 | (20 . font-lock-constant-face) | ||
| 436 | (24 . font-lock-doc-face)))) | ||
| 437 | |||
| 438 | (ert-deftest python-font-lock-escape-sequence-unicode () | ||
| 439 | (python-tests-assert-faces | ||
| 440 | "b'\\u1234 \\U00010348 \\N{Plus-Minus Sign}' | ||
| 441 | '\\u1234 \\U00010348 \\N{Plus-Minus Sign}'" | ||
| 442 | '((1) | ||
| 443 | (2 . font-lock-doc-face) (41) | ||
| 444 | (42 . font-lock-doc-face) | ||
| 445 | (43 . font-lock-constant-face) | ||
| 446 | (49 . font-lock-doc-face) | ||
| 447 | (50 . font-lock-constant-face) | ||
| 448 | (60 . font-lock-doc-face) | ||
| 449 | (61 . font-lock-constant-face) | ||
| 450 | (80 . font-lock-doc-face)))) | ||
| 451 | |||
| 452 | (ert-deftest python-font-lock-raw-escape-sequence () | ||
| 453 | (python-tests-assert-faces | ||
| 454 | "rb'\\x12 \123 \\n' | ||
| 455 | r'\\x12 \123 \\n \\u1234 \\U00010348 \\N{Plus-Minus Sign}'" | ||
| 456 | '((1) | ||
| 457 | (3 . font-lock-doc-face) (14) | ||
| 458 | (16 . font-lock-doc-face)))) | ||
| 459 | |||
| 383 | 460 | ||
| 384 | ;;; Indentation | 461 | ;;; Indentation |
| 385 | 462 | ||