| \ You should have received a copy of the GNU General Public License |
\ You should have received a copy of the GNU General Public License |
| \ along with this program. If not, see http://www.gnu.org/licenses/. |
\ along with this program. If not, see http://www.gnu.org/licenses/. |
| |
|
| |
: ?depth depth IF ." unbalanced: " .s clearstack cr THEN ; |
| |
|
| charclass [bl-] blanks +class '-' +char |
charclass [bl-] blanks +class '-' +char |
| charclass [0-9(] '(' +char '0' '9' ..char |
charclass [0-9(] '(' +char '0' '9' ..char |
| |
|
| IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
| ELSE \0 type ." failed " THEN ; |
ELSE \0 type ." failed " THEN ; |
| |
|
| : ?tel-s ( addr u -- ) ?tel ." should succeed" space depth . cr ; |
: ?tel-s ( addr u -- ) ?tel ." should succeed" space cr ?depth ; |
| : ?tel-f ( addr u -- ) ?tel ." should fail" space depth . cr ; |
: ?tel-f ( addr u -- ) ?tel ." should fail" space cr ?depth ; |
| |
|
| ." --- Telephone number match ---" cr |
." --- Telephone number match ---" cr |
| s" (123) 456-7890" ?tel-s |
s" (123) 456-7890" ?tel-s |
| |
|
| : ?tel2 ( addr u -- ) telnum2 |
: ?tel2 ( addr u -- ) telnum2 |
| IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
IF '(' emit \1 type ." ) " \2 type '-' emit \3 type ." succeeded" |
| ELSE \0 type ." failed " THEN cr ; |
ELSE \0 type ." failed " THEN cr ?depth ; |
| ." --- Telephone number search ---" cr |
." --- Telephone number search ---" cr |
| s" blabla (123) 456-7890" ?tel2 |
s" blabla (123) 456-7890" ?tel2 |
| s" blabla (123) 456-7890 " ?tel2 |
s" blabla (123) 456-7890 " ?tel2 |
| |
|
| : ?num |
: ?num |
| (( // \( {++ [0-9,./:] c? ++} \) )) |
(( // \( {++ [0-9,./:] c? ++} \) )) |
| IF \1 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ELSE \0 type ." failed" THEN cr ?depth ; |
| |
|
| s" 1234" ?num |
s" 1234" ?num |
| s" 12,345abc" ?num |
s" 12,345abc" ?num |
| |
|
| : ?foos |
: ?foos |
| (( \( {** =" foo" **} \) )) |
(( \( {** =" foo" **} \) )) |
| IF \1 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ELSE \0 type ." failed" THEN cr ?depth ; |
| |
|
| : ?foobars |
: ?foobars |
| (( // \( {** =" foo" **} \) \( {++ =" bar" ++} \) )) |
(( // \( {** =" foo" **} \) \( {++ =" bar" ++} \) )) |
| IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ?depth ; |
| |
|
| : ?foos1 |
: ?foos1 |
| (( // \( {+ =" foo" +} \) \( {++ =" bar" ++} \) )) |
(( // \( {+ =" foo" +} \) \( {++ =" bar" ++} \) )) |
| IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ; |
IF \1 type ',' emit \2 type ELSE \0 type ." failed" THEN cr ?depth ; |
| |
|
| s" foobar" ?foos |
s" foobar" ?foos |
| s" foofoofoobar" ?foos |
s" foofoofoobar" ?foos |
| (( // \( =" abcdefghi" \) )) |
(( // \( =" abcdefghi" \) )) |
| IF \1 type cr THEN ; |
IF \1 type cr THEN ; |
| |
|
| here 4096 allocate throw 4096 + 8 - constant test-string |
4096 allocate throw 4096 + 8 - constant test-string |
| s" abcdefgh" test-string swap cmove> |
s" abcdefgh" test-string swap cmove> |
| .( provoking overflow [i.e. see valgrind output]) cr |
.( provoking overflow [i.e. see valgrind output]) cr |
| test-string . cr |
test-string . cr |
| test-string 8 ?long-string |
test-string 8 ?long-string |
| .( done) cr |
.( done) cr ?depth |
| |
|
| \ simple replacement test |
\ simple replacement test |
| |
|
| : test-delnum ( addr u addr' u' -- ) |
: test-delnum ( addr u addr' u' -- ) |
| 2swap delnum 2over 2over str= 0= IF |
2swap delnum 2over 2over str= 0= IF |
| ." test-delnum: got '" type ." ', expected '" type ." '" |
." test-delnum: got '" type ." ', expected '" type ." '" |
| ELSE 2drop 2drop ." passed" cr THEN ; |
ELSE 2drop 2drop ." test-delnum passed" cr THEN ?depth ; |
| s" 0" s" " test-delnum |
s" 0" s" " test-delnum |
| s" 00" s" " test-delnum |
s" 00" s" " test-delnum |
| s" 0a" s" a" test-delnum |
s" 0a" s" a" test-delnum |
| s" hello # test " delcomment type cr |
s" hello # test " delcomment type cr |
| : delparents ( addr u -- addr' u' ) s// ` ( {* .? *} ` ) >> s" ()" //g ; |
: delparents ( addr u -- addr' u' ) s// ` ( {* .? *} ` ) >> s" ()" //g ; |
| s" delete (test) and (another test) " delparents type cr |
s" delete (test) and (another test) " delparents type cr |
| |
?depth |
| |
|
| \ replacement tests |
\ replacement tests |
| |
|
| s" bla 12:34:56 fasel 00:01:57 blubber" 2dup type hms>s |
s" bla 12:34:56 fasel 00:01:57 blubber" 2dup type hms>s |
| ." -> " 2dup type |
." -> " 2dup type |
| s" bla 45296s fasel 117s blubber" str= [IF] .( ok) [ELSE] .( failed) [THEN] cr |
s" bla 45296s fasel 117s blubber" str= [IF] .( ok) [ELSE] .( failed) [THEN] cr |
| |
?depth |
| |
|
| : hms>s,del() ( addr u -- addr' u' ) |
: hms>s,del() ( addr u -- addr' u' ) |
| s// {{ \( \d \d \) ` : \( \d \d \) ` : \( \d \d \) |
s// {{ \( \d \d \) ` : \( \d \d \) ` : \( \d \d \) |