Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 3679) |
+++ test/cctest/test-api.cc (working copy) |
@@ -184,6 +184,32 @@ |
int RegisterThreadedTest::count_ = 0; |
+// Helper function that compiles and runs the source. |
+static Local<Value> CompileRun(const char* source) { |
+ return Script::Compile(String::New(source))->Run(); |
+} |
+ |
+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) { |
@@ -231,11 +257,6 @@ |
} |
-// Helper function that compiles and runs the source. |
-static Local<Value> CompileRun(const char* source) { |
- return Script::Compile(String::New(source))->Run(); |
-} |
- |
THREADED_TEST(ReceiverSignature) { |
v8::HandleScope scope; |
LocalContext env; |
@@ -2583,6 +2604,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(); |
@@ -2669,27 +2720,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; |