-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtest_remove.rb
More file actions
41 lines (36 loc) · 1.09 KB
/
test_remove.rb
File metadata and controls
41 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
covers 'facets/array/remove'
test_case Array do
method :remove do
test do
a = [1,1,2,3]
a.difference([1]).assert == [ 2,3]
(a - [1]).assert == [ 2,3]
a.remove( [1]).assert == [ 1,2,3]
a.assert == [1,1,2,3]
end
test do
a = [1,1,2,3]
(a - [1]).assert == [ 2,3]
a.remove([1, 1, 1]).assert == [ 2,3]
a.assert == [1,1,2,3]
end
test 'example from Array#- docs' do
a = [ 1, 1, 2, 2, 3, 3, 4, 5 ]
(a - [ 1, 2, 4 ]).assert == [ 3, 3, 5 ]
a.remove([1, 2, 4 ]).assert == [ 1, 2, 3, 3, 5 ]
end
test 'element that is not found' do
a = [1,1,2,3]
(a - [4]).assert == [1,1,2,3]
a.remove([4]).assert == [1,1,2,3]
a.assert == [1,1,2,3]
end
end
method :remove! do
test do
a = [1,1,2,3]
a.remove!([1]).assert == [ 1,2,3]
a.assert == [ 1,2,3]
end
end
end