Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: test/cctest/test-alloc.cc

Issue 8915: Extend test case to cover calling runtime functions (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-alloc.cc
===================================================================
--- test/cctest/test-alloc.cc (revision 655)
+++ test/cctest/test-alloc.cc (working copy)
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "v8.h"
+#include "accessors.h"
#include "top.h"
#include "cctest.h"
@@ -87,12 +88,13 @@
return Smi::FromInt(42);
}
+
static Handle<Object> Test() {
CALL_HEAP_FUNCTION(AllocateAfterFailures(), Object);
}
-TEST(Stress) {
+TEST(StressHandles) {
v8::Persistent<v8::Context> env = v8::Context::New();
v8::HandleScope scope;
env->Enter();
@@ -100,3 +102,45 @@
CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42);
env->Exit();
}
+
+
+static Object* TestAccessorGet(Object* object, void*) {
+ return AllocateAfterFailures();
+}
+
+
+const AccessorDescriptor kDescriptor = {
+ TestAccessorGet,
+ 0,
+ 0
+};
+
+
+TEST(StressJS) {
+ v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::HandleScope scope;
+ env->Enter();
+ Handle<JSFunction> function =
+ Factory::NewFunction(Factory::function_symbol(), Factory::null_value());
+ // Force the creation of an initial map and set the code to
+ // something empty.
+ Factory::NewJSObject(function);
+ function->set_code(Builtins::builtin(Builtins::EmptyFunction));
+ // Patch the map to have an accessor for "get".
+ Handle<Map> map(function->initial_map());
+ Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
+ Handle<Proxy> proxy = Factory::NewProxy(&kDescriptor);
+ instance_descriptors = Factory::CopyAppendProxyDescriptor(
+ instance_descriptors,
+ Factory::NewStringFromAscii(Vector<const char>("get", 3)),
+ proxy,
+ static_cast<PropertyAttributes>(0));
+ map->set_instance_descriptors(*instance_descriptors);
+ // Add the Foo constructor the global object.
+ env->Global()->Set(v8::String::New("Foo"), v8::Utils::ToLocal(function));
+ // Call the accessor through JavaScript.
+ v8::Handle<v8::Value> result =
+ v8::Script::Compile(v8::String::New("(new Foo).get"))->Run();
+ CHECK_EQ(42, result->Int32Value());
+ env->Exit();
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698