File: shiftf.lsp

package info (click to toggle)
cl-ansi-tests 20071218-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,000 kB
  • ctags: 22,025
  • sloc: lisp: 134,798; makefile: 144
file content (82 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Apr 20 15:43:44 2003
;;;; Contains: Tests of SHIFTF

(in-package :cl-test)

(deftest shiftf-order.1
  (let ((x (vector 'a 'b 'c 'd 'e))
	(i 2))
    (values (shiftf (aref x (incf i)) (incf i)) x i))
  d #(a b c 4 e) 4)
    
(deftest shiftf-order.2
  (let ((x (vector 'a 'b 'c 'd 'e 'f 'g 'h))
	(i 2))
    (values (shiftf (aref x (incf i)) (aref x (incf i)) (incf i)) x i))
  d #(a b c e 5 f g h) 5)

(deftest shiftf.1
  (let ((x 0))
    (values
     x
     (shiftf x 1)
     x))
  0 0 1)

(deftest shiftf.2
  (let ((x 'a) (y 'b) (z 'c))
    (values
     x y z
     (shiftf x y z 'd)
     x y z))
  a b c
  a
  b c d)
    
(deftest shiftf.3
  (let ((x (vector 0 1 2 3)))
    (values
     (copy-seq x)
     (shiftf (aref x (aref x 0))
	     (aref x (aref x 1))
	     (aref x (aref x 2))
	     (aref x (aref x 3))
	     'foo)
     (copy-seq x)))
  #(0 1 2 3)
  0
  #(1 2 3 foo))

;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment

(deftest shiftf.4
  (macrolet
   ((%m (z) z))
   (let ((x 1) (y 2))
     (values
      (shiftf (expand-in-current-env (%m x)) y 'foo)
      x y)))
  1 2 foo)

(deftest shiftf.5
  (macrolet
   ((%m (z) z))
   (let ((x 1) (y 2))
     (values
      (shiftf x (expand-in-current-env (%m y)) 'foo)
      x y)))
  1 2 foo)

(deftest shiftf.6
  (macrolet
   ((%m (z) z))
   (let ((x 1) (y 2))
     (values
      (shiftf x y (expand-in-current-env (%m 'foo)))
      x y)))
  1 2 foo)

;;; Need to add more shiftf tests here