mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
![Georgy Angelov](/assets/img/avatar_default.png)
This fixes segmentation fault in the tests as extending the examples in a before block with override of `#instance_eval` seems to not work. Also, the context wrap is now opt-in with a helper method, instead of opt-out and relying on `#described_class` (which has slightly different behavior in RSpec 3). Tested on Ruby 2.1.5 and RSpec 2.99.2.
30 lines
905 B
Ruby
30 lines
905 B
Ruby
# encoding: UTF-8
|
|
require 'spec_helper'
|
|
|
|
describe V8::C::Script do
|
|
requires_v8_context
|
|
|
|
it "can run a script and return a polymorphic result" do
|
|
source = V8::C::String::New("(new Array())")
|
|
filename = V8::C::String::New("<eval>")
|
|
script = V8::C::Script::New(source, filename)
|
|
result = script.Run()
|
|
result.should be_kind_of V8::C::Array
|
|
end
|
|
|
|
it "can accept precompiled script data" do
|
|
source = "7 * 6"
|
|
name = V8::C::String::New("<spec>")
|
|
origin = V8::C::ScriptOrigin.new(name)
|
|
data = V8::C::ScriptData::PreCompile(source, source.length)
|
|
data.HasError().should be_false
|
|
script = V8::C::Script::New(V8::C::String::New(source), origin, data)
|
|
script.Run().should eql 42
|
|
end
|
|
|
|
it "can detect errors in the script data" do
|
|
source = "^ = ;"
|
|
data = V8::C::ScriptData::PreCompile(source, source.length)
|
|
data.HasError().should be_true
|
|
end
|
|
end
|