source: trunk/source/tests/ansi-tests/random-type-prop-tests-structs.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.3 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Contains: Random type prop tests: structures
4
5(in-package :cl-test)
6
7(defstruct rtpt-1 a b)
8
9(defmethod make-random-element-of-type ((type (eql 'rtpt-1)))
10  (make-rtpt-1 :a (make-random-element-of-type t)
11               :b (make-random-element-of-type t)))
12
13(defmethod replicate ((obj rtpt-1))
14  (or (gethash obj *replicate-table*)
15      (let ((x (make-rtpt-1)))
16        (setf (gethash obj *replicate-table*) x)
17        (setf (rtpt-1-a x) (replicate (rtpt-1-a obj)))
18        (setf (rtpt-1-b x) (replicate (rtpt-1-b obj)))
19        x)))
20
21(defmethods make-random-type-containing*
22  (1 ((val rtpt-1)) 'rtpt-1))
23
24(def-type-prop-test structure-ref.1 'rtpt-1-a '(rtpt-1) 1)
25
26(def-type-prop-test copy-structure.1 'copy-structure '(rtpt-1) 1
27  :test #'equalp)
28
29
30(defstruct rtpt-2 a)
31(defstruct (rtpt-2.1 (:include rtpt-2)) c d)
32(defstruct (rtpt-2.2 (:include rtpt-2)) d e)
33
34(defmethod make-random-element-of-type ((type (eql 'rtpt-2)))
35  (rcase
36   (1 (make-rtpt-2 :a (make-random-element-of-type t)))
37   (1 (make-random-element-of-type 'rtpt-2.1))
38   (1 (make-random-element-of-type 'rtpt-2.2))))
39
40(defmethod make-random-element-of-type ((type (eql 'rtpt-2.1)))
41  (make-rtpt-2.1 :a (make-random-element-of-type t)
42                 :c (make-random-element-of-type t)
43                 :d (make-random-element-of-type t)))
44
45(defmethod make-random-element-of-type ((type (eql 'rtpt-2.2)))
46  (make-rtpt-2.2 :a (make-random-element-of-type t)
47                 :d (make-random-element-of-type t)
48                 :e (make-random-element-of-type t)))
49
50(defmethod replicate ((obj rtpt-2))
51  (replicate-with (obj x (make-rtpt-2))
52                  (setf (rtpt-2-a x) (replicate (rtpt-2-a obj)))))
53
54(defmethod replicate ((obj rtpt-2.1))
55  (replicate-with (obj x (make-rtpt-2.1))
56                  (setf (rtpt-2.1-a x) (replicate (rtpt-2.1-a obj)))
57                  (setf (rtpt-2.1-c x) (replicate (rtpt-2.1-c obj)))
58                  (setf (rtpt-2.1-d x) (replicate (rtpt-2.1-d obj)))))
59
60(defmethod replicate ((obj rtpt-2.2))
61  (replicate-with (obj x (make-rtpt-2.2))
62                  (setf (rtpt-2.2-a x) (replicate (rtpt-2.2-a obj)))
63                  (setf (rtpt-2.2-d x) (replicate (rtpt-2.2-d obj)))
64                  (setf (rtpt-2.2-e x) (replicate (rtpt-2.2-e obj)))))
65
66(defmethods make-random-type-containing*
67  (1 ((val rtpt-2)) 'rtpt-2)
68  (1 ((val rtpt-2.1)) 'rtpt-2.1)
69  (1 ((val rtpt-2.2)) 'rtpt-2.2))
70
71(def-type-prop-test structure-ref.2 'rtpt-2-a '(rtpt-2) 1)
72
Note: See TracBrowser for help on using the repository browser.