]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/pack/pack-tests.factor
ui.listener: document that ~/.factor-history persists input history
[factor.git] / basis / pack / pack-tests.factor
old mode 100755 (executable)
new mode 100644 (file)
index b1a354c..e07783d
@@ -1,48 +1,58 @@
-USING: io io.streams.string kernel namespaces make
-pack strings tools.test ;
+USING: alien.c-types io io.streams.string kernel make namespaces
+pack pack.private strings tools.test ;
 
-[ B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } ] [
+{ B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } } [
     { 1 2 3 4 5 }
     "cstiq" pack-be
 ] unit-test
 
-[ { 1 2 3 4 5 } ] [
+{ { 1 2 3 4 5 } } [
     { 1 2 3 4 5 }
     "cstiq" [ pack-be ] keep unpack-be
 ] unit-test
 
-[ B{ 1 2 0 3 0 0 4 0 0 0 5 0 0 0 0 0 0 0 } ] [
-    [
-        { 1 2 3 4 5 } "cstiq" pack-le
-    ] with-scope
+{ B{ 1 2 0 3 0 0 4 0 0 0 5 0 0 0 0 0 0 0 } } [
+    { 1 2 3 4 5 } "cstiq" pack-le
 ] unit-test
 
-[ { 1 2 3 4 5 } ] [
+{ { 1 2 3 4 5 } } [
     { 1 2 3 4 5 }
     "cstiq" [ pack-le ] keep unpack-le
 ] unit-test
 
-[ { -1 -2 -3 -4 -5 } ] [
+{ { -1 -2 -3 -4 -5 } } [
     { -1 -2 -3 -4 -5 }
     "cstiq" [ pack-le ] keep unpack-le
 ] unit-test
 
-[ { -1 -2 -3 -4 -5 3.14 } ] [
+{ { -1 -2 -3 -4 -5 3.14 } } [
     { -1 -2 -3 -4 -5 3.14 }
     "cstiqd" [ pack-be ] keep unpack-be
 ] unit-test
 
-[ { -1 -2 -3 -4 -5 } ] [
+{ { -1 -2 -3 -4 -5 } } [
     { -1 -2 -3 -4 -5 }
     "cstiq" [ pack-native ] keep unpack-native
 ] unit-test
 
-[ 2 ] [
-    [ 2 "int" b, ] B{ } make
-    <string-reader> [ "int" read-native ] with-input-stream
-] unit-test
+{ B{ 1 2 3 4 5 0 0 0 } } [ { 1 2 3 4 5 } "4ci" pack-le ] unit-test
+{ { 1 2 3 4 5 } } [ B{ 1 2 3 4 5 0 0 0 } "4ci" unpack-le ] unit-test
+
+{ 9 } [ "iic" packed-length ] unit-test
+[ "iii" read-packed-le ] must-infer
+[ "iii" read-packed-be ] must-infer
+[ "iii" read-packed-native ] must-infer
+[ "iii" unpack-le ] must-infer
+[ "iii" unpack-be ] must-infer
+[ "iii" unpack-native ] must-infer
+[ "iii" pack ] must-infer
+[ "iii" unpack ] must-infer
+
+[ "iii" pack ] must-infer
 
-[ "FRAM" ] [ "FRAM\0" [ read-c-string ] with-string-reader ] unit-test
-[ f ] [ "" [ read-c-string ] with-string-reader ] unit-test
-[ 5 ] [ "FRAM\0\u000005\0\0\0\0\0\0\0" [ read-c-string drop read-u64 ] with-string-reader ] unit-test
+{ "c" } [ "1c" expand-pack-format ] unit-test
+{ "cccc" } [ "4c" expand-pack-format ] unit-test
+{ "cccccccccccc" } [ "12c" expand-pack-format ] unit-test
+{ "iccqqq" } [ "1i2c3q" expand-pack-format ] unit-test
 
+{ B{ 1 0 0 0 } } [ 1 int32_t >n-byte-array ] unit-test