<commit_before>require 'spec_helper'

# rubocop:disable ClassAndModuleChildren
describe Mutant::Matcher::Method::Instance do

  let(:env) { Fixtures::BOOT_ENV }

  describe '#each' do
    subject { object.each { |subject| yields << subject } }

    let(:object)       { described_class.new(env, scope, method) }
    let(:method)       { scope.instance_method(method_name)        }
    let(:yields)       { []                                        }
    let(:namespace)    { self.class                                }
    let(:scope)        { self.class::Foo                           }
    let(:type)         { :def                                      }
    let(:method_name)  { :bar                                      }
    let(:method_arity) { 0                                         }

    def name
      node.children[0]
    end

    def arguments
      node.children[1]
    end

    context 'when method is defined once' do
      let(:base) { __LINE__ }
      class self::Foo
        def bar; end
      end

      let(:method_line) { 2 }

      it_should_behave_like 'a method matcher'
    end

    context 'when method is defined multiple times' do
      context 'on differend lines' do
        let(:base) { __LINE__ }
        class self::Foo
          def bar
          end

          def bar(_arg)
          end
        end

        let(:method_line)  { 5 }
        let(:method_arity) { 1 }

        it_should_behave_like 'a method matcher'
      end

      context 'on the same line' do
        let(:base) { __LINE__ }
        class self::Foo
          def bar; end; def bar(_arg); end
        end

        let(:method_line)  { 2 }<commit_msg>Add an example for method matching on memoizer<commit_after>require 'spec_helper'

# rubocop:disable ClassAndModuleChildren
describe Mutant::Matcher::Method::Instance do

  let(:env) { Fixtures::BOOT_ENV }

  describe '#each' do
    subject { object.each { |subject| yields << subject } }

    let(:object)       { described_class.build(env, scope, method) }
    let(:method)       { scope.instance_method(method_name)        }
    let(:yields)       { []                                        }
    let(:namespace)    { self.class                                }
    let(:scope)        { self.class::Foo                           }
    let(:type)         { :def                                      }
    let(:method_name)  { :bar                                      }
    let(:method_arity) { 0                                         }

    def name
      node.children[0]
    end

    def arguments
      node.children[1]
    end

    context 'when method is defined once' do
      let(:base) { __LINE__ }
      class self::Foo
        def bar; end
      end

      let(:method_line) { 2 }

      it_should_behave_like 'a method matcher'
    end

    context 'when method is defined once with a memoizer' do
      let(:base) { __LINE__ }
      class self::Foo
        def bar; end
        include Adamantium
        memoize :bar
      end

      let(:method_line) { 2 }

      it_should_behave_like 'a method matcher'
    end

    context 'when method is defined multiple times' do
      context 'on differend lines' do
        let(:base) { __LINE__ }
        class self::Foo
          def bar
          end

          def bar(_arg)
          end
        end

        let(:method_line)  { 5 }
        let(:method_arity) { 1 }

        it_should_behave_like 'a method matcher'
      end

      context 'on the same line' do
        let(:base) { __LINE__ }
        class self::Foo
          def bar; end; def bar(_arg); end
        end

        let(:method_line)  { 2 }
{'fraction_non_alphanumeric': 0.09028351224883016, 'fraction_numerical': 0.004128819157720892, 'mean_word_length': 1.4194407456724367, 'pattern_counts': {'":': 0, '<': 7, '<?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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2267277', 'n_tokens_mistral': 1051, 'n_tokens_neox': 990, 'n_words': 268}