Last change
on this file was
15336,
checked in by Mark Evenson, 4 years ago
|
t/byte-vectors: test for failures found with NIBBLES
|
File size:
2.0 KB
|
Line | |
---|
1 | (in-package :cl-user) |
---|
2 | |
---|
3 | (let ((element-bits '(8 16 32)) |
---|
4 | (length 16)) |
---|
5 | (prove:plan (* (length element-bits) 3)) |
---|
6 | (dolist (bits element-bits) |
---|
7 | (let* ((type |
---|
8 | `(unsigned-byte ,bits)) |
---|
9 | (exclusive-max |
---|
10 | (expt 2 bits)) |
---|
11 | (max |
---|
12 | (1- exclusive-max))) |
---|
13 | (prove:ok |
---|
14 | (let ((array (make-array length :element-type type :initial-element max))) |
---|
15 | (typep (aref array 0) type)) |
---|
16 | (format nil "Able to make (SIMPLE-ARRAY ~a (~a)) filled with maximum value ~a" |
---|
17 | type length max)) |
---|
18 | (prove:is-condition |
---|
19 | (let ((array (make-array length :element-type type :initial-element -1))) |
---|
20 | (typep (aref array 0) type)) |
---|
21 | 'type-error |
---|
22 | (format nil "Making a (SIMPLE-ARRAY ~a (~a)) filled with -1 signals a type-error" |
---|
23 | type length)) |
---|
24 | (prove:is-condition |
---|
25 | (let ((array (make-array 16 :element-type type :initial-element exclusive-max))) |
---|
26 | (typep (aref array 0) type)) |
---|
27 | 'type-error |
---|
28 | (format nil "Making a (SIMPLE-ARRAY ~a (~a)) filled with ~a signals a type-error" |
---|
29 | type length exclusive-max))))) |
---|
30 | |
---|
31 | ;; pfdietz |
---|
32 | (prove:plan 1) |
---|
33 | (prove:ok |
---|
34 | (handler-case |
---|
35 | (stable-sort (make-array '(0)) '<) |
---|
36 | (t (e) nil)) |
---|
37 | "Able to STABLE-SORT an empty vector.") |
---|
38 | |
---|
39 | ;; nibbles failures |
---|
40 | |
---|
41 | |
---|
42 | (let* ((unspecialized |
---|
43 | #(2025373960 3099658457 3238582529 148439321 |
---|
44 | 3099658456 3238582528 3000000000 1000000000 |
---|
45 | 2000000000 2900000000 2400000000 2800000000 |
---|
46 | 0 1)) |
---|
47 | (array |
---|
48 | (make-array (length unspecialized) |
---|
49 | :element-type '(unsigned-byte 32) |
---|
50 | :initial-contents unspecialized))) |
---|
51 | (prove:plan (length array)) |
---|
52 | (loop :for i :below (length array) |
---|
53 | :doing |
---|
54 | (let ((x0 |
---|
55 | (elt unspecialized i)) |
---|
56 | (x1 |
---|
57 | (elt array i))) |
---|
58 | (prove:ok |
---|
59 | (equal x0 x1) |
---|
60 | (format nil "~a: ~a equals ~a" i x0 x1))))) |
---|
61 | |
---|
62 | (prove:finalize) |
---|
63 | |
---|
Note: See
TracBrowser
for help on using the repository browser.