<commit_before>require 'faker'

module Clean #:nodoc:
  module Test #:nodoc:
    # Public: Provides the ability to vend arbitrary values without using literals, or
    # long calls to Faker.  This has two levels of utility:
    #
    # helper methods - #any_number, #any_int, #any_string provide arbitrary primitives 
    #                  to make it clear what numbers, ints, and strings in your tests are
    #                  relevant.  Arbitrary values should use one of these any_ helpers.
    #
    # any sort of any - you can define your own "any" values by using #new_any, which allows you to 
    #                   extend things if you like.  Of course, you could just make your own any_method as well.
    #
    # Example:
    #
    #     class Person
    #       def initialize(first_name,last_name,age)
    #         # ...
    #       end
    #     end
    #
    #     test_that "someone under 18 is a minor" {
    #       Given {
    #         # First name and last name aren't relevant to the test
    #         @person = Person.new(any_string,any_string,17)
    #       }
    #       When {
    #         @minor = @person.minor?
    #       }
    #       Then {
    #         assert @minor
    #       }
    #     }
    #
    #     test_that "full_name gives the full name" {
    #       Given {
    #         # Age isn't relevant; it just needs to be positive
    #         @person = Person.new("Dave","Copeland",any_int :positive)
    #       }
    #       When {
    #         @full_name = @person.full_name
    #       }
    #       Then {
    #         assert_equal "<NAME>",@full_namej
    #       }
    #     }
    module Any
      MAX_RAND = 50000 #:nodoc:

      # Public: Get any number; one that doesn't matter
      #
      # options - options to control what sort of number comes back:
      #           :positive - make sure that the number is greater than zero
      #           :negative - make sure that the number is less than zero
      def any_number(*options)
        any :number,options
      end

      # Public: Returns an integer.  options is the same as for #any_number
      def any_int(*options)
        any :int,options
      end

      # Public: Get an arbitrary string of any potential positive length
      #
      # options - options to control the returned string:
      #           :max - the max size of the string you want, must be positive and greater than :min
      #           :min - the minimum size we want to come back, must be positive and less than :max
      #
      # Example
      #
      #     any_string :max => 255 # => ensure it'll fit into a varchar(255)
      #     any_string :min => 1024 # at least 1024 characters
      #
      def any_string(options = {})
        any :string,options
      end<commit_msg>print random seed and allow forcing it to a particular value<commit_after>require 'faker'

module Clean #:nodoc:
  module Test #:nodoc:
    # Public: Provides the ability to vend arbitrary values without using literals, or
    # long calls to Faker.  This has two levels of utility:
    #
    # helper methods - #any_number, #any_int, #any_string provide arbitrary primitives 
    #                  to make it clear what numbers, ints, and strings in your tests are
    #                  relevant.  Arbitrary values should use one of these any_ helpers.
    #
    # any sort of any - you can define your own "any" values by using #new_any, which allows you to 
    #                   extend things if you like.  Of course, you could just make your own any_method as well.
    #
    # Example:
    #
    #     class Person
    #       def initialize(first_name,last_name,age)
    #         # ...
    #       end
    #     end
    #
    #     test_that "someone under 18 is a minor" {
    #       Given {
    #         # First name and last name aren't relevant to the test
    #         @person = Person.new(any_string,any_string,17)
    #       }
    #       When {
    #         @minor = @person.minor?
    #       }
    #       Then {
    #         assert @minor
    #       }
    #     }
    #
    #     test_that "full_name gives the full name" {
    #       Given {
    #         # Age isn't relevant; it just needs to be positive
    #         @person = Person.new("Dave","Copeland",any_int :positive)
    #       }
    #       When {
    #         @full_name = @person.full_name
    #       }
    #       Then {
    #         assert_equal "<NAME>",@full_namej
    #       }
    #     }
    module Any
      def self.included(k)
        seed = if ENV['RANDOM_SEED']
                 ENV['RANDOM_SEED'].to_i
               else
                 srand() # generate random seed
                 seed = srand() # save it (but we've now generated another one)
               end
        srand(seed) # set it explicitly
        puts "Random seed was #{seed}; re-use it via environment variable RANDOM_SEED"
      end
      MAX_RAND = 50000 #:nodoc:

      # Public: Get any number; one that doesn't matter
      #
      # options - options to control what sort of number comes back:
      #           :positive - make sure that the number is greater than zero
      #           :negative - make sure that the number is less than zero
      def any_number(*options)
        any :number,options
      end

      # Public: Returns an integer.  options is the same as for #any_number
      def any_int(*options)
        any :int,options
      end

      # Public: Get an arbitrary string of any potential positive length
      #
      # options - options to control the returned string:
      #           :max - the max size of the string you want, must be positive and greater than :min
      #           :min - the minimum size we want to come back, must be positive and less than :max
      #
      # Example
      #
      #     any_string :max => 255 # => ensure it'll fit into a varchar(255)
      #     any_string :min => 1024 # at least 1024 characters
      #
      def any_string(options = {})
        any :string,options
      end
{'fraction_non_alphanumeric': 0.07821321819993357, 'fraction_numerical': 0.007638658253072069, 'mean_word_length': 1.662687886825818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3788299', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1663, 'n_words': 623}