print-backquote.lsp 3.36 KB
Newer Older
1 2 3 4 5 6 7 8
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Jun 10 19:31:01 2004
;;;; Contains: Tests of printing of backquote forms (and fragments thereof)

(in-package :cl-test)

(compile-and-load "printer-aux.lsp")
pfdietz's avatar
pfdietz committed
9
(compile-and-load "backquote-aux.lsp")
10 11 12

(deftest print.backquote.random.1
  (let* ((x '`(a ,b ,@c (d . ,e) ,.f #(1 2 ,p ,@q ,.r s) g))
sds's avatar
sds committed
13
         (y (copy-tree x)))
14 15 16 17 18 19 20 21 22
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability y :test #'is-similar))
     (and (not (equal x y)) (list :modified x y))))
  nil)

(deftest print.backquote.random.2
  (let* ((x '`(,@a ,@b))
sds's avatar
sds committed
23
         (y (copy-tree x)))
24 25 26 27 28 29 30 31 32
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability y :test #'is-similar))
     (and (not (is-similar x y)) (list :modified x y))))
  nil)

(deftest print.backquote.random.3
  (let* ((x '`(,.a ,.b))
sds's avatar
sds committed
33
         (y (copy-tree x)))
34 35 36 37 38 39 40 41 42
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability y :test #'is-similar))
     (and (not (is-similar x y)) (list :modified x y))))
  nil)

(deftest print.backquote.random.4
  (let* ((x '`(,a ,b))
sds's avatar
sds committed
43
         (y (copy-tree x)))
44 45 46 47 48 49 50 51 52
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability y :test #'is-similar))
     (and (not (is-similar x y)) (list :modified x y))))
  nil)

(deftest print.backquote.random.5
  (let* ((x '`#(,a ,b))
sds's avatar
sds committed
53
         (y (copy-tree x)))
54 55 56 57 58 59 60 61 62 63
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability y :test #'is-similar))
     (and (not (is-similar x y)) (list :modified x y))))
  nil)

(deftest print.backquote.random.6
  (let ((x '`(,@a ,@b)))
    (and (consp x)
sds's avatar
sds committed
64 65 66 67
         (symbolp (car x))
         (loop
          repeat 20
          nconc (randomly-check-readability (list (car x)) :test #'is-similar))))
68 69 70 71 72
  nil)

(deftest print.backquote.random.7
  (let ((x '`(,.a ,.b)))
    (and (consp x)
sds's avatar
sds committed
73 74 75 76
         (symbolp (car x))
         (loop
          repeat 20
          nconc (randomly-check-readability (list (car x)) :test #'is-similar))))
77 78 79 80 81
  nil)

(deftest print.backquote.random.8
  (let ((x '`(,a ,b)))
    (and (consp x)
sds's avatar
sds committed
82 83 84 85
         (symbolp (car x))
         (loop
          repeat 20
          nconc (randomly-check-readability (list (car x)) :test #'is-similar))))
86 87 88 89 90
  nil)

(deftest print.backquote.random.9
  (let ((x '`#(,a ,b)))
    (and (consp x)
sds's avatar
sds committed
91 92 93 94
         (symbolp (car x))
         (loop
          repeat 20
          nconc (randomly-check-readability (list (car x)) :test #'is-similar))))
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
  nil)

(deftest print.backquote.random.10
  (let ((x '`#(,a , .b)))
    (loop
     repeat 20
     nconc (randomly-check-readability x :test #'is-similar)))
  nil)

(deftest print.backquote.random.11
  (let ((x '`#(,a , @b)))
    (loop
     repeat 20
     nconc (randomly-check-readability x :test #'is-similar)))
  nil)

(deftest print.backquote.random.12
  (let ((x '`#(,a ,b c)))
    (and (consp x)
sds's avatar
sds committed
114 115 116 117
         (symbolp (car x))
         (loop
          repeat 20
          nconc (randomly-check-readability (list (car x)) :test #'is-similar))))
118 119 120 121
  nil)

(deftest print.backquote.random.13
  (let* ((x '`#(,a ,b c))
sds's avatar
sds committed
122
         (y (copy-tree x)))
123 124 125 126
    (or
     (loop
      repeat 20
      nconc (randomly-check-readability x :test #'is-similar))
sds's avatar
sds committed
127
     (and (not (is-similar x y)) (list :modified x y))))
128 129
  nil)

pfdietz's avatar
pfdietz committed
130 131
(deftest print.backquote.random.14
  (loop for x = (make-random-backquoted-form 100)
sds's avatar
sds committed
132 133 134
        repeat 500
        nconc (randomly-check-readability x :test #'is-similar))
  nil)