Skip to content

Commit

Permalink
Broken additional interval skip list deletion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansobo committed Jan 22, 2008
1 parent 229af46 commit 5981e11
Showing 1 changed file with 167 additions and 54 deletions.
221 changes: 167 additions & 54 deletions spec/runtime/interval_skip_list/delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class IntervalSkipList
public :insert_node, :delete_node, :head, :nodes
end

describe IntervalSkipList, " with nodes of height 1, 3, 1, 2, 3" do
describe IntervalSkipList, " with nodes of height 3, 2, 1, 3, 1, 2, 3" do
attr_reader :list, :node
include IntervalSkipListSpecHelper

Expand All @@ -15,14 +15,18 @@ class IntervalSkipList

it_should_behave_like "#next_node_height is deterministic"
def expected_node_heights
[1, 3, 1, 2, 3]
[3, 2, 1, 3, 1, 2, 3]
end

before do
list.insert(1..3, :a)
list.insert(1..5, :b)
list.insert(1..7, :c)
list.insert(1..9, :d)
list.insert(1..11, :e)
list.insert(1..13, :f)
list.insert(1..9, :g)
list.insert(5..13, :h)
end

describe " #nodes" do
Expand All @@ -31,13 +35,25 @@ def expected_node_heights
@node = list.nodes[0]
end

it "has a key of 1 and a height of 1" do
it "has a key of 1 and a height of 3" do
node.key.should == 1
node.height.should == 1
node.height.should == 3
end

it "has :a, :b, :c, :d as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:a, :b, :c, :d)
it "has :c, :d, :e, :f, and :g as its only forward markers at level 2" do
node.forward_markers[2].should have_markers(:c, :d, :e, :f, :g)
end

it "has :a, :b as its only forward markers at level 1" do
node.forward_markers[1].should have_markers(:a, :b)
end

it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no markers" do
node.markers.should be_empty
end
end

Expand All @@ -46,22 +62,22 @@ def expected_node_heights
@node = list.nodes[1]
end

it "has a key of 3 and a height of 3" do
it "has a key of 3 and a height of 2" do
node.key.should == 3
node.height.should == 3
end

it "has :d as its only forward marker at level 2" do
node.forward_markers[2].should have_marker(:d)
node.height.should == 2
end

it "has :c as its only forward marker at level 1" do
node.forward_markers[1].should have_marker(:c)
it "has no forward markers at level 1" do
node.forward_markers[1].should be_empty
end

it "has :b as its only forward marker at level 0" do
node.forward_markers[0].should have_marker(:b)
end

it "has :a and :b as its only markers" do
node.markers.should have_markers(:a, :b)
end
end

describe "[2]" do
Expand All @@ -74,8 +90,8 @@ def expected_node_heights
node.height.should == 1
end

it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
it "has :h as its only forward marker at level 0" do
node.forward_markers[0].should have_marker(:h)
end

it "has :b as its only marker" do
Expand All @@ -88,8 +104,54 @@ def expected_node_heights
@node = list.nodes[3]
end

it "has a key of 7 and a height of 2" do
it "has a key of 7 and a height of 3" do
node.key.should == 7
node.height.should == 3
end

it "has :f as its only forward markers at level 2" do
node.forward_markers[2].should have_marker(:f)
end

it "has :e as its only forward markers at level 1" do
node.forward_markers[1].should have_marker(:e)
end

it "has :d, :h as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:d, :h)
end

it "has :c, :d, :e, :f, :g and :h as its only markers" do
node.markers.should have_markers(:c, :d, :e, :f, :h)
end
end

describe "[4]" do
before do
@node = list.nodes[4]
end

it "has a key of 9 and a height of 1" do
node.key.should == 9
node.height.should == 1
end

it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
end

it "has :d and :g as its only markers" do
node.markers.should have_marker(:d, :g)
end
end

describe "[5]" do
before do
@node = list.nodes[5]
end

it "has a key of 11 and a height of 2" do
node.key.should == 11
node.height.should == 2
end

Expand All @@ -98,18 +160,18 @@ def expected_node_heights
node.forward_markers[1].should be_empty
end

