]> gitweb.factorcode.org Git - factor.git/blob - basis/pack/pack-tests.factor
Factor source files should not be executable
[factor.git] / basis / pack / pack-tests.factor
1 USING: io io.streams.string kernel namespaces make
2 pack strings tools.test pack.private ;
3 IN: pack.tests
4
5 [ B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } ] [
6     { 1 2 3 4 5 }
7     "cstiq" pack-be
8 ] unit-test
9
10 [ { 1 2 3 4 5 } ] [
11     { 1 2 3 4 5 }
12     "cstiq" [ pack-be ] keep unpack-be
13 ] unit-test
14
15 [ B{ 1 2 0 3 0 0 4 0 0 0 5 0 0 0 0 0 0 0 } ] [
16     [
17         { 1 2 3 4 5 } "cstiq" pack-le
18     ] with-scope
19 ] unit-test
20
21 [ { 1 2 3 4 5 } ] [
22     { 1 2 3 4 5 }
23     "cstiq" [ pack-le ] keep unpack-le
24 ] unit-test
25
26 [ { -1 -2 -3 -4 -5 } ] [
27     { -1 -2 -3 -4 -5 }
28     "cstiq" [ pack-le ] keep unpack-le
29 ] unit-test
30
31 [ { -1 -2 -3 -4 -5 3.14 } ] [
32     { -1 -2 -3 -4 -5 3.14 }
33     "cstiqd" [ pack-be ] keep unpack-be
34 ] unit-test
35
36 [ { -1 -2 -3 -4 -5 } ] [
37     { -1 -2 -3 -4 -5 }
38     "cstiq" [ pack-native ] keep unpack-native
39 ] unit-test
40
41 [ 9 ] [ "iic" packed-length ] unit-test
42 [ "iii" read-packed-le ] must-infer
43 [ "iii" read-packed-be ] must-infer
44 [ "iii" read-packed-native ] must-infer
45 [ "iii" unpack-le ] must-infer
46 [ "iii" unpack-be ] must-infer
47 [ "iii" unpack-native ] must-infer
48 [ "iii" pack ] must-infer
49 [ "iii" unpack ] must-infer
50
51 : test-pack ( str -- ba )
52     "iii" pack ;
53
54 [ test-pack ] must-infer