Skip to content

Commit

Permalink
FIX: FIND/PART not working after skipping the series
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Oct 23, 2018
1 parent 26dd2cd commit 88a9d14
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/t-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ static struct {
args = Find_Refines(ds, ALL_FIND_REFS);
// if (ANY_BLOCK(arg) || args) {
len = ANY_BLOCK(arg) ? VAL_BLK_LEN(arg) : 1;
if (args & AM_FIND_PART) tail = Partial1(value, D_ARG(ARG_FIND_LENGTH));
if (args & AM_FIND_PART) tail = index + Partial1(value, D_ARG(ARG_FIND_LENGTH));
ret = 1;
if (args & AM_FIND_SKIP) ret = Int32s(D_ARG(ARG_FIND_SIZE), 1);
ret = Find_Block(ser, index, tail, arg, len, args, ret);
Expand Down
2 changes: 1 addition & 1 deletion src/core/t-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)

if (ANY_BINSTR(arg)) len = VAL_LEN(arg);

if (args & AM_FIND_PART) tail = Partial(value, 0, D_ARG(ARG_FIND_LENGTH), 0);
if (args & AM_FIND_PART) tail = index + Partial(value, 0, D_ARG(ARG_FIND_LENGTH), 0);
ret = 1; // skip size
if (args & AM_FIND_SKIP) ret = Partial(value, 0, D_ARG(ARG_FIND_SIZE), 0);

Expand Down
1 change: 1 addition & 0 deletions src/tests/run-tests.r3
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ wrap load %units/protect-test.r3
wrap load %units/crash-test.r3
wrap load %units/bincode-test.r3
wrap load %units/codecs-test.r3
wrap load %units/series-test.r3

recycle/torture
recycle
Expand Down
47 changes: 47 additions & 0 deletions src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Rebol [
Title: "Rebol series test script"
Author: "Oldes"
File: %series-test.r3
Tabs: 4
Needs: [%../quick-test-module.r3]
]

~~~start-file~~~ "Series"

===start-group=== "FIND & SELECT"

--test-- "SELECT or FIND NONE! anything == none - #473"
--assert none? find none 1
--assert none? select none 1

--test-- "FIND"
--assert none? find/part [x] 'x 0
--assert equal? [x] find/part [x] 'x 1
--assert equal? [x] find/reverse tail [x] 'x
--assert equal? [y] find/match [x y] 'x
--assert equal? [x] find/last [x] 'x
--assert equal? [x] find/last [x x x] 'x

--test-- https://github.com/rebol/rebol-issues/issues/66
--assert none? find/skip [1 2 3 4 5 6] 2 3

--test-- https://github.com/rebol/rebol-issues/issues/88
--assert "c" = find "abc" charset ["c"]
--assert none? find/part "ab" "b" 1

--test-- https://github.com/rebol/rebol-issues/issues/2324
str: "1.1.1"
--assert "1.1.1" == find/part str "1." 2
str: skip str 2
--assert "1.1" == find str "1."
--assert "1.1" == find/part str "1." 2

--test-- "SELECT"
--assert 2 = select/part [1 2 1 3 1 2] 1 2
--assert none? select/part [1 2 1 3 1 2] 2 2
--assert 3 = select/part (skip [1 2 1 3 1 2] 2) 1 2


===end-group===

~~~end-file~~~

0 comments on commit 88a9d14

Please sign in to comment.