|
| 1 | +covers 'facets/array/delete_first_each' |
| 2 | + |
| 3 | +test_case Array do |
| 4 | + method :delete_first_each do |
| 5 | + test do |
| 6 | + a = [1,1,2,3] |
| 7 | + a.delete_first_each( [1]).assert == [ 1,2,3] |
| 8 | + a.difference([1]).assert == [ 2,3] |
| 9 | + (a - [1]).assert == [ 2,3] |
| 10 | + a.assert == [1,1,2,3] |
| 11 | + end |
| 12 | + |
| 13 | + test do |
| 14 | + a = [1,1,2,3] |
| 15 | + a.delete_first_each([1, 1]).assert == [ 2,3] |
| 16 | + (a - [1]).assert == [ 2,3] |
| 17 | + a.assert == [1,1,2,3] |
| 18 | + end |
| 19 | + |
| 20 | + test 'example from Array#- docs' do |
| 21 | + a = [ 1, 1, 2, 2, 3, 3, 4, 5 ] |
| 22 | + (a - [ 1, 2, 4 ]).assert == [ 3, 3, 5 ] |
| 23 | + a.delete_first_each([1, 2, 4 ]).assert == [ 1, 2, 3, 3, 5 ] |
| 24 | + end |
| 25 | + |
| 26 | + test 'element that is not found' do |
| 27 | + a = [1,1,2,3] |
| 28 | + (a - [4]).assert == [1,1,2,3] |
| 29 | + a.delete_first_each([ 4]).assert == [1,1,2,3] |
| 30 | + a.assert == [1,1,2,3] |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + method :delete_first_each! do |
| 35 | + test do |
| 36 | + a = [1,1,2,3] |
| 37 | + a.delete_first_each!([1]).assert == [ 1,2,3] |
| 38 | + a.assert == [ 1,2,3] |
| 39 | + end |
| 40 | + end |
| 41 | +end |
0 commit comments