mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
73da2c426d
PR-URL: https://github.com/nodejs/node/pull/45550 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const common = require('./');
|
|
|
|
// The formats could change when V8 is updated, then the tests should be
|
|
// updated accordingly.
|
|
function assertResultShape(result) {
|
|
assert.strictEqual(typeof result.jsMemoryEstimate, 'number');
|
|
assert.strictEqual(typeof result.jsMemoryRange[0], 'number');
|
|
assert.strictEqual(typeof result.jsMemoryRange[1], 'number');
|
|
}
|
|
|
|
function assertSummaryShape(result) {
|
|
assert.strictEqual(typeof result, 'object');
|
|
assert.strictEqual(typeof result.total, 'object');
|
|
assertResultShape(result.total);
|
|
}
|
|
|
|
function assertDetailedShape(result, contexts = 0) {
|
|
assert.strictEqual(typeof result, 'object');
|
|
assert.strictEqual(typeof result.total, 'object');
|
|
assert.strictEqual(typeof result.current, 'object');
|
|
assertResultShape(result.total);
|
|
assertResultShape(result.current);
|
|
if (contexts === 0) {
|
|
assert.deepStrictEqual(result.other, []);
|
|
} else {
|
|
assert.strictEqual(result.other.length, contexts);
|
|
for (const item of result.other) {
|
|
assertResultShape(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
function assertSingleDetailedShape(result) {
|
|
assert.strictEqual(typeof result, 'object');
|
|
assert.strictEqual(typeof result.total, 'object');
|
|
assert.strictEqual(typeof result.current, 'object');
|
|
assert.deepStrictEqual(result.other, []);
|
|
assertResultShape(result.total);
|
|
assertResultShape(result.current);
|
|
}
|
|
|
|
function expectExperimentalWarning() {
|
|
common.expectWarning(
|
|
'ExperimentalWarning',
|
|
'vm.measureMemory is an experimental feature and might change at any time',
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
assertSummaryShape,
|
|
assertDetailedShape,
|
|
assertSingleDetailedShape,
|
|
expectExperimentalWarning,
|
|
};
|