<commit_before>require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/array/subtend_array'

context "SubtendArray" do
  setup do
    @s = SubtendArray.new
  end
  
  specify "rb_ary_new should return an empty array" do
    @s.new_array.should == []
  end
  
  specify "rb_ary_push should add an element to an array" do
    @s.rb_ary_push([], 4).should == [4]
  end
  
  specify "rb_ary_push2 should add elements to an array" do
    o = Object.new
    @s.rb_ary_push2([], 4, o).should == [4,o]
  end

  specify "rb_ary_entry should return nil when called with an empty array" do
    @s.rb_ary_entry([], 0).should == nil
  end

  specify "rb_ary_entry should wrap around the offset if it's negative" do
    @s.rb_ary_entry([1, 2, 3], -1).should == 3
    @s.rb_ary_entry([1, 2, 3], -2).should == 2
  end

  specify "rb_ary_entry should return nil if the index is out of range" do
    @s.rb_ary_entry([1, 2, 3], 3).should == nil
    @s.rb_ary_entry([1, 2, 3], -10).should == nil
  end

  specify "rb_ary_clear should remove all elements from the array" do
    @s.rb_ary_clear([]).should == []
    @s.rb_ary_clear([1, 2, 3]).should == []
  end

  specify "rb_ary_dup should duplicate the array" do
    @s.rb_ary_dup([]).should == []

    a = [1, 2, 3]
    b = @s.rb_ary_dup(a)

    b.should == a
    b.should_not equal?(a)
  end

  specify "rb_ary_unshift should prepend the element to the array" do
    a = [1, 2, 3]
    a.unshift("a").should == ["a", 1, 2, 3]
    a.should == ['a', 1, 2, 3]<commit_msg>Actually exercise rb_ary_unshift() in the spec.<commit_after>require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/array/subtend_array'

context "SubtendArray" do
  setup do
    @s = SubtendArray.new
  end
  
  specify "rb_ary_new should return an empty array" do
    @s.new_array.should == []
  end
  
  specify "rb_ary_push should add an element to an array" do
    @s.rb_ary_push([], 4).should == [4]
  end
  
  specify "rb_ary_push2 should add elements to an array" do
    o = Object.new
    @s.rb_ary_push2([], 4, o).should == [4,o]
  end

  specify "rb_ary_entry should return nil when called with an empty array" do
    @s.rb_ary_entry([], 0).should == nil
  end

  specify "rb_ary_entry should wrap around the offset if it's negative" do
    @s.rb_ary_entry([1, 2, 3], -1).should == 3
    @s.rb_ary_entry([1, 2, 3], -2).should == 2
  end

  specify "rb_ary_entry should return nil if the index is out of range" do
    @s.rb_ary_entry([1, 2, 3], 3).should == nil
    @s.rb_ary_entry([1, 2, 3], -10).should == nil
  end

  specify "rb_ary_clear should remove all elements from the array" do
    @s.rb_ary_clear([]).should == []
    @s.rb_ary_clear([1, 2, 3]).should == []
  end

  specify "rb_ary_dup should duplicate the array" do
    @s.rb_ary_dup([]).should == []

    a = [1, 2, 3]
    b = @s.rb_ary_dup(a)

    b.should == a
    b.should_not equal?(a)
  end

  specify "rb_ary_unshift should prepend the element to the array" do
    a = [1, 2, 3]
    @s.rb_ary_unshift(a, "a").should == ["a", 1, 2, 3]
    a.should == ['a', 1, 2, 3]
{'fraction_non_alphanumeric': 0.14524959742351046, 'fraction_numerical': 0.02640901771336554, 'mean_word_length': 3.0976253298153034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4302540', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1186, 'n_words': 353}