mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8966787624
Only keep the call count assertions under `common.isDebug`. PR-URL: https://github.com/nodejs/node/pull/54570 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
// Flags: --expose-internals --no-warnings --allow-natives-syntax
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const { URL } = require('url');
|
|
const assert = require('assert');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
// One argument is required
|
|
assert.throws(() => {
|
|
URL.canParse();
|
|
}, {
|
|
code: 'ERR_MISSING_ARGS',
|
|
name: 'TypeError',
|
|
});
|
|
|
|
// It should not throw when called without a base string
|
|
assert.strictEqual(URL.canParse('https://example.org'), true);
|
|
|
|
{
|
|
// V8 Fast API
|
|
function testFastPaths() {
|
|
// `canParse` binding has two overloads.
|
|
assert.strictEqual(URL.canParse('https://www.example.com/path/?query=param#hash'), true);
|
|
assert.strictEqual(URL.canParse('/', 'http://n'), true);
|
|
}
|
|
|
|
eval('%PrepareFunctionForOptimization(URL.canParse)');
|
|
testFastPaths();
|
|
eval('%OptimizeFunctionOnNextCall(URL.canParse)');
|
|
testFastPaths();
|
|
|
|
if (common.isDebug) {
|
|
const { getV8FastApiCallCount } = internalBinding('debug');
|
|
assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
|
|
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
|
|
}
|
|
}
|