1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: tools.test kernel serialize io io.streams.byte-array math
5 alien arrays byte-arrays bit-arrays specialized-arrays.double
6 sequences math prettyprint parser classes math.constants
7 io.encodings.binary random assocs serialize.private ;
12 binary [ serialize-cell ] with-byte-writer
13 binary [ deserialize-cell ] with-byte-reader = ;
18 40 [ test-serialize-cell ] all?
19 4 [ 40 * test-serialize-cell ] all?
20 4 [ 400 * test-serialize-cell ] all?
21 4 [ 4000 * test-serialize-cell ] all?
26 TUPLE: serialize-test a b ;
28 C: <serialize-test> serialize-test
45 "hello \u123456 unicode"
48 T{ serialize-test f "a" 2 }
51 double-array{ 1.0 3.0 4.0 1.0 2.35 0.33 }
52 << 1 [ 2 ] curry parsed >>
53 { { "a" "bc" } { "de" "fg" } }
54 H{ { "a" "bc" } { "de" "fg" } }
57 : check-serialize-1 ( obj -- ? )
66 : check-serialize-2 ( obj -- ? )
67 dup number? over wrapper? or [
68 drop t ! we don't care if numbers aren't interned
78 [ t ] [ objects [ check-serialize-1 ] all? ] unit-test
80 [ t ] [ objects [ check-serialize-2 ] all? ] unit-test
82 [ t ] [ pi check-serialize-1 ] unit-test
83 [ serialize ] must-infer
84 [ deserialize ] must-infer
94 H{ } dup dup dup set-at