Author: yamakenz
Date: Mon Apr 28 21:14:56 2008
New Revision: 5469

Modified:
  trunk/scm/ustr.scm
  trunk/test/test-ustr.scm

Log:
* scm/ustr.scm
* test/test-ustr.scm
 - Merge ustr modifications from the composer branch into trunk as
   follows

$ svn merge -r701:HEAD https://uim.googlecode.com/svn/branches/composer/scm/ustr.scm scm/ustr.scm $ svn merge -r701:HEAD https://uim.googlecode.com/svn/branches/composer/test/test-ustr.scm test/test-ustr.scm

----------------
r1143 | yamaken | 2005-08-06 23:13:53 +0900 (Sat, 06 Aug 2005) | 23 lines

* test/test-ustr.scm
 - (test ustr-new, test ustr-empty?): Follow the recent change of
   internal representation of ustr object
 - All test succeeded

----------------
r968 | yamaken | 2005-07-12 20:26:53 +0900 (Tue, 12 Jul 2005) | 12 lines

* scm/ustr.scm
 - (ustr-dup): Fix broken code caused by the change of object
   representation in r961

----------------
r961 | yamaken | 2005-07-10 03:53:23 +0900 (Sun, 10 Jul 2005) | 7 lines

* scm/ustr.scm
 - Replace ustr record with single cons to get efficient
 - (ustr-rec-spec, record ustr, ustr-new-internal): Removed
 - (ustr-former, ustr-set-former!, ustr-latter, ustr-set-latter!):
   New procedure
 - (ustr-new): Follow the changes

----------------
r760 | yamaken | 2005-03-07 18:29:11 +0900 (Mon, 07 Mar 2005) | 9 lines

* scm/ustr.scm
 - (ustr-dup): New procedure


Modified: trunk/scm/ustr.scm
==============================================================================
--- trunk/scm/ustr.scm  (original)
+++ trunk/scm/ustr.scm  Mon Apr 28 21:14:56 2008
@@ -46,19 +46,24 @@
;; private accessors for use in ustr.scm. Users of ustr should use
;; ustr-former-seq, ustr-set-former-seq!, ustr-latter-seq and
;; ustr-set-latter-seq! instead.
-(define ustr-rec-spec
-  '((former ())  ;; reversed order
-    (latter ())))
-(define-record 'ustr ustr-rec-spec)
-(define ustr-new-internal ustr-new)
+
+;;(define ustr-rec-spec
+;;  '((former ())  ;; reversed order
+;;    (latter ())))
+;;(define-record 'ustr ustr-rec-spec)
+;;(define ustr-new-internal ustr-new)
+(define ustr-former car)
+(define ustr-set-former! set-car!)
+(define ustr-latter cdr)
+(define ustr-set-latter! set-cdr!)

(define ustr-new
  (lambda args
-    (let* ((former-seq (and (not (null? args))
-                           (car args)))
-          (latter-seq (and (not (null? (cdr args)))
-                           (cadr args)))
-          (ustr (ustr-new-internal)))
+    (let ((former-seq (and (not (null? args))
+                          (car args)))
+         (latter-seq (and (not (null? (cdr args)))
+                          (cadr args)))
+         (ustr (cons () ())))
      (and former-seq
           (ustr-set-former-seq! ustr former-seq))
      (and latter-seq
@@ -109,6 +114,14 @@
  (lambda (ustr other)
    (ustr-set-former! ustr (ustr-former other))
    (ustr-set-latter! ustr (ustr-latter other))))
+
+;; TODO: write test
+;; TODO: Rename to ustr-copy to conform to the standard naming
+;; convention of light-record.scm.
+(define ustr-dup
+  (lambda (ustr)
+    (cons (ustr-former ustr)
+         (ustr-latter ustr))))

;; ignores cursor position
(define ustr=

Modified: trunk/test/test-ustr.scm
==============================================================================
--- trunk/test/test-ustr.scm    (original)
+++ trunk/test/test-ustr.scm    Mon Apr 28 21:14:56 2008
@@ -29,7 +29,7 @@
;;; SUCH DAMAGE.
;;;;

-;; These tests are passed at revision 5329 (new repository)
+;; These tests are passed at revision 5469 (new repository)

(use test.unit)

@@ -69,14 +69,14 @@

  ("test ustr-new"
   ;; single sequence goes into former
-   (assert-equal '(("o" "l" "l" "e" "h") ())
+   (assert-equal '(("o" "l" "l" "e" "h") . ())
                 (uim '(ustr-new '("h" "e" "l" "l" "o"))))
   ;; dual sequences are go into former and latter
-   (assert-equal '(("l" "e" "h") ("l" "o"))
+   (assert-equal '(("l" "e" "h") . ("l" "o"))
                 (uim '(ustr-new '("h" "e" "l")
                                 '("l" "o"))))
   ;; latter sequence only
-   (assert-equal '(() ("h" "e" "l" "l" "o"))
+   (assert-equal '(() . ("h" "e" "l" "l" "o"))
                 (uim '(ustr-new ()
                                 '("h" "e" "l" "l" "o")))))

@@ -290,7 +290,7 @@
   (assert-false (uim-bool '(ustr-empty? ustrj-f)))
   (assert-false (uim-bool '(ustr-empty? ustrj-l)))

-   (assert-equal '(() ())
+   (assert-equal '(() . ())
                 (uim 'ustre))
   (assert-true  (uim-bool '(ustr-empty? ustre))))

Reply via email to