Sha256: ae1c2399ede87603d45098c7a465c86106b304d33012bf807b7b938906a587ea

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

if defined? RubyVM
  basic_classes = [
    Fixnum, Float, String, Array, Hash, Bignum, Symbol, Time, Regexp
  ]

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

  # set redefined flag
  basic_classes.each do |klass|
    basic_operators.each do |bop|
      if klass.public_method_defined?(bop)
        klass.instance_method(bop).owner.module_eval do
          public bop
        end
      end
    end
  end

  # bypass check_cfunc
  verbose = $VERBOSE
  begin
    $VERBOSE = nil
    module PowerAssert
      refine BasicObject do
        def !
        end

        def ==
        end
      end

      refine Module do
        def ==
        end
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
power_assert-0.2.3 lib/power_assert/enable_tracepoint_events.rb
power_assert-0.2.2 lib/power_assert/enable_tracepoint_events.rb
power_assert-0.2.1 lib/power_assert/enable_tracepoint_events.rb