2004-08-16 21:11:27 -04:00
|
|
|
IN: scratchpad
|
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
|
|
|
|
|
2004-12-12 23:49:44 -05:00
|
|
|
[ f ] [ "a" "b" "c" =? ] unit-test
|
|
|
|
[ "c" ] [ "a" "a" "c" =? ] unit-test
|
|
|
|
|
2004-08-16 21:11:27 -04:00
|
|
|
[ f ] [ "A string." f-or-"" ] unit-test
|
|
|
|
[ t ] [ "" f-or-"" ] unit-test
|
|
|
|
[ t ] [ f f-or-"" ] unit-test
|
|
|
|
|
|
|
|
[ "abc" ] [ [ "a" "b" "c" ] cat ] unit-test
|
|
|
|
|
|
|
|
[ "abc" ] [ "ab" "c" cat2 ] unit-test
|
|
|
|
[ "abc" ] [ "a" "b" "c" cat3 ] unit-test
|
|
|
|
|
|
|
|
[ 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
|
|
|
|
|
2004-11-15 12:33:21 -05:00
|
|
|
[ "Beginning" ] [ 9 "Beginning and end" str-head ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ f ] [ "I" "team" str-contains? ] unit-test
|
|
|
|
[ t ] [ "ea" "team" str-contains? ] unit-test
|
|
|
|
[ f ] [ "actore" "Factor" str-contains? ] unit-test
|
|
|
|
|
2004-11-15 12:33:21 -05:00
|
|
|
[ "end" ] [ 14 "Beginning and end" str-tail ] unit-test
|
2004-08-16 21:11:27 -04:00
|
|
|
|
|
|
|
[ "Beginning" " and end" ] [ "Beginning and end" 9 str/ ] unit-test
|
|
|
|
|
|
|
|
[ "Beginning" "and end" ] [ "Beginning and end" 9 str// ] unit-test
|
|
|
|
|
|
|
|
[ "hello" "world" ] [ "hello world" " " split1 ] unit-test
|
|
|
|
[ "goodbye" f ] [ "goodbye" " " split1 ] unit-test
|
|
|
|
[ "" "" ] [ "great" "great" split1 ] unit-test
|
|
|
|
|
|
|
|
[ "and end" ] [ "Beginning and end" "Beginning " str-head? ] unit-test
|
|
|
|
[ f ] [ "Beginning and end" "Beginning x" str-head? ] unit-test
|
|
|
|
[ f ] [ "Beginning and end" "eginning " str-head? ] unit-test
|
|
|
|
|
|
|
|
[ "Beginning" ] [ "Beginning and end" " and end" str-tail? ] unit-test
|
|
|
|
[ f ] [ "Beginning and end" "Beginning x" str-tail? ] unit-test
|
|
|
|
[ f ] [ "Beginning and end" "eginning " str-tail? ] unit-test
|
|
|
|
|
|
|
|
[ [ "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
|
|
|
|
|
|
|
|
[ 6 ]
|
|
|
|
[
|
|
|
|
[ "One" "Two" "Little" "Piggy" "Went" "To" "The" "Market" ]
|
|
|
|
max-str-length
|
|
|
|
] unit-test
|
|
|
|
|
2004-12-10 21:39:27 -05:00
|
|
|
[ "Hello world" ] [ "Hello world\n" "\n" str-tail? ] unit-test
|
|
|
|
[ f ] [ "Hello world" "\n" str-tail? ] unit-test
|
|
|
|
[ "" ] [ "\n" "\n" str-tail? ] unit-test
|
|
|
|
[ f ] [ "" "\n" str-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
|
|
|
|
|
|
|
|
[ t ] [ "abc" "abd" str-compare 0 < ] unit-test
|
|
|
|
[ t ] [ "z" "abd" str-compare 0 > ] unit-test
|
|
|
|
|
2004-09-04 01:05:50 -04:00
|
|
|
[ "fedcba" ] [ "abcdef" str-reverse ] unit-test
|
|
|
|
[ "edcba" ] [ "abcde" str-reverse ] 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"
|
|
|
|
[ LETTER? [ succ ] when ] str-each
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ "Replacing+spaces+with+plus" ]
|
|
|
|
[
|
|
|
|
"Replacing spaces with plus"
|
2004-12-18 23:35:20 -05:00
|
|
|
[ dup CHAR: \s = [ drop CHAR: + ] when ] str-map
|
2004-10-06 23:34:22 -04:00
|
|
|
]
|
|
|
|
unit-test
|