diff --git a/core/ascii/ascii-tests.factor b/core/ascii/ascii-tests.factor new file mode 100644 index 0000000000..ec76d89d7c --- /dev/null +++ b/core/ascii/ascii-tests.factor @@ -0,0 +1,15 @@ +IN: temporary +USING: ascii tools.test sequences kernel math ; + +[ t ] [ CHAR: a letter? ] unit-test +[ f ] [ CHAR: A letter? ] unit-test +[ f ] [ CHAR: a LETTER? ] unit-test +[ t ] [ CHAR: A LETTER? ] unit-test +[ t ] [ CHAR: 0 digit? ] unit-test +[ f ] [ CHAR: x digit? ] unit-test + + +[ 4 ] [ + 0 "There are Four Upper Case characters" + [ LETTER? [ 1+ ] when ] each +] unit-test diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index 213f0868c0..b00e8e26b4 100755 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -8,13 +8,13 @@ IN: temporary [ 1 CHAR: a ] [ 0 "abcd" next-char ] unit-test - [ 6 CHAR: \s ] + [ 8 CHAR: \s ] [ 1 "\\u000020hello" next-escape ] unit-test [ 2 CHAR: \n ] [ 1 "\\nhello" next-escape ] unit-test - [ 6 CHAR: \s ] + [ 8 CHAR: \s ] [ 0 "\\u000020hello" next-char ] unit-test [ 1 [ 2 [ 3 ] 4 ] 5 ] diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index e988a62feb..73ae4737ba 100755 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -235,12 +235,12 @@ unit-test [ 11 10 nth ] unit-test-fails [ -1./0. 0 delete-nth ] unit-test-fails -[ "" ] [ "" [ blank? ] trim ] unit-test -[ "" ] [ "" [ blank? ] left-trim ] unit-test -[ "" ] [ "" [ blank? ] right-trim ] unit-test -[ "" ] [ " " [ blank? ] left-trim ] unit-test -[ "" ] [ " " [ blank? ] right-trim ] unit-test -[ "asdf" ] [ " asdf " [ blank? ] trim ] unit-test -[ "asdf " ] [ " asdf " [ blank? ] left-trim ] unit-test -[ " asdf" ] [ " asdf " [ blank? ] right-trim ] unit-test +[ "" ] [ "" [ CHAR: \s = ] trim ] unit-test +[ "" ] [ "" [ CHAR: \s = ] left-trim ] unit-test +[ "" ] [ "" [ CHAR: \s = ] right-trim ] unit-test +[ "" ] [ " " [ CHAR: \s = ] left-trim ] unit-test +[ "" ] [ " " [ CHAR: \s = ] right-trim ] unit-test +[ "asdf" ] [ " asdf " [ CHAR: \s = ] trim ] unit-test +[ "asdf " ] [ " asdf " [ CHAR: \s = ] left-trim ] unit-test +[ " asdf" ] [ " asdf " [ CHAR: \s = ] right-trim ] unit-test diff --git a/core/strings/strings-tests.factor b/core/strings/strings-tests.factor index a3c49a08ba..5ab7f1dffe 100755 --- a/core/strings/strings-tests.factor +++ b/core/strings/strings-tests.factor @@ -28,23 +28,11 @@ IN: temporary [ "end" ] [ "Beginning and end" 14 tail ] unit-test -[ t ] [ CHAR: a letter? ] unit-test -[ f ] [ CHAR: A letter? ] unit-test -[ f ] [ CHAR: a LETTER? ] unit-test -[ t ] [ CHAR: A LETTER? ] unit-test -[ t ] [ CHAR: 0 digit? ] unit-test -[ f ] [ CHAR: x digit? ] unit-test - [ t ] [ "abc" "abd" <=> 0 < ] unit-test [ t ] [ "z" "abd" <=> 0 > ] unit-test [ f ] [ [ 0 10 "hello" subseq ] catch not ] unit-test -[ 4 ] [ - 0 "There are Four Upper Case characters" - [ LETTER? [ 1+ ] when ] each -] unit-test - [ "Replacing+spaces+with+plus" ] [ "Replacing spaces with plus" @@ -67,6 +55,7 @@ unit-test [ { "kernel-error" 3 12 -7 } ] [ [ 2 -7 resize-string ] catch ] unit-test +! Make sure 24-bit strings work "hello world" "s" set [ ] [ HEX: 1234 1 "s" get set-nth ] unit-test @@ -90,3 +79,12 @@ unit-test ] [ "s" get >array ] unit-test + +! Make sure we clear aux vector when storing octets +[ "\u123456hi" ] [ "ih\u123456" clone dup reverse-here ] unit-test + +! Make sure aux vector is not shared +[ "\udeadbe" ] [ + "\udeadbe" clone + CHAR: \u123456 over clone set-first +] unit-test diff --git a/core/strings/strings.factor b/core/strings/strings.factor index dc1d12cec9..50c75d784e 100755 --- a/core/strings/strings.factor +++ b/core/strings/strings.factor @@ -37,7 +37,8 @@ M: string set-nth-unsafe dup reset-string-hashcode >r >fixnum >r >fixnum r> r> set-string-nth ; -M: string clone (clone) ; +M: string clone + (clone) dup string-aux clone over set-string-aux ; M: string resize resize-string ; diff --git a/extra/io/unix/unix-tests.factor b/extra/io/unix/unix-tests.factor index e49364fad3..8a621f8f48 100755 --- a/extra/io/unix/unix-tests.factor +++ b/extra/io/unix/unix-tests.factor @@ -1,6 +1,6 @@ USING: io.files io.sockets io kernel threads namespaces tools.test continuations strings byte-arrays sequences -prettyprint system unicode.case ; +prettyprint system ; IN: temporary ! Unix domain stream sockets @@ -56,7 +56,7 @@ yield "Receive 2" print - "d" get receive >r >upper r> + "d" get receive >r " world" append r> "Send 1" print dup . @@ -98,7 +98,7 @@ client-addr "d" get send ] unit-test -[ "HELLO" t ] [ +[ "hello world" t ] [ "d" get receive server-addr = >r >string r> diff --git a/extra/parser-combinators/parser-combinators-tests.factor b/extra/parser-combinators/parser-combinators-tests.factor index 8d55cc5770..fc8cec770b 100644 --- a/extra/parser-combinators/parser-combinators-tests.factor +++ b/extra/parser-combinators/parser-combinators-tests.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2005 Chris Double. ! See http://factorcode.org/license.txt for BSD license. -! USING: kernel lazy-lists tools.test strings math -sequences parser-combinators arrays math.parser ; +sequences parser-combinators arrays math.parser unicode.categories ; IN: scratchpad ! Testing <&> diff --git a/extra/ui/gadgets/buttons/buttons-tests.factor b/extra/ui/gadgets/buttons/buttons-tests.factor index a2786ea878..77dfd30d96 100755 --- a/extra/ui/gadgets/buttons/buttons-tests.factor +++ b/extra/ui/gadgets/buttons/buttons-tests.factor @@ -17,7 +17,7 @@ TUPLE: foo-gadget ; T{ foo-gadget } "t" set [ 2 ] [ "t" get gadget-children length ] unit-test -[ "Foo a" ] [ "t" get gadget-child gadget-child label-string ] unit-test +[ "Foo A" ] [ "t" get gadget-child gadget-child label-string ] unit-test [ ] [ 2 {