Skip to content

Commit

Permalink
FIX: SORT/COMPARE is using reversed order when using integer as a res…
Browse files Browse the repository at this point in the history
…ult from the function

fixes: metaeducation/rebol-issues#2376
  • Loading branch information
Oldes committed May 24, 2019
1 parent 18e2d34 commit f65ffd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/t-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ static struct {
return -1;
}
if (IS_INTEGER(val)) {
if (VAL_INT64(val) > 0) return 1;
if (VAL_INT64(val) < 0) return 1;
if (VAL_INT64(val) == 0) return 0;
return -1;
}
if (IS_DECIMAL(val)) {
if (VAL_DECIMAL(val) > 0) return 1;
if (VAL_DECIMAL(val) < 0) return 1;
if (VAL_DECIMAL(val) == 0) return 0;
return -1;
}
Expand Down
2 changes: 2 additions & 0 deletions src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Rebol [
--test-- "SORT/compare"
;@@ https://github.com/rebol/rebol-issues/issues/720
--assert [3 2 1] = sort/compare [1 2 3] func [a b] [a > b]
;@@ https://github.com/rebol/rebol-issues/issues/2376
--assert [1 3 10] = sort/compare [1 10 3] func[x y][case [x > y [1] x < y [-1] true [0]]]

--test-- "SORT/skip/compare"
;@@ https://github.com/rebol/rebol-issues/issues/1152
Expand Down

0 comments on commit f65ffd9

Please sign in to comment.