[climacs-cvs] CVS update: climacs/Persistent/README climacs/Persistent/persistent-base-test.lisp climacs/Persistent/persistent-buffer-test.lisp climacs/Persistent/persistent-buffer.lisp
Aleksandar Bakic
abakic at common-lisp.net
Fri Jan 28 18:47:47 UTC 2005
Update of /project/climacs/cvsroot/climacs/Persistent
In directory common-lisp.net:/tmp/cvs-serv31513/Persistent
Modified Files:
README persistent-base-test.lisp persistent-buffer-test.lisp
persistent-buffer.lisp
Log Message:
Changed downcase, upcase and capitalize methods to be symmetrical wrt. marks.
Added (setf buffer-object) methods to binseq-buffer and obinseq-buffer.
More tests and comments.
Date: Fri Jan 28 10:47:37 2005
Author: abakic
Index: climacs/Persistent/README
diff -u climacs/Persistent/README:1.1 climacs/Persistent/README:1.2
--- climacs/Persistent/README:1.1 Wed Jan 26 08:10:45 2005
+++ climacs/Persistent/README Fri Jan 28 10:47:34 2005
@@ -20,8 +20,8 @@
(setf (offset mark) offset)))
(It is currently "broken" for performance reasons.) Until then,
-(o)binseq-end-of-line and (o)binseq-next-line tests will fail (20 of
-them).
+(o)binseq-end-of-line, (o)binseq-next-line and (o)binseq-kill-line
+tests will fail (20 of them).
NOTE: There is a dependency of Persistent/persistent-buffer.lisp on
Flexichain/utilities.lisp (the weak pointer handling).
Index: climacs/Persistent/persistent-base-test.lisp
diff -u climacs/Persistent/persistent-base-test.lisp:1.2 climacs/Persistent/persistent-base-test.lisp:1.3
--- climacs/Persistent/persistent-base-test.lisp:1.2 Wed Jan 26 10:28:56 2005
+++ climacs/Persistent/persistent-base-test.lisp Fri Jan 28 10:47:34 2005
@@ -620,6 +620,154 @@
(climacs-base::previous-word m2))))
"climacs" #() "cl")
+(deftest binseq-buffer-downcase-buffer-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "Cli mac5")
+ (climacs-base::downcase-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "cli mac5")
+
+(deftest binseq-buffer-downcase-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (downcase-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest binseq-buffer-downcase-region.test-2
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (downcase-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest binseq-buffer-downcase-region.test-3
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (downcase-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest binseq-buffer-downcase-word.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "CLI MA CS")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (downcase-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "cli ma cs" 9)
+
+(deftest binseq-buffer-upcase-buffer-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "Cli mac5")
+ (climacs-base::upcase-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "CLI MAC5")
+
+(deftest binseq-buffer-upcase-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (upcase-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest binseq-buffer-upcase-region.test-2
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (upcase-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest binseq-buffer-upcase-region.test-3
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (upcase-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest binseq-buffer-upcase-word.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (upcase-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "CLI MA CS" 9)
+
+(deftest binseq-buffer-capitalize-buffer-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (climacs-base::capitalize-buffer-region buffer 1 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "cli Ma Cs")
+
+(deftest binseq-buffer-capitalize-buffer-region.test-2
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "CLI mA Cs")
+ (climacs-base::capitalize-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "Cli Ma Cs")
+
+(deftest binseq-buffer-capitalize-region.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (capitalize-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest binseq-buffer-capitalize-region.test-2
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (capitalize-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest binseq-buffer-capitalize-region.test-3
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (capitalize-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest binseq-buffer-capitalize-word.test-1
+ (let ((buffer (make-instance 'binseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (capitalize-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "Cli Ma Cs" 9)
+
;;; obinseq tests
(deftest obinseq-buffer-previous-line.test-1
@@ -1219,3 +1367,151 @@
(climacs-base::previous-word m1)
(climacs-base::previous-word m2))))
"climacs" #() "cl")
+
+(deftest obinseq-buffer-downcase-buffer-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "Cli mac5")
+ (climacs-base::downcase-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "cli mac5")
+
+(deftest obinseq-buffer-downcase-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (downcase-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest obinseq-buffer-downcase-region.test-2
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (downcase-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest obinseq-buffer-downcase-region.test-3
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (downcase-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_cli mac5_")
+
+(deftest obinseq-buffer-downcase-word.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "CLI MA CS")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (downcase-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "cli ma cs" 9)
+
+(deftest obinseq-buffer-upcase-buffer-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "Cli mac5")
+ (climacs-base::upcase-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "CLI MAC5")
+
+(deftest obinseq-buffer-upcase-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (upcase-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest obinseq-buffer-upcase-region.test-2
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (upcase-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest obinseq-buffer-upcase-region.test-3
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (upcase-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_CLI MAC5_")
+
+(deftest obinseq-buffer-upcase-word.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (upcase-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "CLI MA CS" 9)
+
+(deftest obinseq-buffer-capitalize-buffer-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (climacs-base::capitalize-buffer-region buffer 1 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "cli Ma Cs")
+
+(deftest obinseq-buffer-capitalize-buffer-region.test-2
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "CLI mA Cs")
+ (climacs-base::capitalize-buffer-region buffer 0 (size buffer))
+ (buffer-sequence buffer 0 (size buffer)))
+ "Cli Ma Cs")
+
+(deftest obinseq-buffer-capitalize-region.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 1))
+ (m2 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 8)))
+ (capitalize-region m2 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest obinseq-buffer-capitalize-region.test-2
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 1)))
+ (capitalize-region 8 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest obinseq-buffer-capitalize-region.test-3
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "_Cli mac5_")
+ (let ((m1 (make-instance 'persistent-left-sticky-mark
+ :buffer buffer :offset 8)))
+ (capitalize-region 1 m1)
+ (buffer-sequence buffer 0 (size buffer))))
+ "_Cli Mac5_")
+
+(deftest obinseq-buffer-capitalize-word.test-1
+ (let ((buffer (make-instance 'obinseq-buffer)))
+ (insert-buffer-sequence buffer 0 "cli ma cs")
+ (let ((m (make-instance 'persistent-right-sticky-mark
+ :buffer buffer :offset 0)))
+ (capitalize-word m 3)
+ (values
+ (buffer-sequence buffer 0 (size buffer))
+ (offset m))))
+ "Cli Ma Cs" 9)
\ No newline at end of file
Index: climacs/Persistent/persistent-buffer-test.lisp
diff -u climacs/Persistent/persistent-buffer-test.lisp:1.2 climacs/Persistent/persistent-buffer-test.lisp:1.3
--- climacs/Persistent/persistent-buffer-test.lisp:1.2 Wed Jan 26 10:28:56 2005
+++ climacs/Persistent/persistent-buffer-test.lisp Fri Jan 28 10:47:34 2005
@@ -75,22 +75,37 @@
(deftest binseq-buffer-insert-buffer-object.test-1
(let ((buffer (make-instance 'binseq-buffer)))
(insert-buffer-object buffer 0 #\a)
- (and (= (size buffer) 1) (buffer-sequence buffer 0 1)))
- "a")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 1)))
+ 0 1 t 1 "a")
(deftest binseq-buffer-insert-buffer-object.test-2
(let ((buffer (make-instance 'binseq-buffer)))
(insert-buffer-object buffer 0 #\b)
(insert-buffer-object buffer 0 #\a)
- (and (= (size buffer) 2) (buffer-sequence buffer 0 2)))
- "ab")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 2)))
+ 0 2 t 2 "ab")
(deftest binseq-buffer-insert-buffer-object.test-3
(let ((buffer (make-instance 'binseq-buffer)))
(insert-buffer-object buffer 0 #\b)
(insert-buffer-object buffer 1 #\a)
- (and (= (size buffer) 2) (buffer-sequence buffer 0 2)))
- "ba")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 2)))
+ 0 2 t 2 "ba")
(deftest binseq-buffer-insert-buffer-object.test-4
(handler-case
@@ -154,15 +169,24 @@
(let ((buffer (make-instance 'binseq-buffer)))
(insert-buffer-sequence buffer 0 "climacs")
(delete-buffer-range buffer 0 7)
- (size buffer))
- 0)
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)))
+ 0 0 t 0)
(deftest binseq-buffer-delete-buffer-range.test-2
(let ((buffer (make-instance 'binseq-buffer)))
(insert-buffer-sequence buffer 0 "climacs")
(delete-buffer-range buffer 0 3)
- (and (= (size buffer) 4) (buffer-sequence buffer 0 4)))
- "macs")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 4)))
+ 0 4 t 4 "macs")
(deftest binseq-buffer-delete-buffer-range.test-3
(let ((buffer (make-instance 'binseq-buffer)))
@@ -780,22 +804,37 @@
(deftest obinseq-buffer-insert-buffer-object.test-1
(let ((buffer (make-instance 'obinseq-buffer)))
(insert-buffer-object buffer 0 #\a)
- (and (= (size buffer) 1) (buffer-sequence buffer 0 1)))
- "a")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 1)))
+ 0 1 t 1 "a")
(deftest obinseq-buffer-insert-buffer-object.test-2
(let ((buffer (make-instance 'obinseq-buffer)))
(insert-buffer-object buffer 0 #\b)
(insert-buffer-object buffer 0 #\a)
- (and (= (size buffer) 2) (buffer-sequence buffer 0 2)))
- "ab")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 2)))
+ 0 2 t 2 "ab")
(deftest obinseq-buffer-insert-buffer-object.test-3
(let ((buffer (make-instance 'obinseq-buffer)))
(insert-buffer-object buffer 0 #\b)
(insert-buffer-object buffer 1 #\a)
- (and (= (size buffer) 2) (buffer-sequence buffer 0 2)))
- "ba")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 2)))
+ 0 2 t 2 "ba")
(deftest obinseq-buffer-insert-buffer-object.test-4
(handler-case
@@ -859,15 +898,24 @@
(let ((buffer (make-instance 'obinseq-buffer)))
(insert-buffer-sequence buffer 0 "climacs")
(delete-buffer-range buffer 0 7)
- (size buffer))
- 0)
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)))
+ 0 0 t 0)
(deftest obinseq-buffer-delete-buffer-range.test-2
(let ((buffer (make-instance 'obinseq-buffer)))
(insert-buffer-sequence buffer 0 "climacs")
(delete-buffer-range buffer 0 3)
- (and (= (size buffer) 4) (buffer-sequence buffer 0 4)))
- "macs")
+ (values
+ (offset (low-mark buffer))
+ (offset (high-mark buffer))
+ (modified-p buffer)
+ (size buffer)
+ (buffer-sequence buffer 0 4)))
+ 0 4 t 4 "macs")
(deftest obinseq-buffer-delete-buffer-range.test-3
(let ((buffer (make-instance 'obinseq-buffer)))
Index: climacs/Persistent/persistent-buffer.lisp
diff -u climacs/Persistent/persistent-buffer.lisp:1.2 climacs/Persistent/persistent-buffer.lisp:1.3
--- climacs/Persistent/persistent-buffer.lisp:1.2 Wed Jan 26 10:28:56 2005
+++ climacs/Persistent/persistent-buffer.lisp Fri Jan 28 10:47:36 2005
@@ -197,10 +197,22 @@
(make-condition 'no-such-offset :offset offset))
(binseq-get (slot-value buffer 'contents) offset))
+(defmethod (setf buffer-object) (object (buffer binseq-buffer) offset)
+ (assert (<= 0 offset (1- (size buffer))) ()
+ (make-condition 'no-such-offset :offset offset))
+ (setf (slot-value buffer 'contents)
+ (binseq-set (slot-value buffer 'contents) offset object)))
+
(defmethod buffer-object ((buffer obinseq-buffer) offset)
(assert (<= 0 offset (1- (size buffer))) ()
(make-condition 'no-such-offset :offset offset))
(obinseq-get (slot-value buffer 'contents) offset))
+
+(defmethod (setf buffer-object) (object (buffer obinseq-buffer) offset)
+ (assert (<= 0 offset (1- (size buffer))) ()
+ (make-condition 'no-such-offset :offset offset))
+ (setf (slot-value buffer 'contents)
+ (obinseq-set (slot-value buffer 'contents) offset object)))
(defmethod buffer-sequence ((buffer binseq-buffer) offset1 offset2)
(assert (<= 0 offset1 (size buffer)) ()
More information about the Climacs-cvs
mailing list