Diff for /gforth/regexp-test.fs between versions 1.10 and 1.14

version 1.10, 2010/09/04 21:39:29 version 1.14, 2010/09/05 22:18:54
Line 118  s" fofoofoofofooofoobarbar" ?foos1 Line 118  s" fofoofoofofooofoobarbar" ?foos1
 s" bla baz bar" ?foos1  s" bla baz bar" ?foos1
 s" foofoofoo" ?foos1  s" foofoofoo" ?foos1
   
   \ backtracking on decissions
   
   : ?aab ( addr u -- flag )
      (( {{ =" aa" || =" a" }} {{ =" ab" || =" a" }} )) ;
   s" aab" ?aab 0= [IF] .( aab failed!) cr [THEN]
   
   \ buffer overrun test (bug in =")
   
   ." --- buffer overrun test ---" cr
   
    : ?long-string
       (( // \( =" abcdefghi" \) ))
       IF  \1 type  cr THEN ;
   
   here 4096 allocate throw 4096 + 8 - constant test-string
    s" abcdefgh" test-string swap cmove>
    .( provoking overflow [i.e. see valgrind output]) cr
    test-string . cr
    test-string 8 ?long-string
   .( done) cr
   
 \ simple replacement test  \ simple replacement test
     
 ." --- delnum test ---" cr  ." --- simple replacement test ---" cr
   
 : delnum  ( addr u -- addr' u' )   s// \d s" " //g ;  : delnum  ( addr u -- addr' u' )   s// \d >> s" " //g ;
 : 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  THEN ;     ELSE  2drop 2drop ." passed" cr  THEN ;
 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" a0"  s" a" test-delnum  s" a0"  s" a" test-delnum
 s" aa"  s" aa" test-delnum  s" aa"  s" aa" test-delnum
   
   : delcomment  ( addr u -- addr' u' )  s// ` # {** .? **} >> s" " //g ;
   s" hello # test " delcomment type cr
   : delparents  ( addr u -- addr' u' )  s// ` ( {* .? *} ` ) >> s" ()" //g ;
   s" delete (test) and (another test) " delparents type cr
   
 \ replacement tests  \ replacement tests
   
 ." --- replacement tests ---" cr  ." --- replacement tests ---" cr
   
 : hms>s ( addr u -- addr' u' )  : hms>s ( addr u -- addr' u' )
   s// \( \d \d \) ` : \( \d \d \) ` : \( \d \d \)    s// \( \d \d \) ` : \( \d \d \) ` : \( \d \d \) >>
   \1 s>number drop 60 *    \1 s>number drop 60 *
   \2 s>number drop + 60 *    \2 s>number drop + 60 *
   \3 s>number drop + 0 <# 's' hold #s #> //g ;    \3 s>number drop + 0 <# 's' hold #s #> //g ;
Line 147  s" bla 12:34:56 fasel 00:01:57 blubber" Line 173  s" bla 12:34:56 fasel 00:01:57 blubber"
 ."  replaced by " 2dup type  ."  replaced by " 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
   
   : hms>s,del() ( addr u -- addr' u' )
     s// {{ \( \d \d \) ` : \( \d \d \) ` : \( \d \d \)
            >> \1 s>number drop 60 *
               \2 s>number drop + 60 *
               \3 s>number drop + 0 <# 's' hold #s #> <<
            || ` ( // ` ) >> <<" "
         }} LEAVE //s ;
   
   \ doesn't work yet
   \ s" (bla) 12:34:56 (fasel) 00:01:57 (blubber)" 2dup type hms>s,del() space type cr
   
 script? [IF] bye [THEN]  script? [IF] bye [THEN]

Removed from v.1.10  
changed lines
  Added in v.1.14


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>