Commit 474025f9 authored by pfdietz's avatar pfdietz

Tests for EVENP, ODDP

parent 4d9c24be
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Aug 31 10:39:01 2003
;;;; Contains: Tests of EVENP
(in-package :cl-test)
(deftest evenp.error.1
(classify-error (evenp))
program-error)
(deftest evenp.error.2
(classify-error (evenp 0 nil))
program-error)
(deftest evenp.1
(loop for x in *numbers*
when (integerp x)
do (evenp x))
nil)
(deftest evenp.2
(loop for x in *mini-universe*
unless (or (integerp x)
(eq (classify-error** `(evenp (quote ,x))) 'type-error))
collect x)
nil)
(deftest evenp.3
(let ((upper-bound most-positive-fixnum)
(lower-bound most-negative-fixnum))
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound)
repeat 10000
when (or
(not (evenp (+ x x)))
(evenp (+ x x 1))
(if (evenp x)
(or (evenp (1+ x))
(evenp (1- x))
(/= (mod x 2) 0))
(or (not (evenp (1+ x)))
(not (evenp (1- x)))
(= (mod x 2) 0))))
collect x))
nil)
(deftest evenp.4
(let ((upper-bound 1000000000000000)
(lower-bound -1000000000000000))
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound)
repeat 10000
when (or
(not (evenp (+ x x)))
(evenp (+ x x 1))
(if (evenp x)
(or (evenp (1+ x))
(evenp (1- x))
(/= (mod x 2) 0))
(or (not (evenp (1+ x)))
(not (evenp (1- x)))
(= (mod x 2) 0))))
collect x))
nil)
\ No newline at end of file
......@@ -26,4 +26,7 @@
(load "times.lsp")
(load "plus.lsp")
(load "evenp.lsp")
(load "oddp.lsp")
(load "epsilons.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Aug 31 10:48:25 2003
;;;; Contains: Tests of ODDP
(in-package :cl-test)
(deftest oddp.error.1
(classify-error (oddp))
program-error)
(deftest oddp.error.2
(classify-error (oddp 0 nil))
program-error)
(deftest oddp.1
(loop for x in *numbers*
when (integerp x)
do (oddp x))
nil)
(deftest oddp.2
(loop for x in *mini-universe*
unless (or (integerp x)
(eq (classify-error** `(oddp (quote ,x))) 'type-error))
collect x)
nil)
(deftest oddp.3
(let ((upper-bound most-positive-fixnum)
(lower-bound most-negative-fixnum))
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound)
repeat 10000
when (or
(oddp (+ x x))
(not (oddp (+ x x 1)))
(if (oddp x)
(or (oddp (1+ x))
(oddp (1- x))
(/= (mod x 2) 1))
(or (not (oddp (1+ x)))
(not (oddp (1- x)))
(/= (mod x 2) 0))))
collect x))
nil)
(deftest oddp.4
(let ((upper-bound 1000000000000000)
(lower-bound -1000000000000000))
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound)
repeat 10000
when (or
(oddp (+ x x))
(not (oddp (+ x x 1)))
(if (oddp x)
(or (oddp (1+ x))
(oddp (1- x))
(/= (mod x 2) 1))
(or (not (oddp (1+ x)))
(not (oddp (1- x)))
(/= (mod x 2) 0))))
collect x))
nil)
\ No newline at end of file
Markdown is supported
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