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

make Array maintain referential integrity.

This commit is contained in:
Charles Lowell 2011-04-22 09:09:15 -05:00
parent 25744dffbf
commit 53e0b3d2ec
2 changed files with 16 additions and 3 deletions

View file

@ -44,7 +44,5 @@ void rr_init_v8_array() {
} }
VALUE rr_reflect_v8_array(Handle<Value> value) { VALUE rr_reflect_v8_array(Handle<Value> value) {
Local<Array> array(Array::Cast(*value)); return rr_reflect_v8_object_as(value, ArrayClass);
Local<Value> peer = array->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
return peer.IsEmpty() ? rr_v8_handle_new(ArrayClass, value) : (VALUE)External::Unwrap(peer);
} }

15
spec/ext/array_spec.rb Normal file
View file

@ -0,0 +1,15 @@
require "spec_helper"
describe V8::C::Array do
include V8::ExtSpec
it "can be instantiated" do
a = c::Array::New()
a.Length().should eql(0)
end
it "maintains referential integrity" do
v8_eval('a = []')
v8_eval('a').should be(v8_eval('a'))
end
end