Reviewers: rossberg,

Message:
PTAL

Description:
Make delete API consistent for String objects

Deleting a in-bounds character index from a String object should always return
false.

BUG=
LOG=N

Please review this at https://codereview.chromium.org/1153673003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+12, -1 lines):
  M src/api.cc
  M test/cctest/test-api.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 125a31be06f94b802e9f61a465335ee641b8c189..cf054147ac979786e2d621881ddf85a82a364252 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3481,7 +3481,7 @@ i::MaybeHandle<i::Object> DeleteObjectProperty(
     // underlying string does nothing with the deletion, we can ignore
     // such deletions.
     if (receiver->IsStringObjectWithCharacterAt(index)) {
-      return isolate->factory()->true_value();
+      return isolate->factory()->false_value();
     }

     return i::JSReceiver::DeleteElement(receiver, index, language_mode);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index e6c83849ae4881400eddc34ec268e0e51423c773..01a8d2ce7d2edb8a9bd9567fb308977c8dc07dc6 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1590,6 +1590,17 @@ THREADED_TEST(StringObject) {
 }


+TEST(StringObjectDelete) {
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
+  v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
+  CHECK(boxed_string->IsStringObject());
+  v8::Handle<v8::Object> str_obj = boxed_string.As<v8::Object>();
+  CHECK(!str_obj->Delete(2));
+  CHECK(!str_obj->Delete(v8_num(2)));
+}
+
+
 THREADED_TEST(NumberObject) {
   LocalContext env;
   v8::HandleScope scope(env->GetIsolate());


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to