From 64ca62252445994663e26f8f391d74dcc6bc96e6 Mon Sep 17 00:00:00 2001 From: pfdietz <pfdietz@localhost> Date: Fri, 12 Sep 2003 04:26:15 +0000 Subject: [PATCH] Initial checkin of tests for LOGCOUNT, LOGTEST --- ansi-tests/load-numbers.lsp | 2 ++ ansi-tests/logcount.lsp | 70 +++++++++++++++++++++++++++++++++++++ ansi-tests/logtest.lsp | 53 ++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 ansi-tests/logcount.lsp create mode 100644 ansi-tests/logtest.lsp diff --git a/ansi-tests/load-numbers.lsp b/ansi-tests/load-numbers.lsp index e85cd5f7..ff56ea07 100644 --- a/ansi-tests/load-numbers.lsp +++ b/ansi-tests/load-numbers.lsp @@ -75,6 +75,8 @@ (load "lognot.lsp") (load "logxor.lsp") (load "logbitp.lsp") +(load "logcount.lsp") +(load "logtest.lsp") (load "byte.lsp") (load "deposit-field.lsp") diff --git a/ansi-tests/logcount.lsp b/ansi-tests/logcount.lsp new file mode 100644 index 00000000..6831337c --- /dev/null +++ b/ansi-tests/logcount.lsp @@ -0,0 +1,70 @@ +;-*- Mode: Lisp -*- +;;;; Author: Paul Dietz +;;;; Created: Thu Sep 11 23:12:56 2003 +;;;; Contains: Tests of LOGCOUNT + +(in-package :cl-test) + +(deftest logcount.error.1 + (classify-error (logcount)) + program-error) + +(deftest logcount.error.2 + (classify-error (logcount 0 nil)) + program-error) + +(deftest logcount.error.3 + (loop for x in *mini-universe* + unless (or (integerp x) + (eq (eval `(classify-error (logcount ',x))) 'type-error)) + collect x) + nil) + +(deftest logcount.1 + (logcount 0) + 0) + +(deftest logcount.2 + (logcount 1) + 1) + +(deftest logcount.3 + (logcount 2) + 1) + +(deftest logcount.4 + (logcount 3) + 2) + +(deftest logcount.5 + (logcount -1) + 0) + +(deftest logcount.6 + (loop for x = (random-fixnum) + repeat 100 + always (eql (logcount x) (logcount (lognot x)))) + t) + +(deftest logcount.7 + (let ((bound (ash 1 300))) + (loop for x = (random-from-interval bound) + repeat 100 + always (eql (logcount x) (logcount (lognot x))))) + t) + +(deftest logcount.8 + (loop for y = (random (1+ most-positive-fixnum)) + repeat 100 + unless + (let ((cnt 0) + (x y)) + (loop while (> x 0) + do + (when (oddp x) (incf cnt)) + (setf x (ash x -1))) + (eql cnt (logcount y))) + collect y) + nil) + + diff --git a/ansi-tests/logtest.lsp b/ansi-tests/logtest.lsp new file mode 100644 index 00000000..138ec4ad --- /dev/null +++ b/ansi-tests/logtest.lsp @@ -0,0 +1,53 @@ +;-*- Mode: Lisp -*- +;;;; Author: Paul Dietz +;;;; Created: Thu Sep 11 23:22:46 2003 +;;;; Contains: Tests for LOGTEST + +(in-package :cl-test) + +(deftest logtest.error.1 + (classify-error (logtest)) + program-error) + +(deftest logtest.error.2 + (classify-error (logtest 0)) + program-error) + +(deftest logtest.error.3 + (classify-error (logtest 0 0 nil)) + program-error) + +(deftest logtest.error.4 + (loop for x in *mini-universe* + unless (or (integerp x) + (eq (eval `(classify-error (logtest ',x -1))) 'type-error)) + collect x) + nil) + +(deftest logtest.error.5 + (loop for x in *mini-universe* + unless (or (integerp x) + (eq (eval `(classify-error (logtest -1 ',x))) 'type-error)) + collect x) + nil) + +(deftest logtest.1 + (loop for x = (logand (random-fixnum) (random-fixnum)) + for y = (logand (random-fixnum) (random-fixnum)) + repeat 10000 + unless (if (logtest x y) + (not (zerop (logand x y))) + (zerop (logand x y))) + collect (list x y)) + nil) + +(deftest logtest.2 + (logtest 1 2) + nil) + +(deftest logtest.3 + (notnot-mv (logtest 8 (logior 8 4))) + t) + + + -- GitLab