Sha256: b0bdf6cf45ac2b2f03021ae3396c2f499b7b3e06ab3a904c304bf5b9c2bf42c1

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

module V8::ExtSpec
  
  def self.included(object)
    object.class_eval do
      before(:all) {c::V8::SetFlagsFromString("--expose-gc")}
      before do
        @cxt = c::Context::New()
        @cxt.Enter()
      end
      after do
        @cxt.Exit()
        @cxt.Dispose()
      end
    end
  end
  
  def v8_eval(script, sourcename = "<eval>")
    c::Script::New(c::String::New(script), c::String::New(sourcename)).Run()
  end

  def c
    V8::C
  end
  
  def ruby_gc
    if GC.respond_to?(:stress)
      current = GC.stress
      GC.stress = true
    end
    yield
  ensure
    if GC.respond_to?(:stess)
      GC.stress = current
    end
  end

  def v8_gc
    while !c::V8::IdleNotification();end
    v8_eval('gc()', 'gc.js')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
therubyracer-0.9.0beta2 spec/ext/ext_spec_helper.rb
therubyracer-0.9.0beta1 spec/ext/ext_spec_helper.rb