aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorElías Gabriel Pérez2025-12-10 10:05:44 -0600
committerJuri Linkov2025-12-12 09:23:53 +0200
commitef73f5c25430c43bd4e87aabcdb5e880d933d026 (patch)
treee814a078fa367c4ead6e38719eab766666d42bc3 /test
parentcc4f23302c9616b3a0ef5f5f3340befbb62cb583 (diff)
downloademacs-ef73f5c25430c43bd4e87aabcdb5e880d933d026.tar.gz
emacs-ef73f5c25430c43bd4e87aabcdb5e880d933d026.zip
; * lisp/progmodes/hideshow.el (hs-cycle): Fix regression. (Bug#79983)
* test/lisp/progmodes/hideshow-tests.el (hideshow-cycle-with-delimiters) (hideshow-cycle-without-delimiters) (hideshow-check-unbalanced-parens): Add new tests.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/hideshow-tests.el84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/lisp/progmodes/hideshow-tests.el b/test/lisp/progmodes/hideshow-tests.el
index 39161f2455c..49f661a2390 100644
--- a/test/lisp/progmodes/hideshow-tests.el
+++ b/test/lisp/progmodes/hideshow-tests.el
@@ -342,6 +342,90 @@ main()
342 (funcall call-at "}") 342 (funcall call-at "}")
343 (should (string= (hideshow-tests-visible-string) contents))))) 343 (should (string= (hideshow-tests-visible-string) contents)))))
344 344
345(ert-deftest hideshow-cycle-with-delimiters ()
346 "Should cycle the visibility of a block with delimiters."
347 (let ((contents "
348int
349main ()
350{
351 {
352 {
353 }
354 }
355}
356"))
357 (hideshow-tests-with-temp-buffer
358 c-mode
359 contents
360 (hideshow-tests-look-at "{")
361 (hs-cycle 1)
362 (should (string=
363 (hideshow-tests-visible-string)
364 "
365int
366main ()
367{}
368"))
369 (hs-cycle 1)
370 (should (string=
371 (hideshow-tests-visible-string)
372 "
373int
374main ()
375{
376 {}
377}
378"))
379 (hs-cycle 1)
380 (should (string=
381 (hideshow-tests-visible-string)
382 contents)))))
383
384(ert-deftest hideshow-cycle-without-delimiters ()
385 "Should cycle the visibility of a block without delimiters."
386 (let ((contents "
387def test1 ():
388 def test2 ():
389 def test3():
390"))
391 (hideshow-tests-with-temp-buffer
392 python-mode
393 contents
394 (hideshow-tests-look-at "test1")
395 (hs-cycle 1)
396 (should (string=
397 (hideshow-tests-visible-string)
398 "
399def test1 ():
400"))
401 (hs-cycle 1)
402 (should (string=
403 (hideshow-tests-visible-string)
404 "
405def test1 ():
406 def test2 ():
407"))
408 (hs-cycle 1)
409 (should (string=
410 (hideshow-tests-visible-string)
411 contents)))))
412
413(ert-deftest hideshow-check-unbalanced-parens ()
414 (let ((contents "
415(defun test1 ())
416
417(defun test2
418"))
419 (hideshow-tests-with-temp-buffer
420 c-mode
421 contents
422 (hideshow-tests-look-at "test1")
423 (beginning-of-line)
424 (should (hs-block-positions))
425 (hideshow-tests-look-at "test2")
426 (beginning-of-line)
427 (should-not (hs-block-positions)))))
428
345(provide 'hideshow-tests) 429(provide 'hideshow-tests)
346 430
347;;; hideshow-tests.el ends here 431;;; hideshow-tests.el ends here