Sha256: 583f19b0b59dfa8e095d005d92ca3946d2a8637e43bf28df210a57ea362aaf26

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

require "#{File.dirname(__FILE__)}/../spec_helper.rb"

include V8

describe C::Context do  

  it "should not have a current context if no context is open" do
    C::Context::GetEntered().should be_nil
  end

  it "can get the current javascript execution stack" do
    V8::Context.new do |cxt|
      trace = nil
      cxt['getTrace'] = lambda do
        trace = V8::Context.stack
      end
      cxt.eval(<<-JS, 'trace.js')
      function one() {
        return two();
      }
      
      function two() {
        return three();
      }
      
      function three() {
        return getTrace()
      }
      one();
JS
      trace.length.should be(4)
      trace.to_a[0].tap do |frame|
        frame.line_number.should == 10
        frame.column.should == 16
        frame.script_name.should == 'trace.js'
        frame.function_name.should == 'three'
        frame.should_not be_eval
        frame.should_not be_constructor
      end
    end
  end

  it "has an empty stack if there is no enterned context" do
    V8::Context.stack.should be_empty
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
therubyracer-0.9.2 spec/ext/cxt_spec.rb
therubyracer-0.9.2beta1 spec/ext/cxt_spec.rb
therubyracer-0.9.1 spec/ext/cxt_spec.rb
therubyracer-0.9.1beta1 spec/ext/cxt_spec.rb
therubyracer-0.9.0 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta7 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta6 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta5 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta4 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta3 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta2 spec/ext/cxt_spec.rb
therubyracer-0.9.0beta1 spec/ext/cxt_spec.rb