<commit_before>class Specular
  module Spec

    SPEC_ALIASES = [:Should, :Describe, :Context, :Ensure,
                    :Test, :Testing, :Set, :Setting,
                    :Given, :When, :Then,
                    :It, :He, :She,
                    :If, :Let, :Say, :Assume, :Suppose,
                    :And, :Or, :Nor, :But, :However]

    ASSERT_ALIASES = [:is, :is?,
                      :are, :are?,
                      :was, :was?,
                      :does, :does?,
                      :did, :did?,
                      :expect, :assert, :check,
                      :assume, :await, :affirm,
                      :verify, :prove, :certify,
                      :test, :try]
    NEGATIVE_ASSERT_ALIASES = [:refute, :false?]

    module SpecularBaseMixin

      def initialize

        vars = {
            :nesting_level => 0, :context => [],
            :output => OutputProxy.new(self), :source_files => {},
            :current_spec => nil, :skipped_specs => [],
            :current_test => nil, :total_tests => 0, :skipped_tests => [],
            :assertions => [], :failed_assertions => {},
            :hooks => {:a => [], :z => []}, :browser => nil
        }
        @__specular__vars_pool__ = Struct.new(*vars.keys).new(*vars.values)

      end

      def __specular__run__ *args, &proc

        proc || raise('--- specs need a proc to run ---')

        opts = args.last.is_a?(Hash) ? args.pop : {}
        name = args.first

        __specular__.current_spec = {:name => name, :proc => proc}

        if (skip = opts[:skip]) && (skip.is_a?(Proc) ? skip.call : true)
          return __specular__skipped_specs__ << __specular__current_spec__
        end

        __specular__output__ ''
        __specular__output__ __specular__current_spec__[:name]

        catch __specular__fail_symbol__ do
          self.instance_exec *args, &proc
        end
      end

      def __specular__output__ snippet = nil, color = nil
        __specular__.output << [snippet.to_s, __specular__nesting_level__, color].compact if snippet
        __specular__.output
      end

      def __specular__context__
        __specular__.context
      end

      def __specular__current_spec__
        __specular__.current_spec
      end

      def __specular__skipped_specs__
        __specular__.skipped_specs
      end

      def __specular__source_files__
        __specular__.source_files
      end

      def __specular__fail_symbol__
        ('__specular__fail_symbol__%s__' % __specular__context__.dup.last).to_sym
      end

      def __specular__hooks__ position
        __specular__.hooks[position].map do |map|
          context, hook = map
          hook if __specular__context__[0, context.size] == context
        end.compact
      end

      def __specular__nesting_level__ op = nil
        __specular__.nesting_level += 1 if op == :+
        __specular__.nesting_level -= 1 if op == :-
        __specular__.nesting_level
      end

      private
      def __specular__
        @__specular__vars_pool__
      end

    end
    include SpecularBaseMixin

    module SpecularFrontendMixin

      def include mdl
        self.class.class_exec { include mdl }
      end

      def o s = nil
        return __specular__.output.info(s) if s
        __specular__.output
      end
      alias d o

      # explicitly mark a test as failed
      def fail error = 'failed'
        o.error error
        __specular__failed_assertions__ '', {message: error, source: [caller[0].split(':')]}<commit_msg>fixing syntax for 1.8.*<commit_after>class Specular
  module Spec

    SPEC_ALIASES = [:Should, :Describe, :Context, :Ensure,
                    :Test, :Testing, :Set, :Setting,
                    :Given, :When, :Then,
                    :It, :He, :She,
                    :If, :Let, :Say, :Assume, :Suppose,
                    :And, :Or, :Nor, :But, :However]

    ASSERT_ALIASES = [:is, :is?,
                      :are, :are?,
                      :was, :was?,
                      :does, :does?,
                      :did, :did?,
                      :expect, :assert, :check,
                      :assume, :await, :affirm,
                      :verify, :prove, :certify,
                      :test, :try]
    NEGATIVE_ASSERT_ALIASES = [:refute, :false?]

    module SpecularBaseMixin

      def initialize

        vars = {
            :nesting_level => 0, :context => [],
            :output => OutputProxy.new(self), :source_files => {},
            :current_spec => nil, :skipped_specs => [],
            :current_test => nil, :total_tests => 0, :skipped_tests => [],
            :assertions => [], :failed_assertions => {},
            :hooks => {:a => [], :z => []}, :browser => nil
        }
        @__specular__vars_pool__ = Struct.new(*vars.keys).new(*vars.values)

      end

      def __specular__run__ *args, &proc

        proc || raise('--- specs need a proc to run ---')

        opts = args.last.is_a?(Hash) ? args.pop : {}
        name = args.first

        __specular__.current_spec = {:name => name, :proc => proc}

        if (skip = opts[:skip]) && (skip.is_a?(Proc) ? skip.call : true)
          return __specular__skipped_specs__ << __specular__current_spec__
        end

        __specular__output__ ''
        __specular__output__ __specular__current_spec__[:name]

        catch __specular__fail_symbol__ do
          self.instance_exec *args, &proc
        end
      end

      def __specular__output__ snippet = nil, color = nil
        __specular__.output << [snippet.to_s, __specular__nesting_level__, color].compact if snippet
        __specular__.output
      end

      def __specular__context__
        __specular__.context
      end

      def __specular__current_spec__
        __specular__.current_spec
      end

      def __specular__skipped_specs__
        __specular__.skipped_specs
      end

      def __specular__source_files__
        __specular__.source_files
      end

      def __specular__fail_symbol__
        ('__specular__fail_symbol__%s__' % __specular__context__.dup.last).to_sym
      end

      def __specular__hooks__ position
        __specular__.hooks[position].map do |map|
          context, hook = map
          hook if __specular__context__[0, context.size] == context
        end.compact
      end

      def __specular__nesting_level__ op = nil
        __specular__.nesting_level += 1 if op == :+
        __specular__.nesting_level -= 1 if op == :-
        __specular__.nesting_level
      end

      private
      def __specular__
        @__specular__vars_pool__
      end

    end
    include SpecularBaseMixin

    module SpecularFrontendMixin

      def include mdl
        self.class.class_exec { include mdl }
      end

      def o s = nil
        return __specular__.output.info(s) if s
        __specular__.output
      end
      alias d o

      # explicitly mark a test as failed
      def fail error = 'failed'
        o.error error
        error = {:message => error, :source => [caller[0].split(':')]}
        __specular__failed_assertions__ '', error
{'fraction_non_alphanumeric': 0.10337015009912207, 'fraction_numerical': 0.0019824412347776836, 'mean_word_length': 1.8699715562779358, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, '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': '5246071', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2087, 'n_words': 480}