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:
parent
a5812812bc
commit
687faa4865
10 changed files with 26 additions and 52 deletions
|
@ -1,13 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::Array do
|
describe V8::C::Array do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can store and retrieve a value" do
|
it "can store and retrieve a value" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
o = V8::C::Object::New()
|
o = V8::C::Object::New()
|
||||||
|
|
15
spec/c/context_helper.rb
Normal file
15
spec/c/context_helper.rb
Normal 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
|
|
@ -1,13 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::External do
|
describe V8::C::External do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can store and retrieve a value" do
|
it "can store and retrieve a value" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
o = Object.new
|
o = Object.new
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::Function do
|
describe V8::C::Function do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can be called" do
|
it "can be called" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
fn = run '(function() {return "foo"})'
|
fn = run '(function() {return "foo"})'
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe "setting up handles scopes" do
|
describe "setting up handles scopes" do
|
||||||
before {@cxt = V8::C::Context::New()}
|
include C::ContextHelper
|
||||||
before {@cxt.Enter()}
|
|
||||||
after {@cxt.Exit()}
|
|
||||||
it "can allocate handle scopes" do
|
it "can allocate handle scopes" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
V8::C::Object::New()
|
V8::C::Object::New()
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::Object do
|
describe V8::C::Object do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can store and retrieve a value" do
|
it "can store and retrieve a value" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
o = V8::C::Object::New()
|
o = V8::C::Object::New()
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::External do
|
describe V8::C::External do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can run a script and return a polymorphic result" do
|
it "can run a script and return a polymorphic result" do
|
||||||
V8::C::HandleScope() do
|
V8::C::HandleScope() do
|
||||||
source = V8::C::String::New("(new Array())")
|
source = V8::C::String::New("(new Array())")
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::Template do
|
describe V8::C::Template do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
|
|
||||||
describe V8::C::FunctionTemplate do
|
describe V8::C::FunctionTemplate do
|
||||||
it "can be created with no arguments" do
|
it "can be created with no arguments" do
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::External do
|
describe V8::C::External do
|
||||||
before do
|
include C::ContextHelper
|
||||||
@cxt = V8::C::Context::New()
|
|
||||||
@cxt.Enter()
|
|
||||||
end
|
|
||||||
after do
|
|
||||||
@cxt.Exit()
|
|
||||||
end
|
|
||||||
it "can catch javascript exceptions" do
|
it "can catch javascript exceptions" do
|
||||||
V8::C::V8::SetCaptureStackTraceForUncaughtExceptions(true, 99, V8::C::StackTrace::kDetailed)
|
V8::C::V8::SetCaptureStackTraceForUncaughtExceptions(true, 99, V8::C::StackTrace::kDetailed)
|
||||||
V8::C::TryCatch() do |trycatch|
|
V8::C::TryCatch() do |trycatch|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'v8'
|
require 'v8'
|
||||||
|
load File.expand_path '../c/context_helper.rb', __FILE__
|
||||||
|
|
||||||
def run_v8_gc
|
def run_v8_gc
|
||||||
while !V8::C::V8::IdleNotification() do
|
while !V8::C::V8::IdleNotification() do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue