diff options
| author | Laurence Warne | 2022-08-09 08:33:18 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-08-09 19:21:36 +0200 |
| commit | b92e88875802724af9e08201ea65a96dd5f20ff1 (patch) | |
| tree | 9a0136781ddab7618c4752d60c1c84830a07d95a /test/lisp/progmodes/python-tests.el | |
| parent | 3ef18c7a213f4f3c03eec033fcb8219fb17cd53d (diff) | |
| download | emacs-b92e88875802724af9e08201ea65a96dd5f20ff1.tar.gz emacs-b92e88875802724af9e08201ea65a96dd5f20ff1.zip | |
Fix python escape code fontification for multi-line literals
* lisp/progmodes/python.el (python--string-bytes-literal-matcher): Go
backward one char after a match so that consecutive escape codes are
highlighted
(python--not-raw-string-literal-start-regexp): Make regular expression
more comprehensive, so multi-line bytes literals are not caught
(python-rx): Accept one to three octal digits in octal escape codes
instead of always three
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 95 |
1 files changed, 87 insertions, 8 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index e3c8d5554a1..d303050fad9 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -407,6 +407,81 @@ u\"\\n\"" | |||
| 407 | (31 . font-lock-constant-face) | 407 | (31 . font-lock-constant-face) |
| 408 | (33 . font-lock-string-face)))) | 408 | (33 . font-lock-string-face)))) |
| 409 | 409 | ||
| 410 | (ert-deftest python-font-lock-escape-sequence-multiline-string () | ||
| 411 | (python-tests-assert-faces | ||
| 412 | (let ((escape-sequences "\\x12 \123 \\n \\u1234 \\U00010348 \\N{Plus-Minus Sign}")) | ||
| 413 | (cl-loop for string-prefix in '("" "f" "rf" "fr" "r" "rb" "br" "b") | ||
| 414 | concat (cl-loop for quote-string in '("\"\"\"" "'''") | ||
| 415 | concat (concat string-prefix | ||
| 416 | quote-string | ||
| 417 | escape-sequences | ||
| 418 | quote-string | ||
| 419 | "\n")))) | ||
| 420 | '((1 . font-lock-doc-face) | ||
| 421 | (4 . font-lock-constant-face) | ||
| 422 | (8 . font-lock-doc-face) | ||
| 423 | (11 . font-lock-constant-face) | ||
| 424 | (13 . font-lock-doc-face) | ||
| 425 | (14 . font-lock-constant-face) | ||
| 426 | (20 . font-lock-doc-face) | ||
| 427 | (21 . font-lock-constant-face) | ||
| 428 | (31 . font-lock-doc-face) | ||
| 429 | (32 . font-lock-constant-face) | ||
| 430 | (51 . font-lock-doc-face) (54) | ||
| 431 | (55 . font-lock-doc-face) | ||
| 432 | (58 . font-lock-constant-face) | ||
| 433 | (62 . font-lock-doc-face) | ||
| 434 | (65 . font-lock-constant-face) | ||
| 435 | (67 . font-lock-doc-face) | ||
| 436 | (68 . font-lock-constant-face) | ||
| 437 | (74 . font-lock-doc-face) | ||
| 438 | (75 . font-lock-constant-face) | ||
| 439 | (85 . font-lock-doc-face) | ||
| 440 | (86 . font-lock-constant-face) | ||
| 441 | (105 . font-lock-doc-face) (108) | ||
| 442 | (110 . font-lock-string-face) | ||
| 443 | (113 . font-lock-constant-face) | ||
| 444 | (117 . font-lock-string-face) | ||
| 445 | (120 . font-lock-constant-face) | ||
| 446 | (122 . font-lock-string-face) | ||
| 447 | (123 . font-lock-constant-face) | ||
| 448 | (129 . font-lock-string-face) | ||
| 449 | (130 . font-lock-constant-face) | ||
| 450 | (140 . font-lock-string-face) | ||
| 451 | (141 . font-lock-constant-face) | ||
| 452 | (160 . font-lock-string-face) (163) | ||
| 453 | (165 . font-lock-string-face) | ||
| 454 | (168 . font-lock-constant-face) | ||
| 455 | (172 . font-lock-string-face) | ||
| 456 | (175 . font-lock-constant-face) | ||
| 457 | (177 . font-lock-string-face) | ||
| 458 | (178 . font-lock-constant-face) | ||
| 459 | (184 . font-lock-string-face) | ||
| 460 | (185 . font-lock-constant-face) | ||
| 461 | (195 . font-lock-string-face) | ||
| 462 | (196 . font-lock-constant-face) | ||
| 463 | (215 . font-lock-string-face) (218) | ||
| 464 | (221 . font-lock-string-face) (274) | ||
| 465 | (277 . font-lock-string-face) (330) | ||
| 466 | (333 . font-lock-string-face) (386) | ||
| 467 | (389 . font-lock-string-face) (442) | ||
| 468 | (444 . font-lock-string-face) (497) | ||
| 469 | (499 . font-lock-string-face) (552) | ||
| 470 | (555 . font-lock-string-face) (608) | ||
| 471 | (611 . font-lock-string-face) (664) | ||
| 472 | (667 . font-lock-string-face) (720) | ||
| 473 | (723 . font-lock-string-face) (776) | ||
| 474 | (778 . font-lock-string-face) | ||
| 475 | (781 . font-lock-constant-face) | ||
| 476 | (785 . font-lock-string-face) | ||
| 477 | (788 . font-lock-constant-face) | ||
| 478 | (790 . font-lock-string-face) (831) | ||
| 479 | (833 . font-lock-string-face) | ||
| 480 | (836 . font-lock-constant-face) | ||
| 481 | (840 . font-lock-string-face) | ||
| 482 | (843 . font-lock-constant-face) | ||
| 483 | (845 . font-lock-string-face) (886)))) | ||
| 484 | |||
| 410 | (ert-deftest python-font-lock-escape-sequence-bytes-newline () | 485 | (ert-deftest python-font-lock-escape-sequence-bytes-newline () |
| 411 | (python-tests-assert-faces | 486 | (python-tests-assert-faces |
| 412 | "b'\\n' | 487 | "b'\\n' |
| @@ -421,19 +496,23 @@ b\"\\n\"" | |||
| 421 | 496 | ||
| 422 | (ert-deftest python-font-lock-escape-sequence-hex-octal () | 497 | (ert-deftest python-font-lock-escape-sequence-hex-octal () |
| 423 | (python-tests-assert-faces | 498 | (python-tests-assert-faces |
| 424 | "b'\\x12 \\777' | 499 | "b'\\x12 \\777 \\1\\23' |
| 425 | '\\x12 \\777'" | 500 | '\\x12 \\777 \\1\\23'" |
| 426 | '((1) | 501 | '((1) |
| 427 | (2 . font-lock-doc-face) | 502 | (2 . font-lock-doc-face) |
| 428 | (3 . font-lock-constant-face) | 503 | (3 . font-lock-constant-face) |
| 429 | (7 . font-lock-doc-face) | 504 | (7 . font-lock-doc-face) |
| 430 | (8 . font-lock-constant-face) | 505 | (8 . font-lock-constant-face) |
| 431 | (12 . font-lock-doc-face) (13) | 506 | (12 . font-lock-doc-face) |
| 432 | (14 . font-lock-doc-face) | 507 | (13 . font-lock-constant-face) |
| 433 | (15 . font-lock-constant-face) | 508 | (18 . font-lock-doc-face) (19) |
| 434 | (19 . font-lock-doc-face) | 509 | (20 . font-lock-doc-face) |
| 435 | (20 . font-lock-constant-face) | 510 | (21 . font-lock-constant-face) |
| 436 | (24 . font-lock-doc-face)))) | 511 | (25 . font-lock-doc-face) |
| 512 | (26 . font-lock-constant-face) | ||
| 513 | (30 . font-lock-doc-face) | ||
| 514 | (31 . font-lock-constant-face) | ||
| 515 | (36 . font-lock-doc-face)))) | ||
| 437 | 516 | ||
| 438 | (ert-deftest python-font-lock-escape-sequence-unicode () | 517 | (ert-deftest python-font-lock-escape-sequence-unicode () |
| 439 | (python-tests-assert-faces | 518 | (python-tests-assert-faces |