(Assert (= (+ 1.0 1) 2.0))
(Assert (= (+ 1.0 1 1) 3.0))
(Assert (= (+ 1 1 1.0) 3.0))
+(Assert (eq (1+ most-positive-fixnum) most-negative-fixnum))
+(Assert (eq (+ most-positive-fixnum 1) most-negative-fixnum))
;; Test `-'
(Check-Error wrong-number-of-arguments (-))
(Assert (= (- 1.5 1) .5))
(Assert (= (- 1 1.5) (- .5)))
+(Assert (eq (1- most-negative-fixnum) most-positive-fixnum))
+(Assert (eq (- most-negative-fixnum 1) most-positive-fixnum))
+
;; Test `/'
;; Test division by zero errors
(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
;;-----------------------------------------------------
(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))
+ )