Tests should be explicit regarding whether a promise is expected to settle, and the test should fail when the behavior does not meet expectations. PR-URL: https://github.com/nodejs/node/pull/60976 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
38 lines
1 KiB
JavaScript
38 lines
1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const {
|
|
assertSummaryShape,
|
|
assertSingleDetailedShape,
|
|
expectExperimentalWarning
|
|
} = require('../common/measure-memory');
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
|
|
expectExperimentalWarning();
|
|
|
|
// Test eager memory measurement
|
|
{
|
|
vm.measureMemory({ execution: 'eager' })
|
|
.then(assertSummaryShape).then(common.mustCall());
|
|
|
|
if (!common.isWindows) {
|
|
vm.measureMemory({ mode: 'detailed', execution: 'eager' })
|
|
.then(assertSingleDetailedShape).then(common.mustCall());
|
|
}
|
|
|
|
vm.measureMemory({ mode: 'summary', execution: 'eager' })
|
|
.then(assertSummaryShape).then(common.mustCall());
|
|
|
|
assert.throws(() => vm.measureMemory(null), {
|
|
code: 'ERR_INVALID_ARG_TYPE'
|
|
});
|
|
assert.throws(() => vm.measureMemory('summary'), {
|
|
code: 'ERR_INVALID_ARG_TYPE'
|
|
});
|
|
assert.throws(() => vm.measureMemory({ mode: 'random' }), {
|
|
code: 'ERR_INVALID_ARG_VALUE'
|
|
});
|
|
assert.throws(() => vm.measureMemory({ execution: 'random' }), {
|
|
code: 'ERR_INVALID_ARG_VALUE'
|
|
});
|
|
}
|