[uim-commit] r2782 - in branches/r5rs/sigscheme: . test

yamaken at freedesktop.org yamaken at freedesktop.org
Wed Jan 4 09:30:41 PST 2006


Author: yamaken
Date: 2006-01-04 09:30:37 -0800 (Wed, 04 Jan 2006)
New Revision: 2782

Modified:
   branches/r5rs/sigscheme/TODO
   branches/r5rs/sigscheme/operations-srfi60.c
   branches/r5rs/sigscheme/test/test-srfi60.scm
Log:
* sigscheme/operations-srfi60.c
  - (BITWISE_OPERATION_BODY):
    * Fix lacking ENSURE_INT() for leftmost element
    * Replace the never-met error check with SCM_ASSERT()
    * Change args
  - (scm_p_srfi60_logand, scm_p_srfi60_logior, scm_p_srfi60_logxor):
    * Follow the interface change of BITWISE_OPERATION_BODY()
    * Cosmetic change
* sigscheme/test/test-srfi60.scm
  - Add tests for the error condition
* sigscheme/TODO
  - Update


Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO	2006-01-04 16:48:15 UTC (rev 2781)
+++ branches/r5rs/sigscheme/TODO	2006-01-04 17:30:37 UTC (rev 2782)
@@ -12,7 +12,7 @@
 * Fix all destructive expression on macros
 
 * Review and refactor all functions in syntax.c(listran, vectran,
-  qquote_internal, scm_s_quasiquote, scm_s_do), operations-srfi{1,2,8,34,60}.c,
+  qquote_internal, scm_s_quasiquote, scm_s_do), operations-srfi{1,2,8,34}.c,
   encoding.[hc] and *port.[hc] (other files had already been done except for
   the destructive exp on macros)
 

Modified: branches/r5rs/sigscheme/operations-srfi60.c
===================================================================
--- branches/r5rs/sigscheme/operations-srfi60.c	2006-01-04 16:48:15 UTC (rev 2781)
+++ branches/r5rs/sigscheme/operations-srfi60.c	2006-01-04 17:30:37 UTC (rev 2782)
@@ -1,6 +1,6 @@
 /*===========================================================================
  *  FileName : operations-srfi60.c
- *  About    : SRFI-60 integers as bits
+ *  About    : SRFI-60 Integers as Bits
  *
  *  Copyright (C) 2005-2006 YamaKen
  *
@@ -48,23 +48,25 @@
 /*=======================================
   File Local Macro Declarations
 =======================================*/
-#define BITWISE_OPERATION_BODY(op, opstr)                                    \
+#define BITWISE_OPERATION_BODY(op, left, right)                              \
     do {                                                                     \
-        int result = 0;                                                      \
+        int result;                                                          \
+                                                                             \
+        result = 0;                                                          \
         switch (*state) {                                                    \
         case SCM_REDUCE_0:                                                   \
             break;                                                           \
         case SCM_REDUCE_1:                                                   \
-            ENSURE_INT(left);                                                \
+            ENSURE_INT(right);                                               \
             return right;                                                    \
         case SCM_REDUCE_PARTWAY:                                             \
         case SCM_REDUCE_LAST:                                                \
-            /* left is already ensured as int by previous loop */            \
+            ENSURE_INT(left);                                                \
             ENSURE_INT(right);                                               \
             result = (SCM_INT_VALUE(left) op SCM_INT_VALUE(right));          \
             break;                                                           \
         default:                                                             \
-            ERR(opstr ": (internal error) unrecognized state specifier: %d", *state); \
+            SCM_ASSERT(scm_false);                                           \
         }                                                                    \
         return MAKE_INT(result);                                             \
     } while (/* CONSTCOND */ 0)
@@ -94,25 +96,28 @@
 }
 
 /* Bitwise Operations */
-ScmObj scm_p_srfi60_logand(ScmObj left, ScmObj right,
-                           enum ScmReductionState *state)
+ScmObj
+scm_p_srfi60_logand(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
     DECLARE_FUNCTION("logand", reduction_operator);
-    BITWISE_OPERATION_BODY(&, "logand");
+
+    BITWISE_OPERATION_BODY(&, left, right);
 }
 
-ScmObj scm_p_srfi60_logior(ScmObj left, ScmObj right,
-                           enum ScmReductionState *state)
+ScmObj
+scm_p_srfi60_logior(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
     DECLARE_FUNCTION("logior", reduction_operator);
-    BITWISE_OPERATION_BODY(|, "logior");
+
+    BITWISE_OPERATION_BODY(|, left, right);
 }
 
-ScmObj scm_p_srfi60_logxor(ScmObj left, ScmObj right,
-                           enum ScmReductionState *state)
+ScmObj
+scm_p_srfi60_logxor(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
     DECLARE_FUNCTION("logxor", reduction_operator);
-    BITWISE_OPERATION_BODY(^, "logxor");
+
+    BITWISE_OPERATION_BODY(^, left, right);
 }
 
 ScmObj

Modified: branches/r5rs/sigscheme/test/test-srfi60.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-srfi60.scm	2006-01-04 16:48:15 UTC (rev 2781)
+++ branches/r5rs/sigscheme/test/test-srfi60.scm	2006-01-04 17:30:37 UTC (rev 2782)
@@ -31,6 +31,9 @@
 ;;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 (load "test/unittest.scm")
+
+(define tn test-name)
+
 (use srfi-60)
 
 
@@ -39,6 +42,12 @@
 ;;
 
 ;; logand
+(tn "logand invalid form")
+(assert-error (tn) (lambda () (logand #\a)))
+(assert-error (tn) (lambda () (logand #\a 1)))
+(assert-error (tn) (lambda () (logand 1 #\a)))
+(assert-error (tn) (lambda () (logand 1 1 #\a)))
+
 (assert-equal? "logand" 0      (logand))
 (assert-equal? "logand" 0      (logand 0))
 (assert-equal? "logand" #b11   (logand #b11))



More information about the uim-commit mailing list