v8/test/mjsunit/web-snapshot/web-snapshot-holey-array.js
jameslahm df251e4496 [web snapshot] Add verification mode
We should verify the consistency of the objects we produced after deserializing successfully.

Bug: v8:11525
Change-Id: Ieec1aa7112ab6eda0c61a1a9ab78e86ad8352942
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3813061
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82272}
2022-08-08 15:47:22 +00:00

50 lines
1.4 KiB
JavaScript

// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-d8-web-snapshot-api --allow-natives-syntax --verify-heap
'use strict';
d8.file.execute('test/mjsunit/web-snapshot/web-snapshot-helpers.js');
(function TestHoleySmiElementsArray() {
function createObjects() {
globalThis.foo = [1,,2];
}
const {foo} = takeAndUseWebSnapshot(createObjects, ['foo']);
assertEquals([1,,2], foo);
})();
(function TestHoleyElementsArray() {
function createObjects() {
globalThis.foo = [1,,"123"];
}
const {foo} = takeAndUseWebSnapshot(createObjects, ['foo']);
assertEquals([1,,"123"], foo);
})();
(function TestHoleyArrayContainingDoubleAndSmi() {
function createObjects() {
globalThis.foo = [1.2, , 1];
}
const { foo } = takeAndUseWebSnapshot(createObjects, ['foo']);
assertEquals([1.2, , 1], foo);
})();
(function TestHoleyArrayContainingDoubleAndObject() {
function createObjects() {
globalThis.foo = [1.2, , {'key': 'value'}];
}
const { foo } = takeAndUseWebSnapshot(createObjects, ['foo']);
assertEquals([1.2, , {'key': 'value'}], foo);
})();
(function TestHoleyDoubleElementsArray() {
function createObjects() {
globalThis.foo = [1.2, , 2.3];
}
const {foo} = takeAndUseWebSnapshot(createObjects, ['foo']);
assertEquals([1.2, , 2.3], foo);
})();