IN: bson.tests
: turnaround ( value -- value )
- assoc>bv >byte-array binary [ H{ } clone stream>assoc ] with-byte-reader ;
+ assoc>bv binary [ H{ } clone stream>assoc ] with-byte-reader ;
[ H{ { "a" "a string" } } ] [ H{ { "a" "a string" } } turnaround ] unit-test
{ second 40+15437/200000 }
{ gmt-offset T{ duration { hour 2 } } } } } } turnaround
] unit-test
-
+
[ H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
{ "ref" T{ dbref f "a" "b" "c" } }
{ "array" H{ { "a list" { 1 2.234 "hello world" } } } }
{ "quot" [ 1 2 + ] } }
-]
+]
[ H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
{ "ref" T{ dbref f "a" "b" "c" } }
{ "array" H{ { "a list" { 1 2.234 "hello world" } } } }
{ "quot" [ 1 2 + ] } } turnaround ] unit-test
-
-
<PRIVATE
-CONSTANT: INT32-SIZE { 0 1 2 3 }
-CONSTANT: INT64-SIZE { 0 1 2 3 4 5 6 7 }
+CONSTANT: INT32-SIZE 4
+CONSTANT: INT64-SIZE 8
PRIVATE>
: with-length-prefix ( quot: ( .. -- .. ) -- )
[ ] (with-length-prefix) ; inline
-
+
: with-length-prefix-excl ( quot: ( .. -- .. ) -- )
[ 4 - ] (with-length-prefix) ; inline
-: (>le) ( x n -- )
- [ nth-byte write1 ] with each ; inline
-
<PRIVATE
-TYPED: write-int32 ( int: integer -- ) INT32-SIZE (>le) ; inline
+: write-le ( x n -- )
+ iota [ nth-byte write1 ] with each ; inline
+
+TYPED: write-int32 ( int: integer -- )
+ INT32-SIZE write-le ; inline
-TYPED: write-double ( real: float -- ) double>bits INT64-SIZE (>le) ; inline
+TYPED: write-double ( real: float -- )
+ double>bits INT64-SIZE write-le ; inline
TYPED: write-utf8-string ( string: string -- )
get-output utf8 encode-string ; inline
TYPED: write-cstring ( string: string -- )
write-utf8-string 0 write1 ; inline
-: write-longlong ( object -- ) INT64-SIZE (>le) ; inline
+: write-longlong ( object -- )
+ INT64-SIZE write-le ; inline
: write-eoo ( -- ) T_EOO write1 ; inline
write-assoc ; inline
TYPED: mdb-special-value? ( value -- ?: boolean )
- { [ timestamp? ] [ quotation? ] [ mdbregexp? ]
- [ oid? ] [ byte-array? ] } 1|| ; inline
\ No newline at end of file
+ {
+ [ timestamp? ]
+ [ quotation? ]
+ [ mdbregexp? ]
+ [ oid? ]
+ [ byte-array? ]
+ } 1|| ; inline