]> gitweb.factorcode.org Git - factor.git/blob - basis/json/reader/reader-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / json / reader / reader-tests.factor
1 USING: arrays json.reader kernel multiline strings tools.test ;
2 IN: json.reader.tests
3
4 { f } [ "false" json> ] unit-test
5 { t } [ "true" json> ] unit-test
6 { json-null } [ "null" json> ] unit-test
7 { 0 } [ "0" json> ] unit-test
8 { 102 } [ "102" json> ] unit-test
9 { -102 } [ "-102" json> ] unit-test
10 { 102 } [ "+102" json> ] unit-test
11 { 102.0 } [ "102.0" json> ] unit-test
12 { 102.5 } [ "102.5" json> ] unit-test
13 { 102.5 } [ "102.50" json> ] unit-test
14 { -10250.0 } [ "-102.5e2" json> ] unit-test
15 { -10250.0 } [ "-102.5E+2" json> ] unit-test
16 { 10+1/4 } [ "1025e-2" json> ] unit-test
17 { 0.125 } [ "0.125" json> ] unit-test
18 { -0.125 } [ "-0.125" json> ] unit-test
19
20 { " fuzzy  pickles " } [ <" " fuzzy  pickles " "> json> ] unit-test
21 { "while 1:\n\tpass" } [ <" "while 1:\n\tpass" "> json> ] unit-test
22 { 8 9 10 12 13 34 47 92 } >string 1array [ <" "\b\t\n\f\r\"\/\\" "> json> ] unit-test
23 { HEX: abcd } >string 1array [ <" "\uaBCd" "> json> ] unit-test
24
25 { { 1 "two" 3.0 } } [ <" [1, "two", 3.0] "> json> ] unit-test
26 { H{ { "US$" 1.0 } { "EU€" 1.5 } } } [ <" { "US$":1.00, "EU\u20AC":1.50 } "> json> ] unit-test
27 { H{
28     { "fib" { 1 1 2 3 5 8 H{ { "etc" "etc" } } } }
29     { "prime" { 2 3 5 7 11 13 } }
30 } } [ <" {
31     "fib": [1, 1,  2,   3,     5,         8,
32         { "etc":"etc" } ],
33     "prime":
34     [ 2,3,     5,7,
35 11,
36 13
37 ]      }
38 "> json> ] unit-test
39
40 { 0 } [ "      0" json> ] unit-test
41 { 0 } [ "0      " json> ] unit-test
42 { 0 } [ "   0   " json> ] unit-test
43