diff options
| author | Andrea Corallo | 2020-07-15 23:01:11 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-07-15 23:13:36 +0200 |
| commit | 2c2cc21f1be721e5ba30fa22aedeb5c254791193 (patch) | |
| tree | 434ba225fa6a14dba4a35bfe2c55ce8aefca2c0c /test/src | |
| parent | 82169a3d97014c3eae5e7bad4aabb9220dd26b3b (diff) | |
| download | emacs-2c2cc21f1be721e5ba30fa22aedeb5c254791193.tar.gz emacs-2c2cc21f1be721e5ba30fa22aedeb5c254791193.zip | |
Add a testcase for bug#42360
* test/src/comp-tests.el (comp-test-42360): New testcase.
* test/src/comp-test-funcs.el (comp-test-42360-f): New function.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/comp-test-funcs.el | 47 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 5 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index 2fe6276227a..fe9943a1b91 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el | |||
| @@ -290,6 +290,53 @@ | |||
| 290 | (declare (speed -1)) | 290 | (declare (speed -1)) |
| 291 | 3) | 291 | 3) |
| 292 | 292 | ||
| 293 | (defun comp-test-42360-f (str end-column | ||
| 294 | &optional start-column padding ellipsis | ||
| 295 | ellipsis-text-property) | ||
| 296 | ;; From `truncate-string-to-width'. A large enough function to | ||
| 297 | ;; potentially use all registers and that is modifying local | ||
| 298 | ;; variables inside condition-case. | ||
| 299 | (let ((str-len (length str)) | ||
| 300 | (str-width 14) | ||
| 301 | (ellipsis-width 3) | ||
| 302 | (idx 0) | ||
| 303 | (column 0) | ||
| 304 | (head-padding "") (tail-padding "") | ||
| 305 | ch last-column last-idx from-idx) | ||
| 306 | (condition-case nil | ||
| 307 | (while (< column start-column) | ||
| 308 | (setq ch (aref str idx) | ||
| 309 | column (+ column (char-width ch)) | ||
| 310 | idx (1+ idx))) | ||
| 311 | (args-out-of-range (setq idx str-len))) | ||
| 312 | (if (< column start-column) | ||
| 313 | (if padding (make-string end-column padding) "") | ||
| 314 | (when (and padding (> column start-column)) | ||
| 315 | (setq head-padding (make-string (- column start-column) padding))) | ||
| 316 | (setq from-idx idx) | ||
| 317 | (when (>= end-column column) | ||
| 318 | (condition-case nil | ||
| 319 | (while (< column end-column) | ||
| 320 | (setq last-column column | ||
| 321 | last-idx idx | ||
| 322 | ch (aref str idx) | ||
| 323 | column (+ column (char-width ch)) | ||
| 324 | idx (1+ idx))) | ||
| 325 | (args-out-of-range (setq idx str-len))) | ||
| 326 | (when (> column end-column) | ||
| 327 | (setq column last-column | ||
| 328 | idx last-idx)) | ||
| 329 | (when (and padding (< column end-column)) | ||
| 330 | (setq tail-padding (make-string (- end-column column) padding)))) | ||
| 331 | (if (and ellipsis-text-property | ||
| 332 | (not (equal ellipsis "")) | ||
| 333 | idx) | ||
| 334 | (concat head-padding | ||
| 335 | (substring str from-idx idx) | ||
| 336 | (propertize (substring str idx) 'display (or ellipsis ""))) | ||
| 337 | (concat head-padding (substring str from-idx idx) | ||
| 338 | tail-padding ellipsis))))) | ||
| 339 | |||
| 293 | 340 | ||
| 294 | ;;;;;;;;;;;;;;;;;;;; | 341 | ;;;;;;;;;;;;;;;;;;;; |
| 295 | ;; Tromey's tests ;; | 342 | ;; Tromey's tests ;; |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 8f0b90f8e01..092504565a6 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -363,6 +363,11 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 363 | (should (= (comp-test-speed--1-f) 3)) | 363 | (should (= (comp-test-speed--1-f) 3)) |
| 364 | (should-not (subr-native-elisp-p (symbol-function #'comp-test-speed--1-f)))) | 364 | (should-not (subr-native-elisp-p (symbol-function #'comp-test-speed--1-f)))) |
| 365 | 365 | ||
| 366 | (ert-deftest comp-test-42360 () | ||
| 367 | "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-07/msg00418.html>." | ||
| 368 | (should (string= (comp-test-42360-f "Nel mezzo del " 18 0 32 "yyy" nil) | ||
| 369 | "Nel mezzo del yyy"))) | ||
| 370 | |||
| 366 | 371 | ||
| 367 | ;;;;;;;;;;;;;;;;;;;;; | 372 | ;;;;;;;;;;;;;;;;;;;;; |
| 368 | ;; Tromey's tests. ;; | 373 | ;; Tromey's tests. ;; |