Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
ansi-test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Karsten Poeck
ansi-test
Commits
b7ed600e
Commit
b7ed600e
authored
Mar 02, 2004
by
pfdietz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add randomized tests for printing integers, ratios.
parent
a6e24013
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
4 deletions
+74
-4
ansi-tests/load-printer.lsp
ansi-tests/load-printer.lsp
+1
-0
ansi-tests/print-integers.lsp
ansi-tests/print-integers.lsp
+7
-4
ansi-tests/print-ratios.lsp
ansi-tests/print-ratios.lsp
+17
-0
ansi-tests/printer-aux.lsp
ansi-tests/printer-aux.lsp
+49
-0
No files found.
ansi-tests/load-printer.lsp
View file @
b7ed600e
...
...
@@ -10,4 +10,5 @@
(load "copy-pprint-dispatch.lsp")
(load "print-integers.lsp")
(load "print-ratios.lsp")
ansi-tests/print-integers.lsp
View file @
b7ed600e
...
...
@@ -264,7 +264,10 @@
(concatenate 'string "#36r-" (make-string 200 :initial-element #\Z))
(*print-radix* t) (*print-base* 36))
(deftest print.integers.random
(loop for i from 1 to 10000
for numbits = (random 40)
for bound = (ash 1 numbits)
for r = (- (random (+ bound bound)) bound)
nconc (randomly-check-readability r))
nil)
ansi-tests/print-ratios.lsp
0 → 100644
View file @
b7ed600e
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Mon Mar 1 22:03:58 2004
;;;; Contains: Tests for printing ratios
(in-package :cl-test)
(deftest print.ratios.random
(loop for i from 1 to 1000
for numbits = (1+ (random 40))
for bound = (ash 1 numbits)
for num = (- (random (+ bound bound)) bound)
for denom = (1+ (random bound))
for r = (/ num denom)
nconc (randomly-check-readability r))
nil)
ansi-tests/printer-aux.lsp
View file @
b7ed600e
...
...
@@ -13,3 +13,52 @@
(with-output-to-string (*standard-output*) (prin1 ,form))))
,result)
t))
;;; Function to test readable of printed forms, under random settings
;;; of various printer control variables.
;;;
;;; Return NIL if obj printed and read properly, or a list containing
;;; the object and the printer variable bindings otherwise. They key
;;; argument TEST is used to compared the reread object and obj.
(defun randomly-check-readability (obj &key (test #'equal))
;; Generate random printer-control values
(with-standard-io-syntax
(let ((*print-array* (coin))
(*print-base* (+ 2 (random 34)))
(*print-radix* (coin))
(*print-case* (random-from-seq #(:upcase :downcase :capitalize)))
(*print-circle* (coin))
(*print-escape* (coin))
(*print-gensym* (coin))
(*print-level* (random 50))
(*print-length* (random 50))
(*print-lines* (random 50))
(*print-miser-width* (and (coin) (random 100)))
(*print-pretty* (coin))
(*print-right-margin* (and (coin) (random 100)))
(*print-readably* t)
)
(let* ((str (with-output-to-string (s) (write obj :stream s)))
(obj2 (let ((*read-base* *print-base*))
(handler-case
(read-from-string str)
(reader-error () :error)))))
(unless (funcall test obj obj2)
(list
(list obj obj2
(list '*print-array* *print-array*)
(list '*print-base* *print-base*)
(list '*print-radix* *print-radix*)
(list '*print-case* *print-case*)
(list '*print-circle* *print-circle*)
(list '*print-escape* *print-escape*)
(list '*print-gensym* *print-gensym*)
(list '*print-level* *print-level*)
(list '*print-length* *print-length*)
(list '*print-lines* *print-lines*)
(list '*print-miser-width* *print-miser-width*)
(list '*print-pretty* *print-pretty*)
(list '*print-right-margin* *print-right-margin*))))))))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment