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
bf2e44b8
Commit
bf2e44b8
authored
Sep 03, 2003
by
pfdietz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial checkin of tests for GCD.
parent
17747d98
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
0 deletions
+92
-0
ansi-tests/gcd-aux.lsp
ansi-tests/gcd-aux.lsp
+26
-0
ansi-tests/gcd.lsp
ansi-tests/gcd.lsp
+65
-0
ansi-tests/load-numbers.lsp
ansi-tests/load-numbers.lsp
+1
-0
No files found.
ansi-tests/gcd-aux.lsp
0 → 100644
View file @
bf2e44b8
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Sep 3 06:57:22 2003
;;;; Contains: Aux. functions for testing GCD
(in-package :cl-test)
(defun my-gcd (x y)
(cond
((< x 0)
(my-gcd (- x) y))
((< y 0)
(my-gcd x (- y)))
((<= x y)
(my-gcd* x y))
(t
(my-gcd* y x))))
(defun my-gcd* (x y)
;;; 0 <= x <= y
(loop
(when (zerop x) (return y))
(psetq x (mod y x)
y x)))
ansi-tests/gcd.lsp
0 → 100644
View file @
bf2e44b8
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Sep 3 06:51:03 2003
;;;; Contains: Tests of GCD
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(compile-and-load "gcd-aux.lsp")
(deftest gcd.error.1
(loop for x in *mini-universe*
unless (or (integerp x)
(eq (eval `(classify-error (gcd ',x))) 'type-error))
collect x)
nil)
(deftest gcd.1
(gcd)
0)
(deftest gcd.2
(loop for i = (random-fixnum)
for a = (abs i)
repeat 10000
unless (and (eql a (gcd i))
(eql a (gcd 0 i)))
collect i)
nil)
(deftest gcd.3
(loop for i = (random-from-interval 10000000000000000)
for a = (abs i)
repeat 10000
unless (and (eql a (gcd i))
(eql a (gcd i 0)))
collect i)
nil)
(deftest gcd.4
(loop for i = (random-fixnum)
for j = (random-fixnum)
repeat 1000
unless (eql (my-gcd i j) (gcd i j))
collect (list i j))
nil)
(deftest gcd.5
(let ((bound (ash 1 200)))
(loop for i = (random-from-interval bound)
for j = (random-from-interval bound)
repeat 1000
unless (eql (my-gcd i j) (gcd i j))
collect (list i j)))
nil)
(deftest gcd.6
(loop for i = (random-fixnum)
for j = (random-fixnum)
for k = (random-fixnum)
repeat 1000
unless (eql (my-gcd i (my-gcd j k)) (gcd i j k))
collect (list i j k))
nil)
ansi-tests/load-numbers.lsp
View file @
bf2e44b8
...
...
@@ -32,6 +32,7 @@
(load "abs.lsp")
;;(load "exp.lsp")
(load "expt.lsp")
(load "gcd.lsp")
(load "rational.lsp")
(load "rationalize.lsp")
...
...
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