]> gitweb.factorcode.org Git - factor.git/blobdiff - core/strings/strings-tests.factor
use radix literals
[factor.git] / core / strings / strings-tests.factor
old mode 100755 (executable)
new mode 100644 (file)
index d10f160..3334ef0
@@ -1,6 +1,6 @@
-USING: continuations kernel math math.order namespaces strings
-strings.private sbufs tools.test sequences vectors arrays memory
-prettyprint io.streams.null ;
+USING: continuations kernel math math.order namespaces make
+strings strings.private sbufs tools.test sequences vectors
+arrays memory prettyprint io.streams.null ;
 IN: strings.tests
 
 [ CHAR: b ] [ 1 >bignum "abc" nth ] unit-test
@@ -43,8 +43,8 @@ IN: strings.tests
 ]
 unit-test
 
-[ "05" ] [ "5" 2 CHAR: 0 pad-left ] unit-test
-[ "666" ] [ "666" 2 CHAR: 0 pad-left ] unit-test
+[ "05" ] [ "5" 2 CHAR: 0 pad-head ] unit-test
+[ "666" ] [ "666" 2 CHAR: 0 pad-head ] unit-test
 
 [ 1 "" nth ] must-fail
 [ -6 "hello" nth ] must-fail
@@ -58,23 +58,28 @@ unit-test
 [ "\u001234bc\0\0\0" ] [ 6 "\u001234bc" resize-string ] unit-test
 
 ! Random tester found this
-[ 2 -7 resize-string ] [ { "kernel-error" 3 12 -7 } = ] must-fail-with
+[ 2 -7 resize-string ] [ { "kernel-error" 3 11 -7 } = ] must-fail-with
 
 ! Make sure 24-bit strings work
 "hello world" "s" set
 
-[ ] [ HEX: 1234 1 "s" get set-nth ] unit-test
-[ ] [ HEX: 4321 3 "s" get set-nth ] unit-test
-[ ] [ HEX: 654321 5 "s" get set-nth ] unit-test
+[ ] [ 0x1234 1 "s" get set-nth ] unit-test
+[ 0x1234 ] [ 1 "s" get nth ] unit-test
+
+[ ] [ 0x4321 3 "s" get set-nth ] unit-test
+[ 0x4321 ] [ 3 "s" get nth ] unit-test
+
+[ ] [ 0x654321 5 "s" get set-nth ] unit-test
+[ 0x654321 ] [ 5 "s" get nth ] unit-test
 
 [
     {
         CHAR: h
-        HEX: 1234
+        0x1234
         CHAR: l
-        HEX: 4321
+        0x4321
         CHAR: o
-        HEX: 654321
+        0x654321
         CHAR: w
         CHAR: o
         CHAR: r
@@ -85,8 +90,11 @@ unit-test
     "s" get >array
 ] unit-test
 
+! Make sure string initialization works
+[ 0x123456 ] [ 100 0x123456 <string> first ] unit-test
+
 ! Make sure we clear aux vector when storing octets
-[ "\u123456hi" ] [ "ih\u123456" clone dup reverse-here ] unit-test
+[ "\u123456hi" ] [ "ih\u123456" clone reverse! ] unit-test
 
 ! Make sure aux vector is not shared
 [ "\udeadbe" ] [
@@ -108,7 +116,7 @@ unit-test
             ] times
             .
         ] times
-    ] with-null-stream
+    ] with-null-writer
 ] unit-test
 
 [ t ] [
@@ -116,5 +124,12 @@ unit-test
         drop
         300 100 CHAR: \u123456
         [ <string> clone resize-string first ] keep =
-    ] all?
+    ] all-integers?
 ] unit-test
+
+"X" "s" set
+[ ] [ 0x100,0000 0 "s" get set-nth ] unit-test
+[ 0 ] [ 0 "s" get nth ] unit-test
+
+[ ] [ -1 0 "s" get set-nth ] unit-test
+[ 0x7fffff ] [ 0 "s" get nth ] unit-test