Files
NapCatQQ/.pnpm-store/v3/files/83/8337360c9d90e96c11c82c9faf2a9a76c937e99d7b648082ab8b53802c5dd5067c82fbec91aa94491635a3bab3503c71e2456225bc7cffca1cf41ea0a5008d
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

47 lines
1.7 KiB
Plaintext

'use strict';
var test = require('tape');
var defineProperties = require('define-properties');
var callBind = require('call-bind');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = require('functions-have-names')();
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('builtin', function (t) {
var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
t.equal(descriptor.get.length, 0, 'RegExp#flags getter has a length of 0');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(descriptor.get.name, functionsHaveConfigurableNames ? 'get flags' : 'flags', 'RegExp#flags getter has name "get flags" (or "flags" if function names are not configurable)');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(RegExp.prototype, 'flags'), 'RegExp#flags is not enumerable');
et.end();
});
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
st['throws'](function () { return descriptor.get.call(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { return descriptor.get.call(null); }, TypeError, 'null is not an object');
st.end();
});
t.test('has the correct descriptor', function (st) {
st.equal(descriptor.configurable, true);
st.equal(descriptor.enumerable, false);
st.equal(typeof descriptor.get, 'function');
st.equal(descriptor.set, undefined);
st.end();
});
runTests(callBind(descriptor.get), t);
t.end();
});