Index: test/unittests/value-serializer-unittest.cc |
diff --git a/test/unittests/value-serializer-unittest.cc b/test/unittests/value-serializer-unittest.cc |
index 9f1aa2fa9999237dcd578e88cf8deb978c141875..41e5ba01435322994cb0266195723a148316c49f 100644 |
--- a/test/unittests/value-serializer-unittest.cc |
+++ b/test/unittests/value-serializer-unittest.cc |
@@ -50,6 +50,21 @@ class ValueSerializerTest : public TestWithIsolate { |
output_functor); |
} |
+ // Variant which uses JSON.parse/stringify to check the result. |
+ void RoundTripJSON(const char* source) { |
+ RoundTripTest( |
+ [this, source]() { |
+ return JSON::Parse(serialization_context_, StringFromUtf8(source)) |
+ .ToLocalChecked(); |
+ }, |
+ [this, source](Local<Value> value) { |
+ ASSERT_TRUE(value->IsObject()); |
+ EXPECT_EQ(source, Utf8Value(JSON::Stringify(deserialization_context_, |
+ value.As<Object>()) |
+ .ToLocalChecked())); |
+ }); |
+ } |
+ |
Maybe<std::vector<uint8_t>> DoEncode(Local<Value> value) { |
Local<Context> context = serialization_context(); |
ValueSerializer serializer(isolate()); |
@@ -656,6 +671,23 @@ TEST_F(ValueSerializerTest, RoundTripTrickyGetters) { |
}); |
} |
+TEST_F(ValueSerializerTest, RoundTripDictionaryObjectForTransitions) { |
+ // A case which should run on the fast path, and should reach all of the |
+ // different cases: |
+ // - expected transition matched |
+ // - expected transition failed to match |
+ // - transition found (of multiple possible) |
+ // - no known transition |
Camillo Bruni
2016/09/14 16:26:20
nit: can you update the order of the comment, so i
jbroman
2016/09/14 19:07:16
Done.
|
+ RoundTripJSON( |
+ "[{\"x\":1,\"y\":2,\"z\":3},{\"x\":4,\"y\":5,\"z\":6},{\"x\":5,\"y\":6," |
+ "\"w\":7},{\"x\":6,\"y\":7,\"z\":8},{\"x\":0,\"y\":0,\"w\":0}]"); |
Camillo Bruni
2016/09/14 16:26:20
late question: single quotes doesn't work for the
jbroman
2016/09/14 19:07:16
This uses JSON::Parse/Stringify to compare the obj
|
+ // A slightly simpler case that uses two-byte strings. |
+ RoundTripJSON( |
+ "[{\"\xF0\x9F\x91\x8A\":1,\"\xF0\x9F\x91\x8B\":2},{\"\xF0\x9F\x91\x8A\":" |
+ "3,\"\xF0\x9F\x91\x8C\":4},{\"\xF0\x9F\x91\x8A\":5,\"\xF0\x9F\x91\x9B\":" |
+ "6}]"); |
+} |
+ |
TEST_F(ValueSerializerTest, DecodeDictionaryObjectVersion0) { |
// Empty object. |
DecodeTestForVersion0( |