diff --git a/mes.c b/mes.c index f3d22f95..a506102f 100644 --- a/mes.c +++ b/mes.c @@ -246,6 +246,7 @@ car_ (SCM x) { return (TYPE (CAR (x)) == PAIR || TYPE (CAR (x)) == REF + || TYPE (CAR (x)) == SPECIAL || TYPE (CAR (x)) == SYMBOL || TYPE (CAR (x)) == STRING) ? CAR (x) : MAKE_NUMBER (CAR (x)); } @@ -255,6 +256,7 @@ cdr_ (SCM x) { return (TYPE (CDR (x)) == PAIR || TYPE (CDR (x)) == REF + || TYPE (CAR (x)) == SPECIAL || TYPE (CDR (x)) == SYMBOL || TYPE (CDR (x)) == STRING) ? CDR (x) : MAKE_NUMBER (CDR (x)); } diff --git a/tests/scm.test b/tests/scm.test index a000aa54..2b4728ed 100755 --- a/tests/scm.test +++ b/tests/scm.test @@ -68,13 +68,24 @@ exit $? (pass-if "=" (seq? 3 '3)) (pass-if "= 2" (not (= 3 '4))) +(pass-if-equal "string-length" + 0 + (string-length "")) +(pass-if-equal "string-length 2" + 3 + (string-length (string-append "a" "b" "c"))) +(pass-if-equal "string->list" + '() + (string->list "")) +(pass-if-equal "string->list 2" + '(#\a #\b #\c #\newline) + (string->list "abc\n")) + (pass-if "string-append" (sequal? (string-append "a" "b" "c") "abc")) (pass-if "substring" (sequal? (substring "hello world" 6) "world")) (pass-if "substring 2" (sequal? (substring "hello world" 4 7) "o w")) (pass-if "string-ref" (seq? (string-ref "hello world" 4) #\o)) (pass-if "eq?" (not (eq? (string-append "a" "b" "c") "abc"))) -(pass-if "string-length" (seq? (string-length (string-append "a" "b" "c")) 3)) -(pass-if-equal "string->list" '(#\a #\b #\c #\newline) (string->list "abc\n")) (pass-if "char" (seq? (char->integer #\A) 65)) (pass-if "char 2" (seq? (char->integer #\101) (char->integer #\A))) (pass-if "char 3" (seq? (integer->char 10) #\newline))