[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/fix-locked-narrowing 2956e54b1d 7/7: Add an extensive test for l
From: |
Gregory Heytings |
Subject: |
scratch/fix-locked-narrowing 2956e54b1d 7/7: Add an extensive test for labeled (locked) narrowing |
Date: |
Wed, 8 Feb 2023 20:49:37 -0500 (EST) |
branch: scratch/fix-locked-narrowing
commit 2956e54b1dda1647a9399211c7d09b208b85dcfa
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>
Add an extensive test for labeled (locked) narrowing
* test/src/buffer-tests.el (test-labeled-narrowing): New test.
---
test/src/buffer-tests.el | 106 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 106 insertions(+)
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 9d4bbf3e04..0ae78c8d9d 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -8539,4 +8539,110 @@ Finally, kill the buffer and its temporary file."
(if f2 (delete-file f2))
)))
+(ert-deftest test-labeled-narrowing ()
+ "Test `with-narrowing' and `without-narrowing'."
+ (with-current-buffer (generate-new-buffer " foo" t)
+ (insert (make-string 5000 ?a))
+ (should (= (point-min) 1))
+ (should (= (point-max) 5001))
+ (with-narrowing
+ 100 500 :label 'foo
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (widen)
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (narrow-to-region 1 5000)
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (narrow-to-region 50 150)
+ (should (= (point-min) 100))
+ (should (= (point-max) 150))
+ (widen)
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (narrow-to-region 400 1000)
+ (should (= (point-min) 400))
+ (should (= (point-max) 500))
+ (without-narrowing
+ :label 'bar
+ (should (= (point-min) 100))
+ (should (= (point-max) 500)))
+ (without-narrowing
+ :label 'foo
+ (should (= (point-min) 1))
+ (should (= (point-max) 5001)))
+ (should (= (point-min) 400))
+ (should (= (point-max) 500))
+ (widen)
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (with-narrowing
+ 50 250 :label 'bar
+ (should (= (point-min) 100))
+ (should (= (point-max) 250))
+ (widen)
+ (should (= (point-min) 100))
+ (should (= (point-max) 250))
+ (without-narrowing
+ :label 'bar
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (without-narrowing
+ :label 'foo
+ (should (= (point-min) 1))
+ (should (= (point-max) 5001)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 500)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 250)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (with-narrowing
+ 50 250 :label 'bar
+ (should (= (point-min) 100))
+ (should (= (point-max) 250))
+ (with-narrowing
+ 150 500 :label 'baz
+ (should (= (point-min) 150))
+ (should (= (point-max) 250))
+ (without-narrowing
+ :label 'bar
+ (should (= (point-min) 150))
+ (should (= (point-max) 250)))
+ (without-narrowing
+ :label 'foo
+ (should (= (point-min) 150))
+ (should (= (point-max) 250)))
+ (without-narrowing
+ :label 'baz
+ (should (= (point-min) 100))
+ (should (= (point-max) 250))
+ (without-narrowing
+ :label 'foo
+ (should (= (point-min) 100))
+ (should (= (point-max) 250)))
+ (without-narrowing
+ :label 'bar
+ (should (= (point-min) 100))
+ (should (= (point-max) 500))
+ (without-narrowing
+ :label 'foobar
+ (should (= (point-min) 100))
+ (should (= (point-max) 500)))
+ (without-narrowing
+ :label 'foo
+ (should (= (point-min) 1))
+ (should (= (point-max) 5001)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 500)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 250)))
+ (should (= (point-min) 150))
+ (should (= (point-max) 250)))
+ (should (= (point-min) 100))
+ (should (= (point-max) 250))))
+ (should (= (point-min) 1))
+ (should (= (point-max) 5001))))
+
;;; buffer-tests.el ends here
- branch scratch/fix-locked-narrowing created (now 2956e54b1d), Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing a4aa32bdff 1/7: Fix 'save-restriction' for narrowing locks, Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing 0d73e4aa26 4/7: Add specific symbols for narrowings, Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing d8438e2bb4 3/7: Add 'without-narrowing' macro, Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing 97314447e6 2/7: Make 'narrowing-lock' and 'narrowing-unlock' internal, Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing 2956e54b1d 7/7: Add an extensive test for labeled (locked) narrowing,
Gregory Heytings <=
- scratch/fix-locked-narrowing a6cd4553d4 5/7: Rename two long line optimizations variables, Gregory Heytings, 2023/02/08
- scratch/fix-locked-narrowing 79ce185ad1 6/7: Update the documentation about labeled (locked) narrowing, Gregory Heytings, 2023/02/08