byte.lsp 1.59 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Sep 11 20:13:22 2003
;;;; Contains: Tests of BYTE, BYTE-SIZE, and BYTE-POSITION

6

7 8

(deftest byte.error.1
9 10
  (signals-error (byte) program-error)
  t)
11 12

(deftest byte.error.2
13 14
  (signals-error (byte 1) program-error)
  t)
15 16

(deftest byte.error.3
17 18
  (signals-error (byte 1 1 nil) program-error)
  t)
19 20 21 22 23 24 25 26 27 28 29

(deftest byte.1
  (progn (byte 0 0) :good)
  :good)

(deftest byte.2
  (progn (byte 1 1) :good)
  :good)

(deftest byte.3
  (loop for i from 0 to 100
sds's avatar
sds committed
30 31 32 33 34 35
        always
        (loop for j from 0 to 100
              always
              (let ((bspec (byte i j)))
                (and (eql i (byte-size bspec))
                     (eql j (byte-position bspec))))))
36 37
  t)

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
(deftest byte.4
  (macrolet
   ((%m (z) z))
   (let ((b (byte (expand-in-current-env (%m 2)) 5)))
     (values (byte-size b) (byte-position b))))
  2 5)

(deftest byte.5
  (macrolet
   ((%m (z) z))
   (let ((b (byte 31 (expand-in-current-env (%m 7)))))
     (values (byte-size b) (byte-position b))))
  31 7)

(deftest byte-size.1
  (macrolet ((%m (z) z)) (byte-size (expand-in-current-env (%m (byte 3 7)))))
  3)

(deftest byte-position.1
  (macrolet ((%m (z) z)) (byte-position (expand-in-current-env (%m (byte 3 7)))))
  7)

60
(deftest byte-position.error.1
61 62
  (signals-error (byte-position) program-error)
  t)
63 64

(deftest byte-position.error.2
65
  (signals-error (byte-position (byte 1 1) nil)
sds's avatar
sds committed
66
                 program-error)
67
  t)
68 69

(deftest byte-size.error.1
70 71
  (signals-error (byte-size) program-error)
  t)
72 73

(deftest byte-size.error.2
74 75
  (signals-error (byte-size (byte 1 1) nil) program-error)
  t)