random-type-prop-tests-07.lsp 5.15 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Mar 13 17:03:52 2005
;;;; Contains: Random type prop tests, part 7 (strings)

(in-package :cl-test)

(def-type-prop-test simple-string-p 'simple-string-p '(t) 1)
(def-type-prop-test char 'char (list 'string (index-type-for-dim 0)) 2)
(def-type-prop-test schar 'schar (list 'simple-string (index-type-for-dim 0)) 2)

(def-type-prop-test string 'string '((or string symbol character)) 1)
(def-type-prop-test string-upcase 'string-upcase '(string) 1)
(def-type-prop-test string-downcase 'string-downcase '(string) 1)
(def-type-prop-test string-capitalize 'string-capitalize '(string) 1)

(def-type-prop-test string-trim.1 'string-trim '(string string) 2)
(def-type-prop-test string-trim.2 'string-trim (list #'(lambda () (make-list-type (random 10) 'null 'character))
sds's avatar
sds committed
19
                                                     'string)
pfdietz's avatar
pfdietz committed
20 21 22
  2)
(def-type-prop-test string-left-trim.1 'string-left-trim '(string string) 2)
(def-type-prop-test string-left-trim.2 'string-left-trim (list #'(lambda () (make-list-type (random 10) 'null 'character))
sds's avatar
sds committed
23
                                                               'string)
pfdietz's avatar
pfdietz committed
24 25 26 27 28 29 30 31 32 33
  2)
(def-type-prop-test string-right-trim.1 'string-right-trim '(string string) 2)
(def-type-prop-test string-right-trim.2 'string-right-trim
  (list #'(lambda () (make-list-type (random 10) 'null 'character)) 'string)
  2)

(defmacro def-string-comparison-type-prop-test (op)
  (flet ((%makename (n) (intern (format nil "~A.~A" op n) :cl-test)))
    `(progn
       (def-type-prop-test ,(%makename 1) ',op '(string string) 2)
sds's avatar
sds committed
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96
       (def-type-prop-test ,(%makename 2) ',op
         `(string string (eql :start1) ,#'index-type-for-v1)
         4)
       (def-type-prop-test ,(%makename 3) ',op
         `(string string (eql :start2) ,#'index-type-for-v2)
         4)
       (def-type-prop-test ,(%makename 4) ',op
         `(string string (eql :end1) ,#'end-type-for-v1)
         4)
       (def-type-prop-test ,(%makename 5) ',op
         `(string string (eql :end2) ,#'end-type-for-v2)
         4)
       (def-type-prop-test ,(%makename 6) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :end1) ,#'end-type-for-v1)
         6)
       (def-type-prop-test ,(%makename 7) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :end2) ,#'end-type-for-v2)
         6)
       (def-type-prop-test ,(%makename 8) ',op
         `(string string
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end1) ,#'end-type-for-v1)
         6)
       (def-type-prop-test ,(%makename 9) ',op
         `(string string
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end2) ,#'end-type-for-v2)
         6)
       (def-type-prop-test ,(%makename 10) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end1) ,#'end-type-for-v1)
         8)
       (def-type-prop-test ,(%makename 11) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end2) ,#'end-type-for-v2)
         8)
       (def-type-prop-test ,(%makename 12) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :end2) ,#'end-type-for-v2
                  (eql :end1) ,#'end-type-for-v1)
         8)
       (def-type-prop-test ,(%makename 13) ',op
         `(string string
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end2) ,#'end-type-for-v2
                  (eql :end1) ,#'end-type-for-v1)
         8)
       (def-type-prop-test ,(%makename 14) ',op
         `(string string
                  (eql :start1) ,#'index-type-for-v1
                  (eql :start2) ,#'index-type-for-v2
                  (eql :end2) ,#'end-type-for-v2
                  (eql :end1) ,#'end-type-for-v1)
         10)
pfdietz's avatar
pfdietz committed
97
       )))
sds's avatar
sds committed
98

pfdietz's avatar
pfdietz committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
(def-string-comparison-type-prop-test string=)
(def-string-comparison-type-prop-test string/=)
(def-string-comparison-type-prop-test string<)
(def-string-comparison-type-prop-test string<=)
(def-string-comparison-type-prop-test string>)
(def-string-comparison-type-prop-test string>=)

(def-string-comparison-type-prop-test string-equal)
(def-string-comparison-type-prop-test string-not-equal)
(def-string-comparison-type-prop-test string-lessp)
(def-string-comparison-type-prop-test string-greaterp)
(def-string-comparison-type-prop-test string-not-lessp)
(def-string-comparison-type-prop-test string-not-greaterp)

(def-type-prop-test stringp 'stringp '(t) 1)

(def-type-prop-test make-string.1 'make-string '((integer 0 100) (eql :initial-element) character) 3)
(def-type-prop-test make-string.2 'make-string `((integer 0 100) (eql :initial-element) character
sds's avatar
sds committed
117 118 119 120
                                                 (eql :element-type)
                                                 ,#'(lambda (&rest args)
                                                      `(eql (and character
                                                                 ,(make-random-type-containing (third args))))))
pfdietz's avatar
pfdietz committed
121
  5)