-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbyte.lsp
75 lines (60 loc) · 1.61 KB
/
byte.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Sep 11 20:13:22 2003
;;;; Contains: Tests of BYTE, BYTE-SIZE, and BYTE-POSITION
(in-package :cl-test)
(deftest byte.error.1
(signals-error (byte) program-error)
t)
(deftest byte.error.2
(signals-error (byte 1) program-error)
t)
(deftest byte.error.3
(signals-error (byte 1 1 nil) program-error)
t)
(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
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))))))
t)
(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)
(deftest byte-position.error.1
(signals-error (byte-position) program-error)
t)
(deftest byte-position.error.2
(signals-error (byte-position (byte 1 1) nil)
program-error)
t)
(deftest byte-size.error.1
(signals-error (byte-size) program-error)
t)
(deftest byte-size.error.2
(signals-error (byte-size (byte 1 1) nil) program-error)
t)