Merge branch 'master' of git://factorcode.org/git/factor

db4
Daniel Ehrenberg 2008-02-01 16:19:27 -06:00
commit b7a4e2c6bc
8 changed files with 42 additions and 29 deletions

View File

@ -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

View File

@ -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 ]

View File

@ -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

View File

@ -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

View File

@ -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 ;

View File

@ -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 <datagram>
"d" get send
] unit-test
[ "HELLO" t ] [
[ "hello world" t ] [
"d" get receive
server-addr =
>r >string r>

View File

@ -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 <&>

View File

@ -17,7 +17,7 @@ TUPLE: foo-gadget ;
T{ foo-gadget } <toolbar> "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 <model> {