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

describe "Class.inherited" do
  it "is invoked with the child Class when self is subclassed" do
    begin
      top = Class.new do
        def self.inherited(cls)
          $child_class = cls
        end
      end
      
      child = Class.new(top)
      $child_class.should == child

      other_child = Class.new(top)
      $child_class.should == other_child
    ensure
      $child_class = nil
    end
  end
end<commit_msg>Class.inherited gets invoked regardless of visibility<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'

describe "Class.inherited" do
  it "is invoked with the child Class when self is subclassed" do
    begin
      top = Class.new do
        def self.inherited(cls)
          $child_class = cls
        end
      end
      
      child = Class.new(top)
      $child_class.should == child

      other_child = Class.new(top)
      $child_class.should == other_child
    ensure
      $child_class = nil
    end
  end

  it "will be invoked by child class regardless of visibility" do
    top = Class.new do
      class << self
        def inherited(cls); end
      end
    end

    class << top; private :inherited; end
    lambda { Class.new(top) }.should_not raise_error

    class << top; protected :inherited; end
    lambda { Class.new(top) }.should_not raise_error
  end
end
{'fraction_non_alphanumeric': 0.08895265423242468, 'fraction_numerical': 0.0, 'mean_word_length': 2.297872340425532, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7238093', 'n_tokens_mistral': 421, 'n_tokens_neox': 413, 'n_words': 128}