X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=tests%2Fautomated%2Flisp-tests.el;h=1fba118beaaacba69192cabb11e7959cb85652d1;hp=3ee719bb7a8c49aae18ec483f0c3e6e9eb92bd52;hb=46f51e794ddb493a8a76ec2f3be00b41e3b0be22;hpb=eea9306cd823bc2679588c209015eba3098be0ec diff --git a/tests/automated/lisp-tests.el b/tests/automated/lisp-tests.el index 3ee719b..1fba118 100644 --- a/tests/automated/lisp-tests.el +++ b/tests/automated/lisp-tests.el @@ -229,6 +229,8 @@ (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 (-)) @@ -253,6 +255,9 @@ (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 @@ -750,6 +755,29 @@ (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 ;;----------------------------------------------------- @@ -802,3 +830,34 @@ (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)) + )