diff options
| author | Austin Ziegler <austin@halostatue.ca> | 2011-08-01 13:46:14 -0400 |
|---|---|---|
| committer | Austin Ziegler <austin@halostatue.ca> | 2011-08-01 13:46:14 -0400 |
| commit | 0cd7c7a6855b8439edb5b48fa71f9d7ebdc3344a (patch) | |
| tree | f6ac624cfe3c48776a20c2b35702e7c3517c5c11 /spec | |
| parent | d3ae2094927ca241e339aea21d7439ace86c364c (diff) | |
| download | diff-lcs-0cd7c7a6855b8439edb5b48fa71f9d7ebdc3344a.tar.gz | |
Fixing an error in helper balanced_reverse sorting
Found with rbx-head, Array#sort_by isn't a stable sort in rbx but
appears to be in most other Rubies. Thus the array
[ [ '-', 1, 1 ],
[ '-', 1, 2 ],
[ '-', 2, 2 ] ]
would be sorted properly with the code
#sort_by { |line| line[1] }
on most Rubies, but rbx might sort it as
[ [ '-', 1, 2 ],
[ '-', 1, 1 ],
[ '-', 2, 2 ] ]
Changing the sort to
#sort_by { |line| [ line[1], line[2] ] }
fixes this.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/spec_helper.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 60ee9e9..ff8fa71 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -142,7 +142,7 @@ module Diff::LCS::SpecHelper end new_result << line } - new_result.sort_by { |line| line[1] } + new_result.sort_by { |line| [ line[1], line[2] ] } end def map_to_no_change(change_result) |
