<commit_before>require_relative '../test_helper'

describe ExcEx do 
  before do 
    @exc_ex = ExcEx.new
  end

  describe '#matching' do 
    it 'must group generated matchers' do 
      string = @exc_ex.matching ['pizza', 'cheeseburgers']
      string.must_equal '(pizza|cheeseburgers)'
    end
  end

  describe '#any_number' do 
    it 'must append block with asterisk (*)' do 
      string = @exc_ex.any_number { 'pizza' }
      string[-1].must_equal '*'
    end
  end

  describe '#one_or_more' do 
    it 'must append block with plus sign (+)' do 
      string = @exc_ex.one_or_more { 'pizza' }
      string[-1].must_equal '+'
    end
  end

  describe '#exactly' do 
    it 'must append block with brackets and number of exact matches' do
      string = @exc_ex.exactly(2) { 'pizza' }
      string.must_equal 'pizza{2}'
    end
  end

  describe '#in_range' do 
    it 'must include both values passed in brackets' do 
      string = @exc_ex.in_range [3, 5] { 'pizza' }
      string.must_equal 'pizza{3,5}'
    end

    it 'must leave first element blank if nil is passed in' do 
      string = @exc_ex.in_range [nil, 5] { 'pizza' }
      string.must_equal 'pizza{,5}'
    end

    it 'must leave second element blank if nil is passed in' do 
      string = @exc_ex.in_range [3, nil] { 'pizza' }
      string.must_equal 'pizza{3,}'
    end
  end

end<commit_msg>add additional tests to ExcEx<commit_after>require_relative '../test_helper'

describe ExcEx do 
  before do 
    @exc_ex = ExcEx.new
  end

  describe '#matching' do 
    it 'must group generated matchers' do 
      string = @exc_ex.matching ['pizza', 'cheeseburgers']
      string.must_equal '(pizza|cheeseburgers)'
    end
  end

  describe '#any_number' do 
    it 'must append block with asterisk (*)' do 
      string = @exc_ex.any_number { 'pizza' }
      string[-1].must_equal '*'
    end
  end

  describe '#one_or_more' do 
    it 'must append block with plus sign (+)' do 
      string = @exc_ex.one_or_more { 'pizza' }
      string[-1].must_equal '+'
    end
  end

  describe '#exactly' do 
    it 'must append block with brackets and number of exact matches' do
      string = @exc_ex.exactly(2) { 'pizza' }
      string.must_equal 'pizza{2}'
    end
  end

  describe '#in_range' do 
    it 'must include both values passed in brackets' do 
      string = @exc_ex.in_range [3, 5] { 'pizza' }
      string.must_equal 'pizza{3,5}'
    end

    it 'must leave first element blank if nil is passed in' do 
      string = @exc_ex.in_range [nil, 5] { 'pizza' }
      string.must_equal 'pizza{,5}'
    end

    it 'must leave second element blank if nil is passed in' do 
      string = @exc_ex.in_range [3, nil] { 'pizza' }
      string.must_equal 'pizza{3,}'
    end
  end

  describe '#build' do 
    it 'must return ExcEx object' do 
      ExcEx.build do 
      end.must_be_instance_of ExcEx
    end

    it 'must generate regex for all methods given' do 
      ExcEx.build do 
        any_number { matching 'pizza' }
        exactly(1) { matching 'cheeseburger' }
      end.to_s.must_equal '(pizza)*(cheeseburger){1}'
    end
  end

end
{'fraction_non_alphanumeric': 0.10737179487179487, 'fraction_numerical': 0.008333333333333333, 'mean_word_length': 2.5873563218390805, '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': '2724554', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1062, 'n_words': 326}