it "has :c as its only marker" do
node.markers.should have_marker(:c)
it "has :e as its only marker" do
node.markers.should have_marker(:e)
end
end

describe "[4]" do
describe "[6]" do
before do
@node = list.nodes[4]
@node = list.nodes[6]
end

it "has a key of 9 and a height of 3" do
node.key.should == 9
it "has a key of 13 and a height of 3" do
node.key.should == 13
node.height.should == 3
end

Expand All @@ -119,81 +181,132 @@ def expected_node_heights
node.forward_markers[2].should be_empty
end

it "has :d as its only marker" do
node.markers.should have_marker(:d)
it "has :f as its only marker" do
node.markers.should have_marker(:f)
end
end
end

describe " when :a is deleted" do
describe " when :c is deleted" do
before do
list.delete(:a)
list.delete(:c)
end
describe " nodes[0]" do

describe "[0]" do
before do
@node = list.nodes[0]
end

it "has a key of 1 and a height of 1" do
it "has a key of 1 and a height of 3" do
node.key.should == 1
node.height.should == 1
node.height.should == 3
end

it "has :b, :c, :d as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:b, :c, :d)
it "has :f as its only forward marker at level 2" do
node.forward_markers[2].should have_marker(:f)
end

it "has :a, :b, :d, :e as its only forward markers at level 1" do
node.forward_markers[1].should have_markers(:a, :b, :d, :e)
end

it "has no forward markers at level 0" do
node.forward_markers[0].should be_empty
end

it "has no markers" do
node.markers.should be_empty
end
end

describe " nodes[1]" do
describe "[1]" do
before do
@node = list.nodes[1]
end

it "has a key of 3 and a height of 2" do
node.key.should == 3
node.height.should == 2
end

it "has :e as its only forward marker at level 1" do
node.forward_markers[1].should have_marker(:e)
end

it "has :b and :d as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:b, :d)
end

it "has :b, :d, and :e as its only markers" do
node.markers.should have_markers(:b, :d, :e)
end
end

describe "[2]" do
before do
@node = list.nodes[2]
end

it "has a key of 5 and a height of 1" do
node.key.should == 5
node.height.should == 1
end

it "has :d and :c as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:c, :d)
it "has :b and :d as its only forward markers at level 0" do
node.forward_markers[0].should have_markers(:b, :d)
end

it "has :d, :b, and :c as its only markers" do
node.markers.should have_markers(:b, :c, :d)
it "has :b and :d as its only markers" do
node.markers.should have_markers(:b, :d)
end
end

describe " nodes[2]" do
describe "[3]" do
before do
@node = list.nodes[2]
@node = list.nodes[3]
end

it "has a key of 7 and a height of 2" do
node.key.should == 7
node.height.should == 2
it "has a key of 9 and a height of 1" do
node.key.should == 9
node.height.should == 1
end

it "has :d as its only forard marker at level 1" do
node.forward_markers[1].should have_marker(:d)
it "has :e as its only forward marker at level 0" do
node.forward_markers[0].should have_marker(:e)
end

it "has no forward markers at level 0" do
it "has :d and :e as its only markers" do
node.markers.should have_markers(:d, :e)
end
end

describe "[4]" do
before do
@node = list.nodes[4]
end

it "has a key of 11 and a height of 2" do
node.key.should == 11
node.height.should == 2
end

it "has no forward markers at any level" do
node.forward_markers[0].should be_empty
node.forward_markers[1].should be_empty
end

it "has :d and :c as its only markers" do
node.markers.should have_markers(:c, :d)
it "has :e as its only marker" do
node.markers.should have_marker(:e)
end
end

describe " nodes[3]" do
describe "[5]" do
before do
@node = list.nodes[3]
@node = list.nodes[5]
end

it "has a key of 9 and a height of 3" do
node.key.should == 9
it "has a key of 13 and a height of 3" do
node.key.should == 13
node.height.should == 3
end

Expand All @@ -203,8 +316,8 @@ def expected_node_heights
node.forward_markers[2].should be_empty
end

it "has :d as its only marker" do
node.markers.should have_marker(:d)
it "has :f as its only marker" do
node.markers.should have_marker(:f)
end
end
end
Expand Down

0 comments on commit 5981e11

Please sign in to comment.