random-type-prop-tests-10.lsp 3.51 KB
Newer Older
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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Contains: Random type prop tests, part 10 (sequences, cont.)

(in-package :cl-test)

;;; SEARCH

(def-type-prop-test search.1 'search
  (list 'sequence 'sequence)
  2)

(def-type-prop-test search.2 'search
  (list 'bit-vector 'bit-vector)
  2)

(def-type-prop-test search.3 'search
  (list '(vector * 1) 'sequence)
  2)

(def-type-prop-test search.4 'search
  (list '(vector * 2) 'sequence '(eql :from-end) '(or null t))
  4)

(def-type-prop-test search.5 'search
  (list 'sequence 'sequence '(eql :key)
sds's avatar
sds committed
27
        (list 'member 'identity nil #'identity 'not #'not))
28 29 30 31
  4)

(def-type-prop-test search.6 'search
  (list #'(lambda () (make-sequence-type
sds's avatar
sds committed
32 33 34 35 36 37 38 39 40 41 42
                      (random 10)
                      (let ((i1 (make-random-integer))
                            (i2 (make-random-integer)))
                        `(integer ,(min i1 i2) ,(max i1 i2)))))
        #'(lambda (s)
            (declare (ignore s))
            (make-sequence-type
             (random 10)
             (let ((i1 (make-random-integer))
                   (i2 (make-random-integer)))
               `(integer ,(min i1 i2) ,(max i1 i2))))))
43 44 45 46
  2)

(def-type-prop-test search.7 'search
  (list #'(lambda () (make-sequence-type
sds's avatar
sds committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60
                      (random 10)
                      (let ((i1 (make-random-integer))
                            (i2 (make-random-integer)))
                        `(integer ,(min i1 i2) ,(max i1 i2)))))
        #'(lambda (s)
            (declare (ignore s))
            (make-sequence-type
             (random 10)
             (let ((i1 (make-random-integer))
                   (i2 (make-random-integer)))
               `(integer ,(min i1 i2) ,(max i1 i2)))))
        '(eql :test)
        (list 'member 'eql #'eql 'equal #'equal '= #'=
              '/= #'/= #'(lambda (x y) (= (logand x 1) (logand y 1)))))
61 62 63 64
  4)

(def-type-prop-test search.8 'search
  (labels ((%random-char-type () (random-from-seq #(base-char standard-char character)))
sds's avatar
sds committed
65 66 67 68 69 70 71 72 73 74 75 76 77
           (%random-char-sequence-type (&rest ignored)
              (declare (ignore ignored))
              (make-sequence-type (random 10) (%random-char-type))))

          (list #'%random-char-sequence-type
                #'%random-char-sequence-type
                '(member :test :test-not)
                (let ((char-compare-funs
                       '(char= char/= char< char> char<= char>=
                         char-equal char-not-equal char-lessp char-greaterp
                         char-not-lessp char-not-greaterp)))
                  `(member ,@char-compare-funs
                           ,@(mapcar #'symbol-function char-compare-funs)))))
78 79 80 81
  4)

(def-type-prop-test search.9 'search
  (list 'sequence 'sequence
sds's avatar
sds committed
82 83 84 85 86
        '(eql :start1)
        #'(lambda (s1 s2 k)
            (declare (ignore s2 k))
            (let ((len (length s1)))
              `(integer 0 ,len))))
87 88 89 90
  4)

(def-type-prop-test search.10 'search
  (list 'sequence 'sequence
sds's avatar
sds committed
91 92 93 94 95
        '(eql :end1)
        #'(lambda (s1 s2 k)
            (declare (ignore s2 k))
            (let ((len (length s1)))
              `(integer 0 ,len))))
96 97 98 99
  4)

(def-type-prop-test search.11 'search
  (list 'sequence 'sequence
sds's avatar
sds committed
100 101 102 103 104
        '(eql :start2)
        #'(lambda (s1 s2 k)
            (declare (ignore s1 k))
            (let ((len (length s2)))
              `(integer 0 ,len))))
105 106 107 108
  4)

(def-type-prop-test search.12 'search
  (list 'sequence 'sequence
sds's avatar
sds committed
109 110 111 112 113
        '(eql :end2)
        #'(lambda (s1 s2 k)
            (declare (ignore s1 k))
            (let ((len (length s2)))
              `(integer 0 ,len))))
114
  4)