<commit_before># Copyright (C) 2016 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the
# terms of the three-clause BSD license. See LICENSE.txt
# (located in root directory of this project) for details.

require 'tet'
require_relative '../../build'
require_relative '../helpers/with_falsy_and_mismatch'

module Lextacular
  module Build
    group '.inverse_matcher' do
      example = 'skiffle scuffle'

      group 'matches string when' do
        group 'one of the matchers returns' do
          with_falsy_and_mismatch do |result|
            assert do
              inverse_matcher(proc { result })
                             .call(example) == example
            end
          end
        end

        assert 'not all of the given matchers match' do
          inverse_matcher(regexp_matcher(/skiffle/), regexp_matcher(/-/))
                         .call(example) == example
        end

        assert 'given an index past a match' do
          inverse_matcher(regexp_matcher(/ /))
                         .call(example, 8) == 'scuffle'
        end
      end

      group 'does not match when' do
        assert 'string starts with a match' do
          !inverse_matcher(regexp_matcher(/s/))
                          .call(example)
        end

        assert 'the whole pattern matches' do
          !inverse_matcher(regexp_matcher(/s/), regexp_matcher(/k/))
                          .call(example)
        end

        assert 'given the index of a match' do
          !inverse_matcher(regexp_matcher(/ /), regexp_matcher(/scuffle/))
                          .call(example, 7)<commit_msg>Make #inverse_matcher test a little more robus<commit_after># Copyright (C) 2016 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the
# terms of the three-clause BSD license. See LICENSE.txt
# (located in root directory of this project) for details.

require 'tet'
require_relative '../../build'
require_relative '../helpers/with_falsy_and_mismatch'

module Lextacular
  module Build
    group '.inverse_matcher' do
      example = 'skiffle scuffle'

      group 'matches string when' do
        group 'one of the matchers returns' do
          with_falsy_and_mismatch do |result|
            assert do
              inverse_matcher(regexp_matcher(/sk/), proc { result })
                             .call(example) == example
            end
          end
        end

        assert 'not all of the given matchers match' do
          inverse_matcher(regexp_matcher(/skiffle/), regexp_matcher(/-/))
                         .call(example) == example
        end

        assert 'given an index past a match' do
          inverse_matcher(regexp_matcher(/ /))
                         .call(example, 8) == 'scuffle'
        end
      end

      group 'does not match when' do
        assert 'string starts with a match' do
          !inverse_matcher(regexp_matcher(/s/))
                          .call(example)
        end

        assert 'the whole pattern matches' do
          !inverse_matcher(regexp_matcher(/s/), regexp_matcher(/k/))
                          .call(example)
        end

        assert 'given the index of a match' do
          !inverse_matcher(regexp_matcher(/ /), regexp_matcher(/scuffle/))
                          .call(example, 7)
{'fraction_non_alphanumeric': 0.0863568215892054, 'fraction_numerical': 0.003598200899550225, 'mean_word_length': 1.8415672913117547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5903926', 'n_tokens_mistral': 956, 'n_tokens_neox': 911, 'n_words': 286}