~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/last.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;-*- Mode:     Lisp -*-
 
2
;;;; Author:   Paul Dietz
 
3
;;;; Created:  Sat Mar 28 07:37:21 1998
 
4
;;;; Contains: Testing of CL Features related to "CONS", part 10
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(compile-and-load "cons-aux.lsp")
 
9
 
 
10
(deftest last.1
 
11
  (last nil)
 
12
  nil)
 
13
 
 
14
(deftest last.2
 
15
  (last (copy-tree '(a b)))
 
16
  (b))
 
17
 
 
18
(deftest last.3
 
19
  (last (copy-tree '(a b . c)))
 
20
  (b . c))
 
21
 
 
22
(deftest last.4
 
23
  (last (copy-tree '(a b c d)) 0)
 
24
  nil)
 
25
 
 
26
(deftest last.5
 
27
  (last (copy-tree '(a b c d)) 1)
 
28
  (d))
 
29
 
 
30
(deftest last.6
 
31
  (last (copy-tree '(a b c d)) 2)
 
32
  (c d))
 
33
 
 
34
(deftest last.7
 
35
  (last (copy-tree '(a b c d)) 5)
 
36
  (a b c d))
 
37
 
 
38
(deftest last.8
 
39
  (last (cons 'a 'b) 0)
 
40
  b)
 
41
 
 
42
(deftest last.9
 
43
  (last (cons 'a 'b) 1)
 
44
  (a . b))
 
45
 
 
46
(deftest last.10
 
47
  (last (cons 'a 'b) 2)
 
48
  (a . b))
 
49
 
 
50
(deftest last.11
 
51
  (let ((x '(a b c)))
 
52
    (eqt (last x (1+ most-positive-fixnum)) x))
 
53
  t)
 
54
 
 
55
(deftest last.12
 
56
  (let ((x '(a b c . d)))
 
57
    (eqt (last x (1+ most-positive-fixnum)) x))
 
58
  t)
 
59
 
 
60
(deftest last.13
 
61
  (let ((x '(a b c . d)))
 
62
    (eqt (last x  most-positive-fixnum) x))
 
63
  t)
 
64
 
 
65
(deftest last.14
 
66
  (let ((x '(a b c . d)))
 
67
    (eqt (last x (1- most-positive-fixnum)) x))
 
68
  t)
 
69
 
 
70
(deftest last.order.1
 
71
  (let ((i 0) x y)
 
72
    (values
 
73
     (last (progn (setf x (incf i)) (list 'a 'b 'c 'd))
 
74
           (setf y (incf i)))
 
75
     i x y))
 
76
  (c d) 2 1 2)
 
77
 
 
78
(deftest last.order.2
 
79
  (let ((i 0))
 
80
    (values (last (progn (incf i) (list 'a 'b 'c 'd))) i))
 
81
  (d) 1)
 
82
 
 
83
(deftest last.error.1
 
84
  (signals-error (last (list 'a 'b 'c) -1) type-error)
 
85
  t)
 
86
 
 
87
(deftest last.error.2
 
88
  (signals-error (last (list 'a 'b 'c) 'a) type-error)
 
89
  t)
 
90
 
 
91
(deftest last.error.3
 
92
  (signals-error (last (list 'a 'b 'c) 10.0) type-error)
 
93
  t)
 
94
 
 
95
(deftest last.error.4
 
96
  (signals-error (last (list 'a 'b 'c) -10.0) type-error)
 
97
  t)
 
98
 
 
99
(deftest last.error.5
 
100
  (signals-error (last (list 'a 'b 'c) #\w) type-error)
 
101
  t)
 
102
 
 
103
(deftest last.error.6
 
104
  (signals-error (last) program-error)
 
105
  t)
 
106
 
 
107
(deftest last.error.7
 
108
  (signals-error (last '(a b c) 2 nil) program-error)
 
109
  t)
 
110
 
 
111
(deftest last.error.8
 
112
  (signals-error (locally (last (list 'a 'b 'c) 'a) t)
 
113
                 type-error)
 
114
  t)
 
115