1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

add C::ContextHelper to wrap native test cases

This commit is contained in:
Charles Lowell 2012-05-25 16:01:31 -05:00
parent a5812812bc
commit 687faa4865
10 changed files with 26 additions and 52 deletions

View file

@ -1,13 +1,7 @@
require 'spec_helper'
describe V8::C::Array do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can store and retrieve a value" do
V8::C::HandleScope() do
o = V8::C::Object::New()

15
spec/c/context_helper.rb Normal file
View file

@ -0,0 +1,15 @@
module C
module ContextHelper
def self.included(base)
base.instance_eval do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
end
end
end
end

View file

@ -1,13 +1,7 @@
require 'spec_helper'
describe V8::C::External do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can store and retrieve a value" do
V8::C::HandleScope() do
o = Object.new

View file

@ -1,13 +1,7 @@
require 'spec_helper'
describe V8::C::Function do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can be called" do
V8::C::HandleScope() do
fn = run '(function() {return "foo"})'

View file

@ -1,9 +1,7 @@
require 'spec_helper'
describe "setting up handles scopes" do
before {@cxt = V8::C::Context::New()}
before {@cxt.Enter()}
after {@cxt.Exit()}
include C::ContextHelper
it "can allocate handle scopes" do
V8::C::HandleScope() do
V8::C::Object::New()

View file

@ -1,13 +1,8 @@
require 'spec_helper'
describe V8::C::Object do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can store and retrieve a value" do
V8::C::HandleScope() do
o = V8::C::Object::New()

View file

@ -1,13 +1,7 @@
require 'spec_helper'
describe V8::C::External do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can run a script and return a polymorphic result" do
V8::C::HandleScope() do
source = V8::C::String::New("(new Array())")

View file

@ -1,13 +1,7 @@
require 'spec_helper'
describe V8::C::Template do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
describe V8::C::FunctionTemplate do
it "can be created with no arguments" do

View file

@ -1,13 +1,8 @@
require 'spec_helper'
describe V8::C::External do
before do
@cxt = V8::C::Context::New()
@cxt.Enter()
end
after do
@cxt.Exit()
end
include C::ContextHelper
it "can catch javascript exceptions" do
V8::C::V8::SetCaptureStackTraceForUncaughtExceptions(true, 99, V8::C::StackTrace::kDetailed)
V8::C::TryCatch() do |trycatch|

View file

@ -1,4 +1,5 @@
require 'v8'
load File.expand_path '../c/context_helper.rb', __FILE__
def run_v8_gc
while !V8::C::V8::IdleNotification() do