0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-26 00:59:28 -05:00

chore: test String object serialization (#747)

Serializing `new String("")` requires that the wire format header is
written, otherwise V8 assumes an incompatible legacy wire format when
deserializing.
This commit is contained in:
Ben Noordhuis 2021-08-07 23:33:53 +02:00 committed by GitHub
parent 245c7b2b8e
commit 24bef1e54b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4444,6 +4444,9 @@ fn value_serializer_and_deserializer() {
#[test]
fn value_serializer_and_deserializer_js_objects() {
use v8::ValueDeserializerHelper;
use v8::ValueSerializerHelper;
let buffer;
let mut array_buffers = ArrayBuffers::new();
{
@ -4466,6 +4469,7 @@ fn value_serializer_and_deserializer_js_objects() {
44.444,
99999.55434344,
"test",
new String("test"),
[1, 2, 3],
{a: "tt", add: "tsqqqss"}
]"#,
@ -4473,6 +4477,7 @@ fn value_serializer_and_deserializer_js_objects() {
.unwrap();
let mut value_serializer =
Custom1Value::serializer(scope, &mut array_buffers);
value_serializer.write_header();
assert_eq!(value_serializer.write_value(context, objects), Some(true));
buffer = value_serializer.release();
@ -4489,6 +4494,7 @@ fn value_serializer_and_deserializer_js_objects() {
let mut value_deserializer =
Custom1Value::deserializer(scope, &buffer, &mut array_buffers);
assert_eq!(value_deserializer.read_header(context), Some(true));
let name = v8::String::new(scope, "objects").unwrap();
let objects: v8::Local<v8::Value> =
value_deserializer.read_value(context).unwrap();
@ -4509,6 +4515,7 @@ fn value_serializer_and_deserializer_js_objects() {
44.444,
99999.55434344,
"test",
new String("test"),
[1, 2, 3],
{a: "tt", add: "tsqqqss"}
];