time.lsp 2.03 KB
Newer Older
pfdietz's avatar
pfdietz committed
1
2
3
4
5
6
7
8
9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Dec 12 09:43:47 2004
;;;; Contains: Tests of TIME

(in-package :cl-test)

(deftest time.1
  (let ((s (with-output-to-string
sds's avatar
sds committed
10
11
             (*trace-output*)
             (assert (null (time nil))))))
pfdietz's avatar
pfdietz committed
12
13
14
15
16
    (= (length s) 0))
  nil)

(deftest time.2
  (let ((s (with-output-to-string
sds's avatar
sds committed
17
18
19
             (*trace-output*)
             (let ((x (cons 'a 'b)))
               (assert (eq (time x) x))))))
pfdietz's avatar
pfdietz committed
20
21
22
23
24
    (= (length s) 0))
  nil)

(deftest time.3
  (let ((s (with-output-to-string
sds's avatar
sds committed
25
26
27
28
             (*trace-output*)
             (let ((x (cons 'a 'b)))
               (flet ((%f () x))
                 (assert (eq (time (%f)) x)))))))
pfdietz's avatar
pfdietz committed
29
30
31
32
33
    (= (length s) 0))
  nil)

(deftest time.4
  (let ((s (with-output-to-string
sds's avatar
sds committed
34
35
             (*trace-output*)
             (assert (null (multiple-value-list (time (values))))))))
pfdietz's avatar
pfdietz committed
36
37
38
39
40
    (= (length s) 0))
  nil)

(deftest time.5
  (let ((s (with-output-to-string
sds's avatar
sds committed
41
42
43
             (*trace-output*)
             (assert (equal '(a b c d)
                            (multiple-value-list (time (values 'a 'b 'c 'd))))))))
pfdietz's avatar
pfdietz committed
44
45
46
47
48
49
    (= (length s) 0))
  nil)

(deftest time.6
  (let ((fn (compile nil '(lambda () (time nil)))))
    (let ((s (with-output-to-string
sds's avatar
sds committed
50
51
               (*trace-output*)
               (assert (null (funcall fn))))))
pfdietz's avatar
pfdietz committed
52
53
54
55
56
57
      (= (length s) 0)))
  nil)

(deftest time.7
  (flet ((%f () (time nil)))
    (let ((s (with-output-to-string
sds's avatar
sds committed
58
59
               (*trace-output*)
               (assert (null (%f))))))
pfdietz's avatar
pfdietz committed
60
61
62
63
64
      (= (length s) 0)))
  nil)

(deftest time.8
  (let ((s (with-output-to-string
sds's avatar
sds committed
65
66
67
             (*trace-output*)
             (macrolet ((%m () 1))
               (assert (eql (time (%m)) 1))))))
pfdietz's avatar
pfdietz committed
68
69
70
    (= (length s) 0))
  nil)

pfdietz's avatar
pfdietz committed
71
72
73
74
;;; The TIME definition is weasely, so strenuous complaints from
;;; implementors about specific tests lead me to remove them.
;;; Someone didn't like this one at all.
#|
pfdietz's avatar
pfdietz committed
75
76
(deftest time.9
  (let ((s (with-output-to-string
sds's avatar
sds committed
77
78
79
             (*trace-output*)
             (block done
               (time (return-from done nil))))))
pfdietz's avatar
pfdietz committed
80
81
    (= (length s) 0))
  nil)
pfdietz's avatar
pfdietz committed
82
|#
pfdietz's avatar
pfdietz committed
83

sds's avatar
sds committed
84