Commit 0e31093e authored by pfdietz's avatar pfdietz
Browse files

Add tests for level, length control in printing conses. Begin adding tests for printing vectors.

parent c9753281
......@@ -18,3 +18,4 @@
(load "print-strings.lsp")
(load "print-cons.lsp")
(load "print-bit-vector.lsp")
(load "print-vector.lsp")
......@@ -57,5 +57,82 @@
nconc (randomly-check-readability x))
nil)
\ No newline at end of file
;;; Printing with *print-length*
(deftest print.cons.length.1
(with-standard-io-syntax
(write-to-string '(a) :length 0 :readably nil :pretty nil :escape nil))
"(...)")
(deftest print.cons.length.2
(with-standard-io-syntax
(write-to-string '(81) :length 1 :readably nil :pretty nil :escape nil))
"(81)")
(deftest print.cons.length.3
(with-standard-io-syntax
(write-to-string '(4 . 8) :length 1 :readably nil :pretty nil :escape nil))
"(4 . 8)")
(deftest print.cons.length.4
(with-standard-io-syntax
(write-to-string '(4 8) :length 1 :readably nil :pretty nil :escape nil))
"(4 ...)")
(deftest print.cons.length.5
(with-standard-io-syntax
(write-to-string '(a b c d e f g h i j k l m n o p)
:case :downcase :length 10
:readably nil :pretty nil :escape nil))
"(a b c d e f g h i j ...)")
(deftest print.cons.length.6
(with-standard-io-syntax
(write-to-string '(((((((0)))))))
:case :downcase :length 3
:readably nil :pretty nil :escape nil))
"(((((((0)))))))")
;;; Printing with *print-level*
(deftest print.cons.level.1
(with-standard-io-syntax
(write-to-string '(a)
:case :downcase :level 0
:readably nil :escape nil
:pretty nil))
"#")
(deftest print.cons.level.2
(with-standard-io-syntax
(write-to-string '(a)
:case :downcase :level 1
:readably nil :escape nil
:pretty nil))
"(a)")
(deftest print.cons.level.3
(with-standard-io-syntax
(write-to-string '((a))
:case :downcase :level 1
:readably nil :escape nil
:pretty nil))
"(#)")
(deftest print.cons.level.4
(with-standard-io-syntax
(write-to-string '(a)
:case :downcase :level 2
:readably nil :escape nil
:pretty nil))
"(a)")
(deftest print.cons.level.5
(with-standard-io-syntax
(write-to-string '(#(a) #*1101 "abc")
:case :downcase :level 1
:readably nil :pretty nil))
"(# #*1101 \"abc\")")
\ No newline at end of file
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Apr 20 22:36:53 2004
;;;; Contains: Tests of vector printing
(in-package :cl-test)
(deftest print.vector.1
(with-standard-io-syntax
(write-to-string #() :readably nil :array t))
"#()")
(deftest print.vector.2
(with-standard-io-syntax
(loop for i from 2 to 100
for a = (make-array '(0) :element-type `(unsigned-byte ,i))
for s = (write-to-string a :readably nil :array t)
unless (string= s "#()")
collect (list i s)))
nil)
(deftest print.vector.3
(with-standard-io-syntax
(loop for i from 1 to 100
for a = (make-array '(0) :element-type `(signed-byte ,i))
for s = (write-to-string a :readably nil :array t)
unless (string= s "#()")
collect (list i s)))
nil)
(deftest print.vector.4
(with-standard-io-syntax
(loop for type in '(short-float single-float double-float long-float)
for a = (make-array '(0) :element-type type)
for s = (write-to-string a :readably nil :array t)
unless (string= s "#()")
collect (list type s)))
nil)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment