Sha256: c63e0434ae22fd2752f9761647ac69f185281a3fff16ae98f3793f36b3c35b6a

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require 'power_assert/configuration'

if defined?(RubyVM)
  if PowerAssert.configuration._redefinition
    module PowerAssert
      # set redefined flag
      basic_classes = [
        Integer, Float, String, Array, Hash, Symbol, Time, Regexp, NilClass, TrueClass, FalseClass
      ]

      verbose = $VERBOSE
      begin
        $VERBOSE = nil
        [:Fixnum, :Bignum].each do |c|
          if Object.const_defined?(c) and (c = Object.const_get(c)) != Integer
            basic_classes << c
          end
        end
      ensure
        $VERBOSE = verbose
      end

      basic_operators = [
        :+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=, :length, :size,
        :empty?, :nil?, :succ, :>, :>=, :!, :!=, :=~, :freeze, :-@, :max, :min,
        # :call (it is just used for block call optimization)
        :&, :|,
        # :default (no specialized instruction for this)
        :pack, :include?,
      ]

      basic_classes.each do |klass|
        basic_operators.each do |bop|
          if klass.public_method_defined?(bop)
            refine(klass) do
              define_method(bop) {}
            end
          end
        end
      end

      # bypass check_cfunc
      refine BasicObject do
        def !
        end

        def ==
        end
      end

      refine Module do
        def ==
        end
      end
    end
  end

  # disable optimization
  RubyVM::InstructionSequence.compile_option = {
    specialized_instruction: false
  }
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
es_cli-0.1.0 vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/enable_tracepoint_events.rb
power_assert-2.0.5 lib/power_assert/enable_tracepoint_events.rb