linked-list 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62b4e5579d6c21238cb03f34ea0c63663fff4b63869e9868a289c3d10f7820de
4
- data.tar.gz: e0ca2b939613e239bc6002f5a651dfda1a4cc9cbae99deb776f3f202ce9a43ce
3
+ metadata.gz: a70c658176bc2e924764731304a3f8dbb376306e35b9e016d41896a7b5790463
4
+ data.tar.gz: cde342c544b41d53f5c52eb3d592deed28a6bf79736b6a0f2dbb1ef2d78319a7
5
5
  SHA512:
6
- metadata.gz: 1621a53fdb15af75501b7b448d7cc24c145f8dfbbc273d9ce48a6214d489b10d0934193a91984989ea8a1132ae616da7ef00347579eb02a429dad3cb417eef19
7
- data.tar.gz: ea1d3442d075aa0cefd8df5095eeef2fb7e3dfb2d544dbeba5db5225373c042a2f008fd662ca7b9b39a36841f0101768196027f9e1006469e17e56ec26e550ab
6
+ metadata.gz: db29d3d0ec5195c12937ae63332a8dbb3ac891f6510441762f5a42d1acfce8de826d9a20a6af308e9b39a5fe33fcf92527c26d1ffd757c6814fb2c09ed4c34a4
7
+ data.tar.gz: 7723a09dc0858687eaf4ff6668e024ba8b7efd00cc202ab6eb067baffc52f645f6138d286cec946ccb30896b372345f91b601db5e8dee8900c65582ffe61577b
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.6
3
+ - 2.7
4
4
  cache: bundler
5
5
  env:
6
6
  CI: true
@@ -1,3 +1,14 @@
1
+ # 0.0.x / Unreleased
2
+
3
+
4
+ # 0.0.15 / 2020-05-26
5
+
6
+ ## Fixed
7
+
8
+ - Fixed bug when deleting the last node of the list. The @tail value was not updated if the @head value was updated.
9
+
10
+ [Compare v0.0.14...v0.0.15](https://github.com/spectator/linked-list/compare/v0.0.14...v0.0.15)
11
+
1
12
  # 0.0.14 / 2020-04-17
2
13
 
3
14
  ## Fixed
@@ -286,19 +286,19 @@ module LinkedList
286
286
  private
287
287
 
288
288
  def __unlink_node(node)
289
+ @head = node.next if node.prev.nil?
290
+ @tail = node.prev if node.next.nil?
291
+
289
292
  if node.prev.nil?
290
293
  node.next.prev = nil if node.next
291
- @head = node.next
292
294
  elsif node.next.nil?
293
295
  node.prev.next = nil if node.prev
294
- @tail = node.prev
295
296
  else
296
297
  node.prev.next, node.next.prev = node.next, node.prev
297
298
  end
298
299
  @length -= 1
299
300
  end
300
301
 
301
-
302
302
  def __to_matcher(val = nil, &block)
303
303
  raise ArgumentError, 'either value or block should be passed' if val && block_given?
304
304
  block = ->(e) { e == val } unless block_given?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Linked
4
4
  module List
5
- VERSION = '0.0.14'
5
+ VERSION = '0.0.15'
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '>= 1.3', '<= 2.0'
21
+ spec.add_development_dependency 'bundler', '>= 2.0', '< 3.0'
22
22
  spec.add_development_dependency 'coveralls', '~> 0'
23
23
  spec.add_development_dependency 'm', '~> 1.5', '>= 1.5.0'
24
24
  spec.add_development_dependency 'minitest', '>= 5.0', '<= 6.0'
@@ -510,20 +510,39 @@ describe LinkedList::List do
510
510
 
511
511
  it 'deletes value from head' do
512
512
  list.delete(node_1)
513
- assert_equal ['bar', 'baz'], list.to_a
514
- assert_equal 'bar', list.first
513
+ assert_equal [node_2.data, node_3.data], list.to_a
514
+ assert_equal node_2.data, list.first
515
+ assert_equal node_3.data, list.last
515
516
  end
516
517
 
517
518
  it 'deletes value from middle' do
518
519
  list.delete(node_2)
519
- assert_equal ['foo', 'baz'], list.to_a
520
+ assert_equal [node_1.data, node_3.data], list.to_a
521
+ assert_equal node_1.data, list.first
522
+ assert_equal node_3.data, list.last
520
523
  end
521
524
 
522
525
 
523
526
  it 'deletes value from tail' do
524
527
  list.delete(node_3)
525
- assert_equal ['foo', 'bar'], list.to_a
526
- assert_equal 'bar', list.last
528
+ assert_equal [node_1.data, node_2.data], list.to_a
529
+ assert_equal node_1.data, list.first
530
+ assert_equal node_2.data, list.last
531
+ end
532
+ end
533
+
534
+ describe 'delete edge cases' do
535
+ it 'resets original list state when deleting the last node of the list' do
536
+ assert_nil list.first
537
+ assert_nil list.last
538
+
539
+ list.push(node_1)
540
+ assert_equal node_1.data, list.first
541
+ assert_equal node_1.data, list.last
542
+
543
+ list.delete(node_1)
544
+ assert_nil list.first
545
+ assert_nil list.last
527
546
  end
528
547
  end
529
548
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Velikanau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- - - "<="
21
18
  - !ruby/object:Gem::Version
22
19
  version: '2.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.3'
30
- - - "<="
31
28
  - !ruby/object:Gem::Version
32
29
  version: '2.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: coveralls
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -48,22 +48,22 @@ dependencies:
48
48
  name: m
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 1.5.0
54
51
  - - "~>"
55
52
  - !ruby/object:Gem::Version
56
53
  version: '1.5'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.5.0
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 1.5.0
64
61
  - - "~>"
65
62
  - !ruby/object:Gem::Version
66
63
  version: '1.5'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.5.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: minitest
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.0.3
148
+ rubygems_version: 3.1.2
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Ruby implementation of Doubly Linked List, following some Ruby idioms.