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

Unified Diff: test/unittests/value-serializer-unittest.cc

Issue 2311063004: ValueSerializer: Take advantage of fast elements in dense array serialization. (Closed)
Patch Set: additional unit tests Created 4 years, 3 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 | « src/value-serializer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/value-serializer-unittest.cc
diff --git a/test/unittests/value-serializer-unittest.cc b/test/unittests/value-serializer-unittest.cc
index 9328b3381800508cbc2460208050dac010525b6b..9f1aa2fa9999237dcd578e88cf8deb978c141875 100644
--- a/test/unittests/value-serializer-unittest.cc
+++ b/test/unittests/value-serializer-unittest.cc
@@ -947,6 +947,19 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === 1"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(2)"));
});
+ // The same is true if the length is shortened, but there are still items
+ // remaining.
+ RoundTripTest(
+ "(() => {"
+ " var x = [1, { get a() { x.length = 3; }}, 3, 4];"
+ " return x;"
+ "})()",
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsArray());
+ ASSERT_EQ(4, Array::Cast(*value)->Length());
+ EXPECT_TRUE(EvaluateScriptForResultBool("result[2] === 3"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(3)"));
+ });
// Same for sparse arrays.
RoundTripTest(
"(() => {"
@@ -960,6 +973,18 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
EXPECT_TRUE(EvaluateScriptForResultBool("result[0] === 1"));
EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(2)"));
});
+ RoundTripTest(
+ "(() => {"
+ " var x = [1, { get a() { x.length = 3; }}, 3, 4];"
+ " x.length = 1000;"
+ " return x;"
+ "})()",
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsArray());
+ ASSERT_EQ(1000, Array::Cast(*value)->Length());
+ EXPECT_TRUE(EvaluateScriptForResultBool("result[2] === 3"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(3)"));
+ });
// If a getter makes a property non-enumerable, it should still be enumerated
// as enumeration happens once before getters are invoked.
RoundTripTest(
« no previous file with comments | « src/value-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698