mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 10:46:01 +00:00
Modules
This commit is contained in:
42
node_modules/es-abstract/test/helpers/OwnPropertyKeys.js
generated
vendored
Normal file
42
node_modules/es-abstract/test/helpers/OwnPropertyKeys.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var OwnPropertyKeys = require('../../helpers/OwnPropertyKeys');
|
||||
var defineProperty = require('./defineProperty');
|
||||
|
||||
test('OwnPropertyKeys', function (t) {
|
||||
t.deepEqual(OwnPropertyKeys({ a: 1, b: 2 }).sort(), ['a', 'b'].sort(), 'returns own string keys');
|
||||
|
||||
t.test('Symbols', { skip: !hasSymbols }, function (st) {
|
||||
var o = { a: 1 };
|
||||
var sym = Symbol();
|
||||
o[sym] = 2;
|
||||
|
||||
st.deepEqual(OwnPropertyKeys(o), ['a', sym], 'returns own string and symbol keys');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('non-enumerables', { skip: !defineProperty.oDP }, function (st) {
|
||||
var o = { a: 1, b: 42, c: NaN };
|
||||
defineProperty(o, 'b', { enumerable: false, value: 42 });
|
||||
defineProperty(o, 'c', { enumerable: false, get: function () { return NaN; } });
|
||||
|
||||
if (hasSymbols) {
|
||||
defineProperty(o, 'd', { enumerable: false, value: true });
|
||||
defineProperty(o, 'e', { enumerable: false, get: function () { return true; } });
|
||||
}
|
||||
|
||||
st.deepEqual(
|
||||
OwnPropertyKeys(o).sort(),
|
||||
(hasSymbols ? ['a', 'b', 'c', 'd', 'e'] : ['a', 'b', 'c']).sort(),
|
||||
'returns non-enumerable own keys, including accessors and symbols if available'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
60
node_modules/es-abstract/test/helpers/assertRecord.js
generated
vendored
Normal file
60
node_modules/es-abstract/test/helpers/assertRecord.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var forEach = require('foreach');
|
||||
var debug = require('object-inspect');
|
||||
|
||||
var assertRecord = require('../../helpers/assertRecord');
|
||||
var v = require('./values');
|
||||
|
||||
module.exports = function assertRecordTests(ES, test) {
|
||||
test('Property Descriptor', function (t) {
|
||||
var record = 'Property Descriptor';
|
||||
|
||||
forEach(v.nonUndefinedPrimitives, function (primitive) {
|
||||
t['throws'](
|
||||
function () { assertRecord(ES.Type, record, 'arg', primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not a Property Descriptor'
|
||||
);
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
function () { assertRecord(ES.Type, record, 'arg', { invalid: true }); },
|
||||
TypeError,
|
||||
'invalid keys not allowed on a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES.Type, record, 'arg', {}); },
|
||||
'empty object is an incomplete Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES.Type, record, 'arg', v.accessorDescriptor()); },
|
||||
'accessor descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES.Type, record, 'arg', v.mutatorDescriptor()); },
|
||||
'mutator descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES.Type, record, 'arg', v.dataDescriptor()); },
|
||||
'data descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES.Type, record, 'arg', v.genericDescriptor()); },
|
||||
'generic descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { assertRecord(ES.Type, record, 'arg', v.bothDescriptor()); },
|
||||
TypeError,
|
||||
'a Property Descriptor can not be both a Data and an Accessor Descriptor'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
};
|
22
node_modules/es-abstract/test/helpers/defineProperty.js
generated
vendored
Normal file
22
node_modules/es-abstract/test/helpers/defineProperty.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var oDP = Object.defineProperty;
|
||||
try {
|
||||
oDP({}, 'a', { value: 1 });
|
||||
} catch (e) {
|
||||
// IE 8
|
||||
oDP = null;
|
||||
}
|
||||
|
||||
module.exports = function defineProperty(O, P, Desc) {
|
||||
if (oDP) {
|
||||
return oDP(O, P, Desc);
|
||||
}
|
||||
if ((Desc.enumerable && Desc.configurable && Desc.writable) || !(P in O)) {
|
||||
O[P] = Desc.value; // eslint-disable-line no-param-reassign
|
||||
return O;
|
||||
}
|
||||
|
||||
throw new SyntaxError('helper does not yet support this configuration');
|
||||
};
|
||||
module.exports.oDP = oDP;
|
55
node_modules/es-abstract/test/helpers/getSymbolDescription.js
generated
vendored
Normal file
55
node_modules/es-abstract/test/helpers/getSymbolDescription.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var debug = require('object-inspect');
|
||||
var forEach = require('foreach');
|
||||
|
||||
var v = require('./values');
|
||||
var getSymbolDescription = require('../../helpers/getSymbolDescription');
|
||||
var getInferredName = require('../../helpers/getInferredName');
|
||||
|
||||
test('getSymbolDescription', function (t) {
|
||||
t.test('no symbols', { skip: v.hasSymbols }, function (st) {
|
||||
st['throws'](
|
||||
getSymbolDescription,
|
||||
SyntaxError,
|
||||
'requires Symbol support'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) {
|
||||
t['throws'](
|
||||
function () { getSymbolDescription(nonSymbol); },
|
||||
v.hasSymbols ? TypeError : SyntaxError,
|
||||
debug(nonSymbol) + ' is not a Symbol'
|
||||
);
|
||||
});
|
||||
|
||||
t.test('with symbols', { skip: !v.hasSymbols }, function (st) {
|
||||
forEach(
|
||||
[
|
||||
[Symbol(), undefined],
|
||||
[Symbol(undefined), undefined],
|
||||
[Symbol(null), 'null'],
|
||||
[Symbol.iterator, 'Symbol.iterator'],
|
||||
[Symbol('foo'), 'foo']
|
||||
],
|
||||
function (pair) {
|
||||
var sym = pair[0];
|
||||
var desc = pair[1];
|
||||
st.equal(getSymbolDescription(sym), desc, debug(sym) + ' yields ' + debug(desc));
|
||||
}
|
||||
);
|
||||
|
||||
st.test('only possible when inference is supported', { skip: !getInferredName }, function (s2t) {
|
||||
s2t.equal(getSymbolDescription(Symbol('')), '', 'Symbol("") description is empty string');
|
||||
s2t.end();
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
27
node_modules/es-abstract/test/helpers/runManifestTest.js
generated
vendored
Normal file
27
node_modules/es-abstract/test/helpers/runManifestTest.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var forEach = require('foreach');
|
||||
var keys = require('object-keys');
|
||||
|
||||
module.exports = function runManifestTest(test, ES, edition) {
|
||||
test('ES' + edition + ' manifest', { skip: !fs.readdirSync }, function (t) {
|
||||
var files = fs.readdirSync(path.join(__dirname, '../../' + edition), 'utf-8');
|
||||
var map = {
|
||||
AbstractEqualityComparison: 'Abstract Equality Comparison',
|
||||
AbstractRelationalComparison: 'Abstract Relational Comparison',
|
||||
StrictEqualityComparison: 'Strict Equality Comparison'
|
||||
};
|
||||
forEach(files, function (file) {
|
||||
var name = path.basename(file, path.extname(file));
|
||||
var actual = ES[map[name] || name];
|
||||
var expected = require(path.join(__dirname, '../../' + edition + '/', file)); // eslint-disable-line global-require
|
||||
t.equal(actual, expected, 'ES["' + name + '"] === ' + file);
|
||||
});
|
||||
var actualCount = keys(ES).length;
|
||||
t.equal(actualCount, files.length, 'expected ' + files.length + ' files, got ' + actualCount);
|
||||
t.end();
|
||||
});
|
||||
};
|
121
node_modules/es-abstract/test/helpers/values.js
generated
vendored
Normal file
121
node_modules/es-abstract/test/helpers/values.js
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
var assign = require('../../helpers/assign');
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } };
|
||||
var coercibleFnObject = {
|
||||
valueOf: function () { return function valueOfFn() {}; },
|
||||
toString: function () { return 42; }
|
||||
};
|
||||
var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } };
|
||||
var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } };
|
||||
var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } };
|
||||
var uncoercibleFnObject = {
|
||||
valueOf: function () { return function valueOfFn() {}; },
|
||||
toString: function () { return function toStrFn() {}; }
|
||||
};
|
||||
var objects = [{}, coercibleObject, coercibleFnObject, toStringOnlyObject, valueOfOnlyObject];
|
||||
var nullPrimitives = [undefined, null];
|
||||
var nonIntegerNumbers = [-1.3, 0.2, 1.8, 1 / 3];
|
||||
var zeroes = [0, -0];
|
||||
var infinities = [Infinity, -Infinity];
|
||||
var numbers = zeroes.concat([42], infinities, nonIntegerNumbers);
|
||||
var strings = ['', 'foo', 'a\uD83D\uDCA9c'];
|
||||
var booleans = [true, false];
|
||||
var symbols = hasSymbols ? [Symbol.iterator, Symbol('foo')] : [];
|
||||
var nonSymbolPrimitives = [].concat(nullPrimitives, booleans, strings, numbers);
|
||||
var nonNumberPrimitives = [].concat(nullPrimitives, booleans, strings, symbols);
|
||||
var nonNullPrimitives = [].concat(booleans, strings, numbers, symbols);
|
||||
var nonUndefinedPrimitives = [].concat(null, nonNullPrimitives);
|
||||
var nonStrings = [].concat(nullPrimitives, booleans, numbers, symbols, objects);
|
||||
var primitives = [].concat(nullPrimitives, nonNullPrimitives);
|
||||
var nonPropertyKeys = [].concat(nullPrimitives, booleans, numbers, objects);
|
||||
var propertyKeys = [].concat(strings, symbols);
|
||||
var nonBooleans = [].concat(nullPrimitives, strings, symbols, numbers, objects);
|
||||
var falsies = [].concat(nullPrimitives, false, '', 0, -0, NaN);
|
||||
var truthies = [].concat(true, 'foo', 42, symbols, objects);
|
||||
var timestamps = [].concat(0, 946713600000, 1546329600000);
|
||||
var nonFunctions = [].concat(primitives, objects, [42]);
|
||||
var nonArrays = [].concat(nonFunctions);
|
||||
|
||||
var descriptors = {
|
||||
configurable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Configurable]]': true });
|
||||
},
|
||||
nonConfigurable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Configurable]]': false });
|
||||
},
|
||||
enumerable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Enumerable]]': true });
|
||||
},
|
||||
nonEnumerable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Enumerable]]': false });
|
||||
},
|
||||
writable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Writable]]': true });
|
||||
},
|
||||
nonWritable: function (descriptor) {
|
||||
return assign(assign({}, descriptor), { '[[Writable]]': false });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
coercibleObject: coercibleObject,
|
||||
coercibleFnObject: coercibleFnObject,
|
||||
valueOfOnlyObject: valueOfOnlyObject,
|
||||
toStringOnlyObject: toStringOnlyObject,
|
||||
uncoercibleObject: uncoercibleObject,
|
||||
uncoercibleFnObject: uncoercibleFnObject,
|
||||
objects: objects,
|
||||
nonFunctions: nonFunctions,
|
||||
nonArrays: nonArrays,
|
||||
nullPrimitives: nullPrimitives,
|
||||
numbers: numbers,
|
||||
zeroes: zeroes,
|
||||
infinities: infinities,
|
||||
strings: strings,
|
||||
booleans: booleans,
|
||||
symbols: symbols,
|
||||
hasSymbols: hasSymbols,
|
||||
nonSymbolPrimitives: nonSymbolPrimitives,
|
||||
nonNumberPrimitives: nonNumberPrimitives,
|
||||
nonNullPrimitives: nonNullPrimitives,
|
||||
nonUndefinedPrimitives: nonUndefinedPrimitives,
|
||||
nonStrings: nonStrings,
|
||||
nonNumbers: nonNumberPrimitives.concat(objects),
|
||||
nonIntegerNumbers: nonIntegerNumbers,
|
||||
primitives: primitives,
|
||||
nonPropertyKeys: nonPropertyKeys,
|
||||
propertyKeys: propertyKeys,
|
||||
nonBooleans: nonBooleans,
|
||||
falsies: falsies,
|
||||
truthies: truthies,
|
||||
timestamps: timestamps,
|
||||
bothDescriptor: function () {
|
||||
return { '[[Get]]': function () {}, '[[Value]]': true };
|
||||
},
|
||||
bothDescriptorWritable: function () {
|
||||
return descriptors.writable({ '[[Get]]': function () {} });
|
||||
},
|
||||
accessorDescriptor: function (value) {
|
||||
return descriptors.enumerable(descriptors.configurable({
|
||||
'[[Get]]': function get() { return value; }
|
||||
}));
|
||||
},
|
||||
mutatorDescriptor: function () {
|
||||
return descriptors.enumerable(descriptors.configurable({
|
||||
'[[Set]]': function () {}
|
||||
}));
|
||||
},
|
||||
dataDescriptor: function (value) {
|
||||
return descriptors.nonWritable({
|
||||
'[[Value]]': arguments.length > 0 ? value : 42
|
||||
});
|
||||
},
|
||||
genericDescriptor: function () {
|
||||
return descriptors.configurable(descriptors.nonEnumerable());
|
||||
},
|
||||
descriptors: descriptors
|
||||
};
|
Reference in New Issue
Block a user