+
+;;-----------------------------------------------------
+;; Test mapping functions
+;;-----------------------------------------------------
+(Check-Error wrong-type-argument (mapcar #'identity (current-buffer)))
+(Assert (equal (mapcar #'identity load-path) load-path))
+(Assert (equal (mapcar #'identity '(1 2 3)) '(1 2 3)))
+(Assert (equal (mapcar #'identity "123") '(?1 ?2 ?3)))
+(Assert (equal (mapcar #'identity [1 2 3]) '(1 2 3)))
+(Assert (equal (mapcar #'identity #*010) '(0 1 0)))
+
+(let ((z 0) (list (make-list 1000 1)))
+ (mapc (lambda (x) (incf z x)) list)
+ (Assert (eq 1000 z)))
+
+(Check-Error wrong-type-argument (mapvector #'identity (current-buffer)))
+(Assert (equal (mapvector #'identity '(1 2 3)) [1 2 3]))
+(Assert (equal (mapvector #'identity "123") [?1 ?2 ?3]))
+(Assert (equal (mapvector #'identity [1 2 3]) [1 2 3]))
+(Assert (equal (mapvector #'identity #*010) [0 1 0]))
+
+(Check-Error wrong-type-argument (mapconcat #'identity (current-buffer) "foo"))
+(Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3"))
+(Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3"))
+
+;; The following 2 functions used to crash XEmacs via mapcar1().
+;; We don't test the actual values of the mapcar, since they're undefined.
+(Assert
+ (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3))))
+ (mapcar
+ (lambda (y)
+ "Devious evil mapping function"
+ (when (eq (car y) 2) ; go out onto a limb
+ (setcdr x nil) ; cut it off behind us
+ (garbage-collect)) ; are we riding a magic broomstick?
+ (car y)) ; sorry, hard landing
+ x)))
+
+(Assert
+ (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3))))
+ (mapcar
+ (lambda (y)
+ "Devious evil mapping function"
+ (when (eq (car y) 1)
+ (setcdr (cdr x) 42)) ; drop a brick wall onto the freeway
+ (car y))
+ x)))
+
+;;-----------------------------------------------------
+;; Test vector functions
+;;-----------------------------------------------------
+(Assert (equal [1 2 3] [1 2 3]))
+(Assert (equal [] []))
+(Assert (not (equal [1 2 3] [])))
+(Assert (not (equal [1 2 3] [1 2 4])))
+(Assert (not (equal [0 2 3] [1 2 3])))
+(Assert (not (equal [1 2 3] [1 2 3 4])))
+(Assert (not (equal [1 2 3 4] [1 2 3])))
+(Assert (equal (vector 1 2 3) [1 2 3]))
+(Assert (equal (make-vector 3 1) [1 1 1]))
+
+;;-----------------------------------------------------
+;; Test bit-vector functions
+;;-----------------------------------------------------
+(Assert (equal #*010 #*010))
+(Assert (equal #* #*))
+(Assert (not (equal #*010 #*011)))
+(Assert (not (equal #*010 #*)))
+(Assert (not (equal #*110 #*010)))
+(Assert (not (equal #*010 #*0100)))
+(Assert (not (equal #*0101 #*010)))
+(Assert (equal (bit-vector 0 1 0) #*010))
+(Assert (equal (make-bit-vector 3 1) #*111))
+(Assert (equal (make-bit-vector 3 0) #*000))
+
+;;-----------------------------------------------------
+;; Test buffer-local variables used as (ugh!) function parameters
+;;-----------------------------------------------------
+(make-local-variable 'test-emacs-buffer-local-variable)
+(byte-compile
+ (defun test-emacs-buffer-local-parameter (test-emacs-buffer-local-variable)
+ (setq test-emacs-buffer-local-variable nil)))
+(test-emacs-buffer-local-parameter nil)
+
+;;-----------------------------------------------------
+;; Test split-string
+;;-----------------------------------------------------
+;; Hrvoje didn't like these tests so I'm disabling them for now. -sb
+;(Assert (equal (split-string "foo" "") '("" "f" "o" "o" "")))
+;(Assert (equal (split-string "foo" "^") '("" "foo")))
+;(Assert (equal (split-string "foo" "$") '("foo" "")))
+(Assert (equal (split-string "foo,bar" ",") '("foo" "bar")))
+(Assert (equal (split-string ",foo,bar," ",") '("" "foo" "bar" "")))
+(Assert (equal (split-string ",foo,bar," "^,") '("" "foo,bar,")))
+(Assert (equal (split-string ",foo,bar," ",$") '(",foo,bar" "")))
+(Assert (equal (split-string ",foo,,bar," ",") '("" "foo" "" "bar" "")))
+(Assert (equal (split-string "foo,,,bar" ",") '("foo" "" "" "bar")))
+(Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" "")))
+(Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar")))
+(Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" "")))
+
+;;-----------------------------------------------------
+;; Test near-text buffer functions.
+;;-----------------------------------------------------
+(with-temp-buffer
+ (erase-buffer)
+ (Assert (eq (char-before) nil))
+ (Assert (eq (char-before (point)) nil))
+ (Assert (eq (char-before (point-marker)) nil))
+ (Assert (eq (char-before (point) (current-buffer)) nil))
+ (Assert (eq (char-before (point-marker) (current-buffer)) nil))
+ (Assert (eq (char-after) nil))
+ (Assert (eq (char-after (point)) nil))
+ (Assert (eq (char-after (point-marker)) nil))
+ (Assert (eq (char-after (point) (current-buffer)) nil))
+ (Assert (eq (char-after (point-marker) (current-buffer)) nil))
+ (Assert (eq (preceding-char) 0))
+ (Assert (eq (preceding-char (current-buffer)) 0))
+ (Assert (eq (following-char) 0))
+ (Assert (eq (following-char (current-buffer)) 0))
+ (insert "foobar")
+ (Assert (eq (char-before) ?r))
+ (Assert (eq (char-after) nil))
+ (Assert (eq (preceding-char) ?r))
+ (Assert (eq (following-char) 0))
+ (goto-char (point-min))
+ (Assert (eq (char-before) nil))
+ (Assert (eq (char-after) ?f))
+ (Assert (eq (preceding-char) 0))
+ (Assert (eq (following-char) ?f))
+ )