fix count-matches and add unit test for it

db4
Doug Coleman 2008-11-22 21:10:53 -06:00
parent 6c5f761503
commit b00156bc85
2 changed files with 7 additions and 1 deletions

View File

@ -283,6 +283,12 @@ IN: regexp-tests
[ { "ABC" "DEF" "GHI" } ]
[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matches [ >string ] map ] unit-test
[ 3 ]
[ "1ABC2DEF3GHI4" R/ [A-Z]+/ count-matches ] unit-test
[ 0 ]
[ "123" R/ [A-Z]+/ count-matches ] unit-test
[ "1.2.3.4" ]
[ "1ABC2DEF3GHI4JK" R/ [A-Z]+/ "." re-replace ] unit-test

View File

@ -73,7 +73,7 @@ IN: regexp
[ dup ] swap '[ _ next-match ] [ ] produce nip harvest ;
: count-matches ( string regexp -- n )
all-matches length 1- ;
all-matches length ;
: initial-option ( regexp option -- regexp' )
over options>> conjoin ;