Fixed empty strings, added stride tests.
This commit is contained in:
@ -117,3 +117,8 @@ e: test-compiler-off
|
|||||||
: test [ 123 111 + literal ] ;
|
: test [ 123 111 + literal ] ;
|
||||||
test 234 = assert
|
test 234 = assert
|
||||||
;e
|
;e
|
||||||
|
|
||||||
|
e: test-empty-string
|
||||||
|
: test s" " ;
|
||||||
|
test 0 = assert drop
|
||||||
|
;e
|
||||||
|
|||||||
@ -136,8 +136,10 @@ static int match(char sep, char ch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cell_t parse(cell_t sep, cell_t *ret) {
|
static cell_t parse(cell_t sep, cell_t *ret) {
|
||||||
while (g_sys.tin < g_sys.ntib &&
|
if (sep == ' ') {
|
||||||
match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; }
|
while (g_sys.tin < g_sys.ntib &&
|
||||||
|
match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; }
|
||||||
|
}
|
||||||
*ret = (cell_t) (g_sys.tib + g_sys.tin);
|
*ret = (cell_t) (g_sys.tib + g_sys.tin);
|
||||||
while (g_sys.tin < g_sys.ntib &&
|
while (g_sys.tin < g_sys.ntib &&
|
||||||
!match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; }
|
!match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; }
|
||||||
|
|||||||
@ -70,3 +70,33 @@ e: test-see-fornext
|
|||||||
see test
|
see test
|
||||||
out: : test >R DONEXT ;
|
out: : test >R DONEXT ;
|
||||||
;e
|
;e
|
||||||
|
|
||||||
|
e: test-string-strides
|
||||||
|
: test0 1 if ." " then ;
|
||||||
|
: test1 1 if ." >" then ;
|
||||||
|
: test2 1 if ." ->" then ;
|
||||||
|
: test3 1 if ." -->" then ;
|
||||||
|
: test4 1 if ." --->" then ;
|
||||||
|
: test5 1 if ." ---->" then ;
|
||||||
|
: test6 1 if ." ----->" then ;
|
||||||
|
: test7 1 if ." ------>" then ;
|
||||||
|
: test8 1 if ." ------->" then ;
|
||||||
|
see test0
|
||||||
|
out: : test0 1 0BRANCH s" " type ;
|
||||||
|
see test1
|
||||||
|
out: : test1 1 0BRANCH s" >" type ;
|
||||||
|
see test2
|
||||||
|
out: : test2 1 0BRANCH s" ->" type ;
|
||||||
|
see test3
|
||||||
|
out: : test3 1 0BRANCH s" -->" type ;
|
||||||
|
see test4
|
||||||
|
out: : test4 1 0BRANCH s" --->" type ;
|
||||||
|
see test5
|
||||||
|
out: : test5 1 0BRANCH s" ---->" type ;
|
||||||
|
see test6
|
||||||
|
out: : test6 1 0BRANCH s" ----->" type ;
|
||||||
|
see test7
|
||||||
|
out: : test7 1 0BRANCH s" ------>" type ;
|
||||||
|
see test8
|
||||||
|
out: : test8 1 0BRANCH s" ------->" type ;
|
||||||
|
;e
|
||||||
|
|||||||
Reference in New Issue
Block a user