Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ansi-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michał Herda
ansi-test
Commits
44295dd3
Commit
44295dd3
authored
21 years ago
by
pfdietz
Browse files
Options
Downloads
Patches
Plain Diff
More LOGBITP tests, and a function to randomly test compiled LOG* functions with declarations.
parent
f09cefad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ansi-tests/logbitp.lsp
+16
-0
16 additions, 0 deletions
ansi-tests/logbitp.lsp
ansi-tests/numbers-aux.lsp
+32
-0
32 additions, 0 deletions
ansi-tests/numbers-aux.lsp
with
48 additions
and
0 deletions
ansi-tests/logbitp.lsp
+
16
−
0
View file @
44295dd3
...
@@ -61,6 +61,22 @@
...
@@ -61,6 +61,22 @@
(notnot-mv (logbitp (1+ most-positive-fixnum) -1))
(notnot-mv (logbitp (1+ most-positive-fixnum) -1))
t)
t)
(deftest logbitp.7
(loop for len = (random 100)
for i = (random-from-interval (ash 1 len))
for k = (random (1+ len))
repeat 1000
unless (if (ldb-test (byte 1 k) i)
(logbitp k i)
(not (logbitp k i)))
collect (list i k))
nil)
(deftest logbitp.8
(loop for k from 1 to 1000
always (logbitp k -1))
t)
(deftest logbitp.order.1
(deftest logbitp.order.1
(let ((i 0) a b)
(let ((i 0) a b)
(values
(values
...
...
This diff is collapsed.
Click to expand it.
ansi-tests/numbers-aux.lsp
+
32
−
0
View file @
44295dd3
...
@@ -249,3 +249,35 @@
...
@@ -249,3 +249,35 @@
;;; Approximate equality function
;;; Approximate equality function
(defun approx= (x y &optional (eps (epsilon x)))
(defun approx= (x y &optional (eps (epsilon x)))
(<= (abs (/ (- x y) (max (abs x) 1))) eps))
(<= (abs (/ (- x y) (max (abs x) 1))) eps))
(defun test-log-op-with-decls (op xlo xhi ylo yhi niters
&optional
(decls '((optimize (speed 3) (safety 1)
(debug 1)))))
"Test that a compiled form of the LOG* function OP computes
the expected result on two random integers drawn from the
types `(integer ,xlo ,xhi) and `(integer ,ylo ,yhi). Try
niters choices. Return a list of pairs on which the test fails."
(assert (symbolp op))
(assert (integerp xlo))
(assert (integerp xhi))
(assert (integerp ylo))
(assert (integerp yhi))
(assert (integerp niters))
(assert (<= xlo xhi))
(assert (<= ylo yhi))
(let* ((source
`(lambda (x y)
(declare (type (integer ,xlo ,xhi) x)
(type (integer ,ylo ,yhi) y)
,@ decls)
(,op x y)))
(fn (compile nil source)))
(loop for i below niters
for x = (random-from-interval xhi xlo)
for y = (random-from-interval yhi ylo)
unless (eql (funcall (the symbol op) x y)
(funcall fn x y))
collect (list x y))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment