[elephant-cvs] CVS elephant/tests
ieslick
ieslick at common-lisp.net
Thu Feb 1 15:19:50 UTC 2007
Update of /project/elephant/cvsroot/elephant/tests
In directory clnet:/tmp/cvs-serv18919/tests
Modified Files:
testserializer.lisp
Log Message:
Finish 64-bit update; clean up memutil; fix array flag type error in SBCL; more efficient and correct hash serialization in new serializer
--- /project/elephant/cvsroot/elephant/tests/testserializer.lisp 2007/02/01 04:37:25 1.14
+++ /project/elephant/cvsroot/elephant/tests/testserializer.lisp 2007/02/01 15:19:50 1.15
@@ -47,10 +47,75 @@
(typep (in-out-value most-negative-fixnum) 'fixnum))
t t t t t)
+;;
+;; Validate 32/64 bit memutils operation (white box test)
+;;
+
+(deftest read-32-bit-fixnum
+ (progn
+ (with-buffer-streams (bs)
+ (if (not (elephant-memutil::little-endian-p))
+ (elephant-memutil::buffer-write-byte 1 bs))
+ (loop for i from 1 upto 3 do
+ (elephant-memutil::buffer-write-byte 0 bs))
+ (if (elephant-memutil::little-endian-p)
+ (elephant-memutil::buffer-write-byte 1 bs))
+ (elephant-memutil::buffer-read-fixnum32 bs)))
+ #x1000000)
+
+(deftest read-64-bit-fixnum
+ (progn
+ (with-buffer-streams (bs)
+ (if (not (elephant-memutil::little-endian-p))
+ (elephant-memutil::buffer-write-byte 1 bs))
+ (loop for i from 1 upto 7 do
+ (elephant-memutil::buffer-write-byte 0 bs))
+ (if (elephant-memutil::little-endian-p)
+ (elephant-memutil::buffer-write-byte 1 bs))
+ (elephant-memutil::buffer-read-fixnum64 bs)))
+ #x100000000000000)
+
+;;
+;; Use serializer to write fixnum
+;; Verify bytes and length of output
+;;
+
+(deftest write-32-bit-fixnum
+ (progn
+ (with-buffer-streams (bs)
+ (serialize #x01000000 bs *store-controller*)
+ (elephant-memutil::buffer-read-byte bs) ;; skip tag
+ (and (= (elephant-memutil::buffer-stream-size bs) 5)
+ (if (elephant-memutil::little-endian-p)
+ (= (progn (loop for i from 1 upto 3 do
+ (elephant-memutil::buffer-read-byte bs))
+ (elephant-memutil::buffer-read-byte bs))
+ 1)
+ (= (elephant-memutil::buffer-read-byte bs)
+ 1)))))
+ t)
+
+(deftest write-64-bit-fixnum
+ (progn
+ (with-buffer-streams (bs)
+ (serialize #x0100000000000000 bs *store-controller*)
+ (elephant-memutil::buffer-read-byte bs) ;; skip tag
+ (if (< most-positive-fixnum elephant-memutil::+2^32+)
+ t
+ (and (= (elephant-memutil::buffer-stream-size bs) 9)
+ (if (elephant-memutil::little-endian-p)
+ (= (progn (loop for i from 1 upto 7 do
+ (elephant-memutil::buffer-read-byte bs))
+ (elephant-memutil::buffer-read-byte bs))
+ 1)
+ (= (elephant-memutil::buffer-read-byte bs)
+ 1))))))
+ t)
+
(deftest bignums
(are-not-null
- (in-out-equal 10000000000)
- (in-out-equal -10000000000)
+ (in-out-equal (+ most-positive-fixnum 100))
+ (in-out-equal (- most-negative-fixnum 100))
(loop for i from 0 to 2000
always (in-out-equal (expt 2 i)))
(loop for i from 0 to 2000
@@ -167,22 +232,21 @@
(deftest hash-tables-1
(let* ((ht (make-hash-table :test 'equalp :size 333 :rehash-size 1.2
:rehash-threshold 0.8))
- (size (hash-table-size ht))
(rehash-size (hash-table-rehash-size ht))
(rehash-threshold (hash-table-rehash-threshold ht))
- (out (in-out-value ht)))
+ (out (in-out-value ht)))
(are-not-null
(eq (hash-table-test out) 'equalp)
- (= (hash-table-size ht) size)
- (= (hash-table-rehash-size ht) rehash-size)
- (= (hash-table-rehash-threshold ht) rehash-threshold)
+;; (= (hash-table-size out) size) ;; size is not equal, only kv pairs are stored
+;; (= (hash-table-rehash-size out) rehash-size) ;; hint only, implementation not constrained
+;; (= (hash-table-rehash-threshold out) rehash-threshold) ;; hints only, implementation not constrained
(eq (hash-table-test (in-out-value (make-hash-table :test 'eq))) 'eq)
(eq (hash-table-test (in-out-value (make-hash-table :test 'eql))) 'eql)
(eq (hash-table-test
(in-out-value (make-hash-table :test 'equal))) 'equal)
(eq (hash-table-test
(in-out-value (make-hash-table :test 'equalp))) 'equalp)))
- t t t t t t t t)
+ t t t t t)
(deftest hash-tables-2
(let ((ht (make-hash-table :test 'equalp)))
@@ -391,33 +455,4 @@
(eq (get-value f2 h) f2))))
t t t t t t t t)
-(defparameter +little-endian+ nil)
-(defparameter +big-endian+ t)
-
-(defun determine-endianness ()
- (with-buffer-streams (bs)
- (%serialize 1 bs *store-controller*)
- (elephant-memutil::buffer-read-byte bs)
- ;; If little endian, switch defaults
- (when (= (elephant-memutil::buffer-read-byte bs) 1)
- (setf +little-endian+ t)
- (setf +big-endian+ nil))))
-
-;;
-;; Manually write bytes
-;; Verify read out using serializer
-;;
-
-;;(deftest read-32-bit-fixnum
-;; (progn nil)
-;; t)
-
-;;(deftest read-64-bit-fixnum
-;; (progn nil)
-;; t)
-;;
-;; Clear the buffer stream
-;; Use serializer to write fixnum if 64-bit
-;; Verify bytes and length of output
-;;
\ No newline at end of file
More information about the Elephant-cvs
mailing list