<commit_before>require_relative '../automated_init'

context "Schema" do
  context "Hash Code" do
    schema_class = Class.new do
      include Schema

      attribute :some_attribute
    end

    attribute_value = "some-value"

    context "Same Class" do
      context "Same Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = schema_class.new
        other_schema.some_attribute = attribute_value

        assert(schema.eql?(other_schema))

        test "Equivalent" do
          assert(schema.hash == other_schema.hash)
        end
      end

      context "Different Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = schema_class.new
        other_schema.some_attribute = SecureRandom.hex

        refute(schema.eql?(other_schema))

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end
      end
    end

    context "Different Class" do
      other_schema_class = Class.new do
        include Schema

        attribute :some_attribute, String
      end

      context "Same Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = other_schema_class.new
        other_schema.some_attribute = attribute_value

        refute(schema.eql?(other_schema))

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end
      end

      context "Different Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = other_schema_class.new
        other_schema.some_attribute = SecureRandom.hex

        refute(schema.eql?(other_schema))

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end
      end
    end
  end
end<commit_msg>Hash code test preconditions are elevated to tests<commit_after>require_relative '../automated_init'

context "Schema" do
  context "Hash Code" do
    schema_class = Class.new do
      include Schema

      attribute :some_attribute
    end

    attribute_value = "some-value"

    context "Same Class" do
      context "Same Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = schema_class.new
        other_schema.some_attribute = attribute_value

        test "Equivalent" do
          assert(schema.hash == other_schema.hash)
        end

        test "Schemas instances are equal when hash codes are equal" do
          assert(schema.eql?(other_schema))
        end
      end

      context "Different Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = schema_class.new
        other_schema.some_attribute = SecureRandom.hex

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end

        test "Schemas instances are not equal when hash codes are not equal" do
          refute(schema.eql?(other_schema))
        end
      end
    end

    context "Different Class" do
      other_schema_class = Class.new do
        include Schema

        attribute :some_attribute, String
      end

      context "Same Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = other_schema_class.new
        other_schema.some_attribute = attribute_value

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end

        test "Schemas instances are not equal when hash codes are not equal" do
          refute(schema.eql?(other_schema))
        end
      end

      context "Different Attribute Values" do
        schema = schema_class.new
        schema.some_attribute = attribute_value

        other_schema = other_schema_class.new
        other_schema.some_attribute = SecureRandom.hex

        test "Not Equivalent" do
          refute(schema.hash == other_schema.hash)
        end

        test "Schemas instances are not equal when hash codes are not equal" do
          refute(schema.eql?(other_schema))
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06023815082885828, 'fraction_numerical': 0.0, 'mean_word_length': 2.26027397260274, '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': '228974', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1124, 'n_words': 314}