2005-03-28 23:45:13 -05:00
|
|
|
IN: temporary
|
2004-08-27 02:09:24 -04:00
|
|
|
USE: errors
|
2004-08-16 21:11:27 -04:00
|
|
|
USE: kernel
|
2004-08-26 22:21:17 -04:00
|
|
|
USE: math
|
2004-08-16 21:11:27 -04:00
|
|
|
USE: namespaces
|
|
|
|
USE: strings
|
|
|
|
USE: test
|
2005-04-25 03:33:33 -04:00
|
|
|
USE: sequences
|
2005-04-30 01:12:23 -04:00
|
|
|
USE: lists
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-04-25 03:33:33 -04:00
|
|
|
[ "abc" ] [ [ "a" "b" "c" ] [ [ % ] each ] make-string ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
[ "abc" ] [ "ab" "c" append ] unit-test
|
|
|
|
[ "abc" ] [ "a" "b" "c" append3 ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ 3 ] [ "hola" "a" index-of ] unit-test
|
|
|
|
[ -1 ] [ "hola" "x" index-of ] unit-test
|
|
|
|
[ 0 ] [ "a" "" index-of ] unit-test
|
|
|
|
[ 0 ] [ "" "" index-of ] unit-test
|
|
|
|
[ 0 ] [ "hola" "hola" index-of ] unit-test
|
|
|
|
[ 1 ] [ "hola" "ol" index-of ] unit-test
|
|
|
|
[ -1 ] [ "hola" "amigo" index-of ] unit-test
|
|
|
|
[ -1 ] [ "hola" "holaa" index-of ] unit-test
|
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "Beginning" ] [ 9 "Beginning and end" string-head ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ f ] [ "I" "team" string-contains? ] unit-test
|
|
|
|
[ t ] [ "ea" "team" string-contains? ] unit-test
|
|
|
|
[ f ] [ "actore" "Factor" string-contains? ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "end" ] [ 14 "Beginning and end" string-tail ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-04-07 18:54:02 -04:00
|
|
|
[ "" 10 string/ ] unit-test-fails
|
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "Beginning" " and end" ] [ "Beginning and end" 9 string/ ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "Beginning" "and end" ] [ "Beginning and end" 9 string// ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ "hello" "world" ] [ "hello world" " " split1 ] unit-test
|
|
|
|
[ "goodbye" f ] [ "goodbye" " " split1 ] unit-test
|
|
|
|
[ "" "" ] [ "great" "great" split1 ] unit-test
|
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "and end" t ] [ "Beginning and end" "Beginning " ?string-head ] unit-test
|
|
|
|
[ "Beginning and end" f ] [ "Beginning and end" "Beginning x" ?string-head ] unit-test
|
|
|
|
[ "Beginning and end" f ] [ "Beginning and end" "eginning " ?string-head ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "Beginning" t ] [ "Beginning and end" " and end" ?string-tail ] unit-test
|
|
|
|
[ "Beginning and end" f ] [ "Beginning and end" "Beginning x" ?string-tail ] unit-test
|
|
|
|
[ "Beginning and end" f ] [ "Beginning and end" "eginning " ?string-tail ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ [ "This" "is" "a" "split" "sentence" ] ]
|
|
|
|
[ "This is a split sentence" " " split ]
|
|
|
|
unit-test
|
|
|
|
|
|
|
|
[ [ "OneWord" ] ]
|
|
|
|
[ "OneWord" " " split ]
|
|
|
|
unit-test
|
|
|
|
|
|
|
|
[ [ "a" "b" "c" "d" "e" "f" ] ]
|
|
|
|
[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test
|
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ "Hello world" t ] [ "Hello world\n" "\n" ?string-tail ] unit-test
|
|
|
|
[ "Hello world" f ] [ "Hello world" "\n" ?string-tail ] unit-test
|
|
|
|
[ "" t ] [ "\n" "\n" ?string-tail ] unit-test
|
|
|
|
[ "" f ] [ "" "\n" ?string-tail ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ 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
|
|
|
|
|
2005-03-05 16:33:40 -05:00
|
|
|
[ t ] [ "abc" "abd" string-compare 0 < ] unit-test
|
|
|
|
[ t ] [ "z" "abd" string-compare 0 > ] unit-test
|
2004-08-25 20:51:19 -04:00
|
|
|
|
2004-08-27 02:09:24 -04:00
|
|
|
[ f ] [ [ 0 10 "hello" substring ] [ not ] catch ] unit-test
|
2004-09-04 01:05:50 -04:00
|
|
|
|
|
|
|
[ [ "hell" "o wo" "rld" ] ] [ 4 "hello world" split-n ] unit-test
|
2004-10-06 23:34:22 -04:00
|
|
|
|
|
|
|
[ 4 ] [
|
|
|
|
0 "There are Four Upper Case characters"
|
2005-05-14 17:18:45 -04:00
|
|
|
[ LETTER? [ 1 + ] when ] each
|
2004-10-06 23:34:22 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ "Replacing+spaces+with+plus" ]
|
|
|
|
[
|
|
|
|
"Replacing spaces with plus"
|
2005-05-14 17:18:45 -04:00
|
|
|
[ dup CHAR: \s = [ drop CHAR: + ] when ] map
|
2004-10-06 23:34:22 -04:00
|
|
|
]
|
|
|
|
unit-test
|
2004-12-19 03:04:03 -05:00
|
|
|
|
2005-04-30 01:12:23 -04:00
|
|
|
[ "05" ] [ "5" 2 CHAR: 0 pad ] unit-test
|
|
|
|
[ "666" ] [ "666" 2 CHAR: 0 pad ] unit-test
|
2005-04-07 18:54:02 -04:00
|
|
|
|
|
|
|
[ 1 "" nth ] unit-test-fails
|
2005-05-05 22:30:58 -04:00
|
|
|
[ -6 "hello" nth ] unit-test-fails
|