<commit_before>require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")

describe "#next_node_height is deterministic", :shared => true do
  before do
    node_heights = expected_node_heights.dup
    stub(list).next_node_height { node_heights.shift }
  end
end

describe "it is non-empty", :shared => true do
  specify "#empty? returns false" do
    list.should_not be_empty
  end
end

describe "#nodes is an array of the three inserted nodes in key order", :shared => true do
  specify "#nodes is an array of the three inserted nodes in key order" do
    list.nodes.should == inserted_nodes.sort_by(&:key)
  end
end

describe "it has nil forward pointers", :shared => true do
  it "has nil forward pointers" do
    inserted_node.forward.each do |next_pointer|
      next_pointer.should be_nil
    end
  end
end

class IntervalSkipList
  public :insert_node, :delete, :head
end

describe IntervalSkipList do
  attr_reader :list

  before do
    @list = IntervalSkipList.new
  end

  describe " when :a is inserted for interval 1..5" do
    def expected_node_heights
      [1,2]
    end

    it_should_behave_like "#next_node_height is deterministic"

    before do
      list.insert(1..5, :a)
    end

    describe "first node" do
      attr_reader :node

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

      it "has a key of 1" do
        node.key.should == 1<commit_msg>Cleanup<commit_after>require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")

class IntervalSkipList
  public :insert_node, :delete, :head
end

describe "#next_node_height is deterministic", :shared => true do
  before do
    node_heights = expected_node_heights.dup
    stub(list).next_node_height { node_heights.shift }
  end
end

describe "it is non-empty", :shared => true do
  specify "#empty? returns false" do
    list.should_not be_empty
  end
end

describe "#nodes is an array of the three inserted nodes in key order", :shared => true do
  specify "#nodes is an array of the three inserted nodes in key order" do
    list.nodes.should == inserted_nodes.sort_by(&:key)
  end
end

describe "it has nil forward pointers", :shared => true do
  it "has nil forward pointers" do
    inserted_node.forward.each do |next_pointer|
      next_pointer.should be_nil
    end
  end
end

describe IntervalSkipList do
  attr_reader :list

  before do
    @list = IntervalSkipList.new
  end

  describe " when :a is inserted for interval 1..5" do
    def expected_node_heights
      [1,2]
    end

    it_should_behave_like "#next_node_height is deterministic"

    before do
      list.insert(1..5, :a)
    end

    describe "first node" do
      attr_reader :node

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

      it "has a key of 1" do
        node.key.should == 1
{'fraction_non_alphanumeric': 0.08483105679367361, 'fraction_numerical': 0.006470165348670022, 'mean_word_length': 3.1475409836065573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751644', 'n_tokens_mistral': 906, 'n_tokens_neox': 875, 'n_words': 297}