Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 1b6359b40d09670145639d0946d27db33bd0bf2a..473dd1b4dddaebbb03e5968cdaad7a6303baeb11 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -3061,7 +3061,7 @@ THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
static v8::Handle<Value> IdentityIndexedPropertyGetter( |
uint32_t index, |
const AccessorInfo& info) { |
- return v8::Integer::New(index); |
+ return v8::Integer::NewFromUnsigned(index); |
} |
@@ -3186,6 +3186,45 @@ THREADED_TEST(IndexedInterceptorWithDifferentIndices) { |
} |
+THREADED_TEST(IndexedInterceptorWithNegativeIndices) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
+ |
+ LocalContext context; |
+ Local<v8::Object> obj = templ->NewInstance(); |
+ context->Global()->Set(v8_str("obj"), obj); |
+ |
+ const char* code = |
+ "try {" |
+ " for (var i = 0; i < 100; i++) {" |
+ " var expected = i;" |
+ " var key = i;" |
+ " if (i == 25) {" |
+ " key = -1;" |
+ " expected = undefined;" |
+ " }" |
+ " if (i == 50) {" |
+ " /* probe minimal Smi number on 32-bit platforms */" |
+ " key = -(1 << 30);" |
+ " expected = undefined;" |
+ " }" |
+ " if (i == 75) {" |
+ " /* probe minimal Smi number on 64-bit platforms */" |
+ " key = 1 << 31;" |
+ " expected = undefined;" |
+ " }" |
+ " var v = obj[key];" |
+ " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
+ " }" |
+ " 'PASSED'" |
+ "} catch(e) {" |
+ " e" |
+ "}"; |
+ ExpectString(code, "PASSED"); |
+} |
+ |
+ |
THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { |
v8::HandleScope scope; |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
@@ -3199,11 +3238,12 @@ THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { |
"try {" |
" for (var i = 0; i < 100; i++) {" |
" var expected = i;" |
+ " var key = i;" |
" if (i == 50) {" |
- " i = 'foobar';" |
+ " key = 'foobar';" |
" expected = undefined;" |
" }" |
- " var v = obj[i];" |
+ " var v = obj[key];" |
" if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
" }" |
" 'PASSED'" |