Sha256: 9b1ad701abdb1406ff3c4c63bc0a182c9f1293257d43cd118b9fc32962b02471

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

if defined? RubyVM
  verbose = $VERBOSE
  begin
    $VERBOSE = nil
    module PowerAssert
      # set redefined flag
      basic_classes = [
        Fixnum, Float, String, Array, Hash, Bignum, Symbol, Time, Regexp
      ]

      basic_operators = [
        :+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=,
        :length, :size, :empty?, :succ, :>, :>=, :!, :!=, :=~, :freeze
      ]

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


      # bypass check_cfunc
      refine BasicObject do
        def !
        end

        def ==
        end
      end

      refine Module do
        def ==
        end
      end
    end
  ensure
    $VERBOSE = verbose
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
power_assert-0.2.5 lib/power_assert/enable_tracepoint_events.rb