therubyracer 0.10.2 → 0.11.0beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of therubyracer might be problematic. Click here for more details.
- data/.gitignore +21 -11
- data/.travis.yml +2 -1
- data/Changelog.md +46 -0
- data/Gemfile +16 -1
- data/README.md +31 -13
- data/Rakefile +42 -23
- data/benchmarks.rb +217 -0
- data/ext/v8/accessor.cc +181 -0
- data/ext/v8/array.cc +26 -0
- data/ext/v8/backref.cc +56 -0
- data/ext/v8/build.rb +51 -0
- data/ext/v8/constants.cc +34 -0
- data/ext/v8/constraints.cc +52 -0
- data/ext/v8/context.cc +130 -0
- data/ext/v8/date.cc +18 -0
- data/ext/v8/exception.cc +38 -0
- data/ext/v8/extconf.rb +14 -18
- data/ext/v8/external.cc +43 -0
- data/ext/v8/function.cc +58 -0
- data/ext/v8/gc.cc +43 -0
- data/ext/v8/handles.cc +34 -0
- data/ext/v8/heap.cc +31 -0
- data/ext/v8/init.cc +39 -0
- data/ext/v8/invocation.cc +86 -0
- data/ext/v8/locker.cc +77 -0
- data/ext/v8/message.cc +51 -0
- data/ext/v8/object.cc +334 -0
- data/ext/v8/primitive.cc +8 -0
- data/ext/v8/rr.cc +83 -0
- data/ext/v8/rr.h +878 -36
- data/ext/v8/script.cc +80 -0
- data/ext/v8/signature.cc +18 -0
- data/ext/v8/stack.cc +75 -0
- data/ext/v8/string.cc +47 -0
- data/ext/v8/template.cc +175 -0
- data/ext/v8/trycatch.cc +86 -0
- data/ext/v8/v8.cc +87 -0
- data/ext/v8/value.cc +239 -0
- data/lib/v8.rb +30 -22
- data/lib/v8/access.rb +5 -87
- data/lib/v8/access/indices.rb +40 -0
- data/lib/v8/access/invocation.rb +47 -0
- data/lib/v8/access/names.rb +65 -0
- data/lib/v8/array.rb +19 -10
- data/lib/v8/context.rb +85 -78
- data/lib/v8/conversion.rb +35 -0
- data/lib/v8/conversion/array.rb +11 -0
- data/lib/v8/conversion/class.rb +120 -0
- data/lib/v8/conversion/code.rb +38 -0
- data/lib/v8/conversion/fundamental.rb +11 -0
- data/lib/v8/conversion/hash.rb +11 -0
- data/lib/v8/conversion/indentity.rb +31 -0
- data/lib/v8/conversion/method.rb +26 -0
- data/lib/v8/conversion/object.rb +28 -0
- data/lib/v8/conversion/primitive.rb +7 -0
- data/lib/v8/conversion/proc.rb +5 -0
- data/lib/v8/conversion/reference.rb +16 -0
- data/lib/v8/conversion/string.rb +12 -0
- data/lib/v8/conversion/symbol.rb +7 -0
- data/lib/v8/conversion/time.rb +13 -0
- data/lib/v8/error.rb +18 -123
- data/lib/v8/error/protect.rb +20 -0
- data/lib/v8/error/try.rb +15 -0
- data/lib/v8/function.rb +18 -34
- data/lib/v8/object.rb +48 -52
- data/lib/v8/util/weakcell.rb +29 -0
- data/lib/v8/version.rb +2 -2
- data/spec/c/array_spec.rb +17 -0
- data/spec/c/constants_spec.rb +20 -0
- data/spec/c/exception_spec.rb +26 -0
- data/spec/c/external_spec.rb +9 -0
- data/spec/c/function_spec.rb +46 -0
- data/spec/c/handles_spec.rb +35 -0
- data/spec/c/locker_spec.rb +38 -0
- data/spec/c/object_spec.rb +46 -0
- data/spec/c/script_spec.rb +28 -0
- data/spec/c/string_spec.rb +16 -0
- data/spec/c/template_spec.rb +30 -0
- data/spec/c/trycatch_spec.rb +51 -0
- data/spec/mem/blunt_spec.rb +42 -0
- data/spec/redjs_spec.rb +10 -0
- data/spec/spec_helper.rb +40 -4
- data/spec/threading_spec.rb +52 -0
- data/spec/v8/context_spec.rb +19 -0
- data/spec/v8/conversion_spec.rb +9 -0
- data/spec/v8/error_spec.rb +15 -125
- data/spec/v8/function_spec.rb +9 -0
- data/therubyracer.gemspec +15 -24
- metadata +102 -135
- data/.gitmodules +0 -3
- data/.rspec +0 -1
- data/.yardopts +0 -1
- data/bin/therubyracer +0 -11
- data/ext/v8/rr.cpp +0 -189
- data/ext/v8/v8.cpp +0 -48
- data/ext/v8/v8_array.cpp +0 -48
- data/ext/v8/v8_array.h +0 -8
- data/ext/v8/v8_callbacks.cpp +0 -81
- data/ext/v8/v8_callbacks.h +0 -8
- data/ext/v8/v8_context.cpp +0 -92
- data/ext/v8/v8_context.h +0 -6
- data/ext/v8/v8_date.cpp +0 -34
- data/ext/v8/v8_date.h +0 -6
- data/ext/v8/v8_debug.cpp +0 -17
- data/ext/v8/v8_debug.h +0 -6
- data/ext/v8/v8_exception.cpp +0 -133
- data/ext/v8/v8_exception.h +0 -11
- data/ext/v8/v8_external.cpp +0 -70
- data/ext/v8/v8_external.h +0 -8
- data/ext/v8/v8_function.cpp +0 -69
- data/ext/v8/v8_function.h +0 -11
- data/ext/v8/v8_handle.cpp +0 -186
- data/ext/v8/v8_handle.h +0 -48
- data/ext/v8/v8_locker.cpp +0 -139
- data/ext/v8/v8_locker.h +0 -6
- data/ext/v8/v8_message.cpp +0 -67
- data/ext/v8/v8_message.h +0 -10
- data/ext/v8/v8_object.cpp +0 -122
- data/ext/v8/v8_object.h +0 -10
- data/ext/v8/v8_script.cpp +0 -36
- data/ext/v8/v8_script.h +0 -8
- data/ext/v8/v8_string.cpp +0 -52
- data/ext/v8/v8_string.h +0 -9
- data/ext/v8/v8_template.cpp +0 -344
- data/ext/v8/v8_template.h +0 -8
- data/ext/v8/v8_try_catch.cpp +0 -70
- data/ext/v8/v8_try_catch.h +0 -5
- data/ext/v8/v8_v8.cpp +0 -35
- data/ext/v8/v8_v8.h +0 -6
- data/ext/v8/v8_value.cpp +0 -175
- data/ext/v8/v8_value.h +0 -10
- data/ext/v8/v8_weakref.cpp +0 -61
- data/ext/v8/v8_weakref.h +0 -29
- data/lib/v8/c/locker.rb +0 -18
- data/lib/v8/cli.rb +0 -133
- data/lib/v8/portal.rb +0 -86
- data/lib/v8/portal/caller.rb +0 -37
- data/lib/v8/portal/constructor.rb +0 -98
- data/lib/v8/portal/function.rb +0 -63
- data/lib/v8/portal/interceptors.rb +0 -152
- data/lib/v8/portal/proxies.rb +0 -151
- data/lib/v8/portal/templates.rb +0 -73
- data/lib/v8/stack.rb +0 -66
- data/lib/v8/tap.rb +0 -9
- data/spec/ext/array_spec.rb +0 -15
- data/spec/ext/cxt_spec.rb +0 -57
- data/spec/ext/ext_spec_helper.rb +0 -27
- data/spec/ext/func_spec.rb +0 -64
- data/spec/ext/object_spec.rb +0 -10
- data/spec/ext/string_spec.rb +0 -11
- data/spec/ext/try_catch_spec.rb +0 -60
- data/spec/redjs_helper.rb +0 -3
- data/spec/v8/portal/proxies_spec.rb +0 -106
- data/specmem/handle_memspec.rb +0 -41
- data/specmem/object_memspec.rb +0 -14
- data/specmem/proxies_memspec.rb +0 -49
- data/specmem/spec_helper.rb +0 -24
- data/specthread/spec_helper.rb +0 -2
- data/specthread/threading_spec.rb +0 -13
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe V8::C::Template do
|
4
|
+
|
5
|
+
describe V8::C::FunctionTemplate do
|
6
|
+
it "can be created with no arguments" do
|
7
|
+
t = V8::C::FunctionTemplate::New()
|
8
|
+
t.GetFunction().Call(@cxt.Global(),[]).StrictEquals(@cxt.Global()).should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can be created with a callback" do
|
12
|
+
receiver = V8::C::Object::New()
|
13
|
+
f = nil
|
14
|
+
callback = lambda do |arguments|
|
15
|
+
arguments.Length().should be(2)
|
16
|
+
arguments[0].Utf8Value().should eql 'one'
|
17
|
+
arguments[1].Utf8Value().should eql 'two'
|
18
|
+
arguments.Callee().StrictEquals(f).should be_true
|
19
|
+
arguments.This().StrictEquals(receiver).should be_true
|
20
|
+
arguments.Holder().StrictEquals(receiver).should be_true
|
21
|
+
arguments.IsConstructCall().should be_false
|
22
|
+
arguments.Data().Value().should be(42)
|
23
|
+
V8::C::String::New("result")
|
24
|
+
end
|
25
|
+
t = V8::C::FunctionTemplate::New(callback, V8::C::External::New(42))
|
26
|
+
f = t.GetFunction()
|
27
|
+
f.Call(receiver, [V8::C::String::New('one'), V8::C::String::New('two')]).Utf8Value().should eql "result"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe V8::C::External do
|
4
|
+
|
5
|
+
it "can catch javascript exceptions" do
|
6
|
+
V8::C::V8::SetCaptureStackTraceForUncaughtExceptions(true, 99, V8::C::StackTrace::kDetailed)
|
7
|
+
V8::C::TryCatch() do |trycatch|
|
8
|
+
source = V8::C::String::New(<<-JS)
|
9
|
+
function one() {
|
10
|
+
two()
|
11
|
+
}
|
12
|
+
function two() {
|
13
|
+
three()
|
14
|
+
}
|
15
|
+
function three() {
|
16
|
+
boom()
|
17
|
+
}
|
18
|
+
function boom() {
|
19
|
+
throw new Error('boom!')
|
20
|
+
}
|
21
|
+
eval('one()')
|
22
|
+
JS
|
23
|
+
filename = V8::C::String::New("<eval>")
|
24
|
+
script = V8::C::Script::New(source, filename)
|
25
|
+
result = script.Run()
|
26
|
+
trycatch.HasCaught().should be_true
|
27
|
+
trycatch.CanContinue().should be_true
|
28
|
+
exception = trycatch.Exception()
|
29
|
+
exception.should_not be_nil
|
30
|
+
exception.IsNativeError().should be_true
|
31
|
+
trycatch.StackTrace().Utf8Value().should match /boom.*three.*two.*one/m
|
32
|
+
message = trycatch.Message();
|
33
|
+
message.should_not be_nil
|
34
|
+
message.Get().Utf8Value().should eql "Uncaught Error: boom!"
|
35
|
+
message.GetSourceLine().Utf8Value().should eql " throw new Error('boom!')"
|
36
|
+
message.GetScriptResourceName().Utf8Value().should eql "<eval>"
|
37
|
+
message.GetLineNumber().should eql 11
|
38
|
+
stack = message.GetStackTrace()
|
39
|
+
stack.should_not be_nil
|
40
|
+
stack.GetFrameCount().should eql 6
|
41
|
+
frame = stack.GetFrame(0)
|
42
|
+
frame.GetLineNumber().should eql 11
|
43
|
+
frame.GetColumn().should eql 15
|
44
|
+
frame.GetScriptName().Utf8Value().should eql "<eval>"
|
45
|
+
frame.GetScriptNameOrSourceURL().Utf8Value().should eql "<eval>"
|
46
|
+
frame.IsEval().should be_false
|
47
|
+
stack.GetFrame(4).IsEval().should be_true
|
48
|
+
frame.IsConstructor().should be_false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "A Very blunt test to make sure that we aren't doing stupid leaks", :memory => true do
|
4
|
+
before do
|
5
|
+
if Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
6
|
+
pending 'need to figure out how to do memory sanity checks on rbx'
|
7
|
+
end
|
8
|
+
#allocate a single context to make sure that v8 loads its snapshot and
|
9
|
+
#we pay the overhead.
|
10
|
+
V8::Context.new
|
11
|
+
@start_memory = process_memory
|
12
|
+
GC.stress = true
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
GC.stress = false
|
17
|
+
end
|
18
|
+
it "won't increase process memory by more than 50% no matter how many contexts we create" do
|
19
|
+
500.times do
|
20
|
+
V8::Context.new
|
21
|
+
run_v8_gc
|
22
|
+
end
|
23
|
+
process_memory.should <= @start_memory * 1.5
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can eval simple value passing statements repeatedly without significantly increasing memory" do
|
27
|
+
V8::C::Locker() do
|
28
|
+
cxt = V8::Context.new
|
29
|
+
500.times do
|
30
|
+
cxt.eval('7 * 6')
|
31
|
+
run_v8_gc
|
32
|
+
end
|
33
|
+
end
|
34
|
+
process_memory.should <= @start_memory * 1.1
|
35
|
+
end
|
36
|
+
|
37
|
+
def process_memory
|
38
|
+
/\w*[ ]*#{Process.pid}[ ]*([.,\d]*)[ ]*([.,\d]*)[ ]*([\d]*)[ ]*([\d]*)/.match(`ps aux`)[4].to_i
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
data/spec/redjs_spec.rb
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,45 @@
|
|
1
|
-
|
2
1
|
require 'v8'
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
|
3
|
+
def run_v8_gc
|
4
|
+
V8::C::V8::LowMemoryNotification()
|
5
|
+
while !V8::C::V8::IdleNotification() do
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
6
9
|
def rputs(msg)
|
7
10
|
puts "<pre>#{ERB::Util.h(msg)}</pre>"
|
8
11
|
$stdout.flush
|
9
12
|
end
|
13
|
+
|
14
|
+
module ExplicitScoper;end
|
15
|
+
module Autoscope
|
16
|
+
def instance_eval(*args, &block)
|
17
|
+
return super unless low_level_c_spec? && !explicitly_defines_scope?
|
18
|
+
V8::C::Locker() do
|
19
|
+
V8::C::HandleScope() do
|
20
|
+
@cxt = V8::C::Context::New()
|
21
|
+
begin
|
22
|
+
@cxt.Enter()
|
23
|
+
super(*args, &block)
|
24
|
+
ensure
|
25
|
+
@cxt.Exit()
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def low_level_c_spec?
|
32
|
+
return false unless described_class
|
33
|
+
described_class.name =~ /^V8::C::/
|
34
|
+
end
|
35
|
+
|
36
|
+
def explicitly_defines_scope?
|
37
|
+
is_a?(ExplicitScoper)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
RSpec.configure do |c|
|
42
|
+
c.before(:each) do
|
43
|
+
extend Autoscope
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "using v8 from multiple threads", :threads => true do
|
4
|
+
|
5
|
+
it "creates contexts from within threads" do
|
6
|
+
10.times.collect do
|
7
|
+
Thread.new do
|
8
|
+
V8::Context.new
|
9
|
+
end
|
10
|
+
end.each {|t| t.join}
|
11
|
+
V8::Context.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it "executes codes on multiple threads simultaneously" do
|
15
|
+
5.times.collect{V8::Context.new}.collect do |ctx|
|
16
|
+
Thread.new do
|
17
|
+
ctx['x'] = 99
|
18
|
+
while ctx['x'] > 0
|
19
|
+
ctx.eval 'for (i=10000;i;i--){};--x'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end.each {|t| t.join}
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can access the current thread id" do
|
26
|
+
V8::C::Locker() do
|
27
|
+
V8::C::V8::GetCurrentThreadId().should_not be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "can pre-empt a running JavaScript thread" do
|
32
|
+
pending "need to release the GIL while executing V8 code"
|
33
|
+
begin
|
34
|
+
V8::C::Locker::StartPreemption(2)
|
35
|
+
thread_id = nil
|
36
|
+
Thread.new do
|
37
|
+
loop until thread_id
|
38
|
+
puts "thread id: #{thread_id}"
|
39
|
+
V8::C::V8::TerminateExecution(thread_id)
|
40
|
+
end
|
41
|
+
Thread.new do
|
42
|
+
V8::C::Locker() do
|
43
|
+
thread_id = V8::C::V8::GetCurrentThreadId()
|
44
|
+
V8::Context.new {|cxt| cxt.eval('while (true) {}')}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
V8::C::V8::TerminateExecution(thread_id)
|
48
|
+
ensure
|
49
|
+
V8::C::Locker::StopPreemption()
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe V8::Context do
|
4
|
+
it "can be disposed of" do
|
5
|
+
cxt = V8::Context.new
|
6
|
+
cxt.enter do
|
7
|
+
cxt['object'] = V8::Object.new
|
8
|
+
end
|
9
|
+
cxt.dispose()
|
10
|
+
|
11
|
+
lambda {cxt.eval('1 + 1')}.should raise_error
|
12
|
+
lambda {cxt['object']}.should raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can be disposed of any number of times" do
|
16
|
+
cxt = V8::Context.new
|
17
|
+
10.times {cxt.dispose()}
|
18
|
+
end
|
19
|
+
end
|
data/spec/v8/error_spec.rb
CHANGED
@@ -1,131 +1,21 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe V8::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
@cxt['two'] = lambda do
|
11
|
-
@cxt.eval('three()', 'two.js')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "captures a message without over nesting when the error is an error" do
|
16
|
-
throw! do |e|
|
17
|
-
e.message.should == "BOOM!"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "captures the js message without over nesting when the error is a normal object" do
|
22
|
-
throw!('{foo: "bar"}') do |e|
|
23
|
-
e.message.should == "[object Object]"
|
24
|
-
end
|
25
|
-
throw!('{message: "bar"}') do |e|
|
26
|
-
e.message.should == "bar"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "captures a thrown value as the message" do
|
31
|
-
throw!('"BOOM!"') do |e|
|
32
|
-
e.message.should == "BOOM!"
|
33
|
-
end
|
34
|
-
throw!('6') do |e|
|
35
|
-
e.message.should == '6'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "has a reference to the root javascript cause" do
|
40
|
-
throw!('"I am a String"') do |e|
|
41
|
-
e.should_not be_in_ruby
|
42
|
-
e.should be_in_javascript
|
43
|
-
e.value.should == "I am a String"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it "has a reference to the root ruby cause if one exists" do
|
48
|
-
StandardError.new("BOOM!").tap do |bomb|
|
49
|
-
@cxt['boom'] = lambda do
|
50
|
-
raise bomb
|
51
|
-
end
|
52
|
-
lambda {
|
53
|
-
@cxt.eval('boom()', 'boom.js')
|
54
|
-
}.should(raise_error do |raised|
|
55
|
-
raised.should be_in_ruby
|
56
|
-
raised.should_not be_in_javascript
|
57
|
-
raised.value.should be(bomb)
|
58
|
-
end)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "backtrace" do
|
63
|
-
|
64
|
-
it "is mixed with ruby and javascript" do
|
65
|
-
throw! do |e|
|
66
|
-
e.backtrace.first.should == "at three.js:1:7"
|
67
|
-
e.backtrace[1].should =~ /error_spec.rb/
|
68
|
-
e.backtrace[2].should == "at two.js:1:1"
|
69
|
-
e.backtrace[3].should =~ /error_spec.rb/
|
70
|
-
e.backtrace[4].should == "at one.js:1:1"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
it "can be set to show only ruby frames" do
|
75
|
-
throw! do |e|
|
76
|
-
e.backtrace(:ruby).each do |frame|
|
77
|
-
frame.should =~ /(\.rb|):\d+/
|
78
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe V8::Error do
|
4
|
+
it "uses the same ruby exception through multiple language boundaries" do
|
5
|
+
V8::Context.new do |cxt|
|
6
|
+
error = StandardError.new('potato')
|
7
|
+
cxt['one'] = lambda do
|
8
|
+
cxt.eval('two()', 'one.js')
|
79
9
|
end
|
80
|
-
|
81
|
-
|
82
|
-
it "can be set to show only javascript frames" do
|
83
|
-
throw! do |e|
|
84
|
-
e.backtrace(:javascript).each do |frame|
|
85
|
-
frame.should =~ /\.js:\d:\d/
|
86
|
-
end
|
10
|
+
cxt['two'] = lambda do
|
11
|
+
cxt.eval('three()', 'two.js')
|
87
12
|
end
|
88
|
-
|
89
|
-
|
90
|
-
it "includes a mystery marker when the original frame is unavailable because what got thrown wasn't an error" do
|
91
|
-
throw!("6") do |e|
|
92
|
-
e.backtrace.first.should == 'at three.js:1:1'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
it "has a source name and line number when there is a javascript SyntaxError" do
|
97
|
-
lambda do
|
98
|
-
@cxt.eval(<<-INVALID, 'source.js')
|
99
|
-
"this line is okay";
|
100
|
-
"this line has a syntax error because it ends with a colon":
|
101
|
-
"this line is also okay";
|
102
|
-
"how do I find out that line 2 has the syntax error?";
|
103
|
-
INVALID
|
104
|
-
end.should raise_error(V8::JSError) {|error|
|
105
|
-
error.backtrace.first.should == 'at source.js:2:60'
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
it "can start with ruby at the bottom" do
|
110
|
-
@cxt['boom'] = lambda do
|
111
|
-
raise StandardError, "Bif!"
|
13
|
+
cxt['three'] = lambda do
|
14
|
+
raise error
|
112
15
|
end
|
113
16
|
lambda {
|
114
|
-
|
115
|
-
}.should
|
116
|
-
e.backtrace.first.should =~ /error_spec\.rb/
|
117
|
-
e.backtrace[1].should =~ /boom.js/
|
118
|
-
})
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
def throw!(js = "new Error('BOOM!')", &block)
|
124
|
-
@cxt['three'] = lambda do
|
125
|
-
@cxt.eval("throw #{js}", 'three.js')
|
17
|
+
cxt.eval('three()')
|
18
|
+
}.should raise_error {|e| e.should be error}
|
126
19
|
end
|
127
|
-
lambda do
|
128
|
-
@cxt['one'].call()
|
129
|
-
end.should(raise_error(V8::JSError, &block))
|
130
20
|
end
|
131
|
-
end
|
21
|
+
end
|
data/therubyracer.gemspec
CHANGED
@@ -1,29 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "v8/version"
|
4
|
-
require 'pathname'
|
2
|
+
require File.expand_path('../lib/v8/version', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
s.homepage = "http://github.com/cowboyd/therubyracer"
|
13
|
-
s.email = "cowboyd@thefrontside.net"
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Charles Lowell"]
|
6
|
+
gem.email = ["javascript-and-friends@googlegroups.com"]
|
7
|
+
gem.summary = "Embed the V8 Javascript interpreter into Ruby"
|
8
|
+
gem.description = "Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript."
|
9
|
+
gem.homepage = "http://github.com/cowboyd/therubyracer"
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
s.require_paths = ["lib", "ext"]
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "therubyracer"
|
15
|
+
gem.extensions = ["ext/v8/extconf.rb"]
|
16
|
+
gem.require_paths = ["lib", "ext"]
|
17
|
+
gem.version = V8::VERSION
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
s.add_development_dependency "rake"
|
27
|
-
s.add_development_dependency "rspec", "~> 2.0"
|
28
|
-
s.add_development_dependency "rake-compiler"
|
19
|
+
gem.add_dependency 'ref'
|
29
20
|
end
|