]> gitweb.factorcode.org Git - factor.git/blob - extra/bson/bson-tests.factor
factor: fix some spacing
[factor.git] / extra / bson / bson-tests.factor
1 USING: bson.reader bson.writer bson.constants byte-arrays io.encodings.binary
2 io.streams.byte-array tools.test literals calendar kernel math ;
3
4 IN: bson.tests
5
6 : turnaround ( value -- value )
7     assoc>bv binary [ H{ } clone stream>assoc ] with-byte-reader ;
8
9 { H{ { "a" "a string" } } } [ H{ { "a" "a string" } } turnaround ] unit-test
10
11 { H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } }
12 [ H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } turnaround ] unit-test
13
14 { H{ { "a list" { 1 2.234 "hello world" } } } }
15 [ H{ { "a list" { 1 2.234 "hello world" } } } turnaround ] unit-test
16
17 { H{ { "a quotation" [ 1 2 + ] } } }
18 [ H{ { "a quotation" [ 1 2 + ] } } turnaround ] unit-test
19
20 { H{ { "ref" T{ dbref f "a" "b" "c" } } } }
21 [ H{ { "ref" T{ dbref f "a" "b" "c" } } } turnaround ] unit-test
22
23 { H{ { "a date" T{ timestamp { year 2009 }
24                    { month 7 }
25                    { day 11 }
26                    { hour 9 }
27                    { minute 8 }
28                    { second 40+77/1000 } } } }
29 }
30 [ H{ { "a date" T{ timestamp { year 2009 }
31                    { month 7 }
32                    { day 11 }
33                    { hour 11 }
34                    { minute 8 }
35                    { second 40+15437/200000 }
36                    { gmt-offset T{ duration { hour 2 } } } } } } turnaround
37 ] unit-test
38
39 {
40      H{
41           { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
42           { "ref" T{ dbref f "a" "b" "c" } }
43           { "array" H{ { "a list" { 1 2.234 "hello world" } } } }
44           { "quot" [ 1 2 + ] }
45      }
46 } [
47      H{
48           { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
49           { "ref" T{ dbref f "a" "b" "c" } }
50           { "array" H{ { "a list" { 1 2.234 "hello world" } } } }
51           { "quot" [ 1 2 + ] }
52      } turnaround
53 ] unit-test