Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 3678) |
+++ test/cctest/test-api.cc (working copy) |
@@ -61,6 +61,27 @@ |
namespace i = ::v8::internal; |
+static void ExpectString(const char* code, const char* expected) { |
+ Local<Value> result = CompileRun(code); |
+ CHECK(result->IsString()); |
+ String::AsciiValue ascii(result); |
+ CHECK_EQ(expected, *ascii); |
+} |
+ |
+ |
+static void ExpectBoolean(const char* code, bool expected) { |
+ Local<Value> result = CompileRun(code); |
+ CHECK(result->IsBoolean()); |
+ CHECK_EQ(expected, result->BooleanValue()); |
+} |
+ |
+ |
+static void ExpectObject(const char* code, Local<Value> expected) { |
+ Local<Value> result = CompileRun(code); |
+ CHECK(result->Equals(expected)); |
+} |
+ |
+ |
static int signature_callback_count; |
static v8::Handle<Value> IncrementingSignatureCallback( |
const v8::Arguments& args) { |
@@ -2381,6 +2402,36 @@ |
} |
+static v8::Handle<Value> IdentityIndexedPropertyGetter( |
+ uint32_t index, |
+ const AccessorInfo& info) { |
+ return v8::Integer::New(index); |
+} |
+ |
+ |
+THREADED_TEST(IndexedInterceptorWithNoSetter) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
+ |
+ LocalContext context; |
+ context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
+ |
+ const char* code = |
+ "try {" |
+ " obj[0] = 239;" |
+ " for (var i = 0; i < 100; i++) {" |
+ " var v = obj[0];" |
+ " if (v != 0) throw 'Wrong value ' + v + ' at iteration ' + i;" |
+ " }" |
+ " 'PASSED'" |
+ "} catch(e) {" |
+ " e" |
+ "}"; |
+ ExpectString(code, "PASSED"); |
+} |
+ |
+ |
THREADED_TEST(MultiContexts) { |
v8::HandleScope scope; |
v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); |
@@ -2467,27 +2518,6 @@ |
} |
-static void ExpectString(const char* code, const char* expected) { |
- Local<Value> result = CompileRun(code); |
- CHECK(result->IsString()); |
- String::AsciiValue ascii(result); |
- CHECK_EQ(0, strcmp(*ascii, expected)); |
-} |
- |
- |
-static void ExpectBoolean(const char* code, bool expected) { |
- Local<Value> result = CompileRun(code); |
- CHECK(result->IsBoolean()); |
- CHECK_EQ(expected, result->BooleanValue()); |
-} |
- |
- |
-static void ExpectObject(const char* code, Local<Value> expected) { |
- Local<Value> result = CompileRun(code); |
- CHECK(result->Equals(expected)); |
-} |
- |
- |
THREADED_TEST(UndetectableObject) { |
v8::HandleScope scope; |
LocalContext env; |