<commit_before>shared :array_indexes do |cmd|
  describe "Array##{cmd}" do
    it "returns elements at integer argument indexes (DEPRECATED)" do
      array = [1, 2, 3, 4, 5]

      x = mock('4')
      def x.to_int() 4 end

      params = [1, 0, 5, -1, -8, 10, x]
      array.send(cmd, *params).should == array.values_at(*params)
    end
    
    it "calls to_int on arguments" do
      array = [1, 2, 3, 4, 5]

      x = mock('4')
      def x.to_int() 4 end
      array.send(cmd, x).should == [5]

      x = mock('2')
      x.should_receive(:respond_to?).with(:to_int).any_number_of_times.and_return(true)
      x.should_receive(:method_missing).with(:to_int).and_return(2)
      array.send(cmd, x).should == [3]
    end

    it "returns elements in range arguments as nested arrays (DEPRECATED)" do<commit_msg>Updated Array#indexes and Array#indices specs for compatibility with 1.8.7.<commit_after>shared :array_indexes do |cmd|
  describe "Array##{cmd}" do
    it "returns elements at integer argument indexes (DEPRECATED)" do
      array = [1, 2, 3, 4, 5]

      x = mock('4')
      def x.to_int() 4 end

      params = [1, 0, 5, -1, -8, 10, x]
      array.send(cmd, *params).should == array.values_at(*params)
    end
    
    it "tries to convert the passed arguments to Integers using #to_int" do
      obj = mock('to_int')
      obj.should_receive(:to_int).and_return(1, 3)
      [1, 2, 3, 4, 5].send(cmd, obj, obj).should == [2, 4]
    end

    ruby_version_is "" ... "1.8.7" do
      it "checks whether the passed arguments respond to #to_int" do
        obj = mock('method_missing to_int')
        obj.should_receive(:respond_to?).with(:to_int).any_number_of_times.and_return(true)
        obj.should_receive(:method_missing).with(:to_int).twice.and_return(1, 3)
        [1, 2, 3, 4, 5].send(cmd, obj, obj).should == [2, 4]
      end
    end

    ruby_version_is "1.8.7" do
      it "checks whether the passed arguments respond to #to_int (including private methods)" do
        obj = mock('method_missing to_int')
        obj.should_receive(:respond_to?).with(:to_int, true).any_number_of_times.and_return(true)
        obj.should_receive(:method_missing).with(:to_int).twice.and_return(1, 3)
        [1, 2, 3, 4, 5].send(cmd, obj, obj).should == [2, 4]
      end
    end

    it "returns elements in range arguments as nested arrays (DEPRECATED)" do
{'fraction_non_alphanumeric': 0.14219212865002115, 'fraction_numerical': 0.031739314430808296, 'mean_word_length': 2.9334442595673877, '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': '1860052', 'n_tokens_mistral': 891, 'n_tokens_neox': 821, 'n_words': 228}