5 |
|
|
6 |
(in-package :cl-test) |
(in-package :cl-test) |
7 |
|
|
8 |
|
(compile-and-load "numbers-aux.lsp") |
9 |
|
|
10 |
(deftest oddp.error.1 |
(deftest oddp.error.1 |
11 |
(classify-error (oddp)) |
(classify-error (oddp)) |
12 |
program-error) |
program-error) |
29 |
nil) |
nil) |
30 |
|
|
31 |
(deftest oddp.3 |
(deftest oddp.3 |
32 |
(let ((upper-bound most-positive-fixnum) |
(loop for x = (random-fixnum) |
33 |
(lower-bound most-negative-fixnum)) |
repeat 10000 |
34 |
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound) |
when (or |
35 |
repeat 10000 |
(oddp (+ x x)) |
36 |
when (or |
(not (oddp (+ x x 1))) |
37 |
(oddp (+ x x)) |
(if (oddp x) |
38 |
(not (oddp (+ x x 1))) |
(or (oddp (1+ x)) |
39 |
(if (oddp x) |
(oddp (1- x)) |
40 |
(or (oddp (1+ x)) |
(/= (mod x 2) 1)) |
41 |
(oddp (1- x)) |
(or (not (oddp (1+ x))) |
42 |
(/= (mod x 2) 1)) |
(not (oddp (1- x))) |
43 |
(or (not (oddp (1+ x))) |
(/= (mod x 2) 0)))) |
44 |
(not (oddp (1- x))) |
collect x) |
|
(/= (mod x 2) 0)))) |
|
|
collect x)) |
|
45 |
nil) |
nil) |
46 |
|
|
47 |
(deftest oddp.4 |
(deftest oddp.4 |
48 |
(let ((upper-bound 1000000000000000) |
(let ((upper-bound 1000000000000000) |
49 |
(lower-bound -1000000000000000)) |
(lower-bound -1000000000000000)) |
50 |
(loop for x = (- (random (- upper-bound lower-bound)) lower-bound) |
(loop for x = (random-from-interval upper-bound lower-bound) |
51 |
repeat 10000 |
repeat 10000 |
52 |
when (or |
when (or |
53 |
(oddp (+ x x)) |
(oddp (+ x x)) |