File: type.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 (71 lines) | stat: -rw-r--r-- 1,425 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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun May 29 08:25:46 2005
;;;; Contains: Tests of TYPE declarations

(in-package :cl-test)

;;; Also of implicit type declarations

(deftest type.1
  (let ((x 1))
    (declare (type (integer 0 1) x))
    (values
     x
     (setq x 0)
     (1+ x)))
  1 0 1)

(deftest type.2
  (let ((x 1))
    (declare (type (integer -1 1) x))
    (locally (declare (type (integer 0 2) x))
	     (values
	      x
	      (setq x 0)
	      (1+ x))))
  1 0 1)

(deftest type.3
  (loop for x in *mini-universe*
	for tp = (type-of x)
	for form = `(let ((y ',x))
		      (declare (type ,tp y))
		      y)
	for val = (eval form)
	unless (eql val x)
	collect (list x tp form val))
  nil)

(deftest type.4
  (loop for x in *mini-universe*
	for tp = (type-of x)
	for form = `(let ((y ',x))
		      (declare (,tp y))
		      y)
	for val = (eval form)
	unless (eql val x)
	collect (list x tp form val))
  nil)

(deftest type.5
  (loop for x in *mini-universe*
	for class = (class-of x)
	for form = `(let ((y ',x))
		      (declare (,class y))
		      y)
	for val = (eval form)
	unless (eql val x)
	collect (list x class form val))
  nil)

;;; Free TYPE declaration
;;; It should not apply to the occurence of X in the form
;;; whose value is being bound to Y.

(deftest type.6
  (let ((x 2))
    (let ((y (+ (decf x) 2)))
      (declare (type (integer 0 1) x))
      (values x y)))
  1 3)