annotate tests/basic-lisp.el @ 316:512e409c26a2 r21-0b56

Import from CVS: tag r21-0b56
author cvs
date Mon, 13 Aug 2007 10:44:46 +0200
parents c5d627a313b1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
1 ;;; Test basic Lisp functionality
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
2
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
3 ;;(when (not (boundp 'foo)) (setq foo 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
4 ;;(incf foo)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
5 ;;(print foo)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
6
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
7 (let ((my-vector [1 2 3 4])
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
8 (my-bit-vector (bit-vector 1 0 1 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
9 (my-string "1234")
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
10 (my-list '(1 2 3 4)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
11
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
12 ;;(Assert (fooooo)) ;; Generate Other failure
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
13 ;;(Assert (eq 1 2)) ;; Generate Assertion failure
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
14
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
15 (Assert (eq (elt my-vector 0) 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
16 (Assert (eq (elt my-bit-vector 0) 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
17 (Assert (eq (elt my-string 0) ?1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
18 (Assert (eq (elt my-list 0) 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
19
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
20 (Assert (eq 4 (length my-vector)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
21 (Assert (eq 4 (length my-bit-vector)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
22 (Assert (eq 4 (length my-string)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
23
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
24 (fillarray my-vector 5)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
25 (fillarray my-bit-vector 1)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
26 (fillarray my-string ?5)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
27
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
28 (Assert (eq 4 (length my-vector)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
29 (Assert (eq 4 (length my-bit-vector)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
30 (Assert (eq 4 (length my-string)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
31
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
32 (Assert (eq (elt my-vector 0) 5))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
33 (Assert (eq (elt my-bit-vector 0) 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
34 (Assert (eq (elt my-string 0) ?5))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
35
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
36 (Assert (eq (elt my-vector 3) 5))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
37 (Assert (eq (elt my-bit-vector 3) 1))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
38 (Assert (eq (elt my-string 3) ?5))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
39
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
40 (fillarray my-bit-vector 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
41 (Assert (eq 4 (length my-bit-vector)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
42 (Assert (eq (elt my-bit-vector 2) 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
43
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
44 ;; Test nconc
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
45 (let ((x (list 0 1 2)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
46 (Assert (eq (nconc) nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
47 (Assert (eq (nconc nil) nil))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
48 (Assert (eq (nconc nil x) x))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
49 (Assert (eq (nconc x nil) x))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
50 (let ((y (nconc x nil (list 3 4 5) nil)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
51 (Assert (eq (length y) 6))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
52 (Assert (eq (nth 3 y) 3))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
53 ))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
54 )
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
55
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
56 ;;; Old cruft
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
57 ;;;(run-tests)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
58
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
59 ;(defmacro Assert (assertion)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
60 ; `(condition-case error
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
61 ; (progn
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
62 ; (assert ,assertion)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
63 ; (princ (format "Assertion passed: %S" (quote ,assertion)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
64 ; (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
65 ; (incf Assert-successes))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
66 ; (cl-assertion-failed
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
67 ; (princ (format "Assertion failed: %S" (quote ,assertion)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
68 ; (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
69 ; (incf Assert-failures))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
70 ; (t (princ (format "Test harness error: %S" error))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
71 ; (terpri)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
72 ; (incf Harness-failures)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
73 ; )))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
74
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
75
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
76 ;(defun run-tests ()
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
77 ; (with-output-to-temp-buffer "*Test-Log*"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
78 ; (let ((Assert-successes 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
79 ; (Assert-failures 0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
80 ; (Harness-failures 0))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
81 ; (basic-lisp-test)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
82 ; (byte-compile 'basic-lisp-test)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
83 ; (basic-lisp-test)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
84 ; (print (format "%d successes, %d assertion failures, %d harness failures"
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
85 ; Assert-successes
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
86 ; Assert-failures
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
87 ; Harness-failures)))))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
88
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
89 ;(defun the-test ()