mirror of
https://github.com/cachix/install-nix-action.git
synced 2025-06-08 18:04:29 +00:00
v6
This commit is contained in:
parent
cd5893b2c6
commit
70742d22d9
6774 changed files with 1602535 additions and 1 deletions
13
node_modules/es-abstract/test/.eslintrc
generated
vendored
Normal file
13
node_modules/es-abstract/test/.eslintrc
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"rules": {
|
||||
"id-length": 0,
|
||||
"max-lines": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"max-statements-per-line": [2, { "max": 3 }],
|
||||
"max-nested-callbacks": [2, 4],
|
||||
"max-statements": 0,
|
||||
"no-implicit-coercion": 1,
|
||||
"no-invalid-this": 1,
|
||||
"object-curly-newline": 0,
|
||||
}
|
||||
}
|
34
node_modules/es-abstract/test/GetIntrinsic.js
generated
vendored
Normal file
34
node_modules/es-abstract/test/GetIntrinsic.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
|
||||
var test = require('tape');
|
||||
var forEach = require('foreach');
|
||||
var debug = require('object-inspect');
|
||||
|
||||
var v = require('./helpers/values');
|
||||
|
||||
test('export', function (t) {
|
||||
t.equal(typeof GetIntrinsic, 'function', 'it is a function');
|
||||
t.equal(GetIntrinsic.length, 2, 'function has length of 2');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('throws', function (t) {
|
||||
t['throws'](
|
||||
function () { GetIntrinsic('not an intrinsic'); },
|
||||
SyntaxError,
|
||||
'nonexistent intrinsic throws a syntax error'
|
||||
);
|
||||
|
||||
forEach(v.nonBooleans, function (nonBoolean) {
|
||||
t['throws'](
|
||||
function () { GetIntrinsic('%', nonBoolean); },
|
||||
TypeError,
|
||||
debug(nonBoolean) + ' is not a Boolean'
|
||||
);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
26
node_modules/es-abstract/test/diffOps.js
generated
vendored
Normal file
26
node_modules/es-abstract/test/diffOps.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
var keys = require('object-keys');
|
||||
var forEach = require('foreach');
|
||||
|
||||
module.exports = function diffOperations(actual, expected, expectedMissing) {
|
||||
var actualKeys = keys(actual);
|
||||
var expectedKeys = keys(expected);
|
||||
|
||||
var extra = [];
|
||||
var missing = [];
|
||||
forEach(actualKeys, function (op) {
|
||||
if (!(op in expected)) {
|
||||
extra.push(op);
|
||||
} else if (expectedMissing.indexOf(op) !== -1) {
|
||||
extra.push(op);
|
||||
}
|
||||
});
|
||||
forEach(expectedKeys, function (op) {
|
||||
if (typeof actual[op] !== 'function' && expectedMissing.indexOf(op) === -1) {
|
||||
missing.push(op);
|
||||
}
|
||||
});
|
||||
|
||||
return { missing: missing, extra: extra };
|
||||
};
|
9
node_modules/es-abstract/test/es2015.js
generated
vendored
Normal file
9
node_modules/es-abstract/test/es2015.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
var ES = require('../').ES2015;
|
||||
|
||||
var ops = require('../operations/2015');
|
||||
|
||||
var expectedMissing = ['Construct', 'CreateArrayFromList', 'CreateListFromArrayLike', 'CreateListIterator', 'NormalCompletion', 'RegExpBuiltinExec'];
|
||||
|
||||
require('./tests').es2015(ES, ops, expectedMissing);
|
9
node_modules/es-abstract/test/es2016.js
generated
vendored
Normal file
9
node_modules/es-abstract/test/es2016.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
var ES = require('../').ES2016;
|
||||
|
||||
var ops = require('../operations/2016');
|
||||
|
||||
var expectedMissing = ['AddRestrictedFunctionProperties', 'AllocateArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'Construct', 'CopyDataBlockBytes', 'CreateArrayFromList', 'CreateArrayIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateIntrinsics', 'CreateListFromArrayLike', 'CreateListIterator', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DayWithinYear', 'DaysInYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateDirectCall', 'EvaluateNew', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetFunctionRealm', 'GetGlobalObject', 'GetIdentifierReference', 'GetModuleNamespace', 'GetNewTarget', 'GetPrototypeFromConstructor', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GlobalDeclarationInstantiation', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InLeapYear', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsWordChar', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'MinFromTime', 'MinutesPerHour', 'ModuleNamespaceCreate', 'MonthFromTime', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NextJob', 'NormalCompletion', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetPrototypeOf', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySet', 'OrdinarySetPrototypeOf', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RegExpAlloc', 'RegExpBuiltinExec', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SortCompare', 'SplitMatch', 'StringCreate', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'ToDateString', 'ToString Applied to the Number Type', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'UpdateEmpty', 'ValidateTypedArray', 'WeekDay', 'YearFromTime', 'abs', 'floor', 'max', 'min', 'modulo', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond'];
|
||||
|
||||
require('./tests').es2016(ES, ops, expectedMissing);
|
9
node_modules/es-abstract/test/es2017.js
generated
vendored
Normal file
9
node_modules/es-abstract/test/es2017.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/es-abstract/test/es2018.js
generated
vendored
Normal file
9
node_modules/es-abstract/test/es2018.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/es-abstract/test/es2019.js
generated
vendored
Normal file
9
node_modules/es-abstract/test/es2019.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
530
node_modules/es-abstract/test/es5.js
generated
vendored
Normal file
530
node_modules/es-abstract/test/es5.js
generated
vendored
Normal file
|
@ -0,0 +1,530 @@
|
|||
'use strict';
|
||||
|
||||
var ES = require('../').ES5;
|
||||
var test = require('tape');
|
||||
|
||||
var forEach = require('foreach');
|
||||
var is = require('object-is');
|
||||
var debug = require('object-inspect');
|
||||
|
||||
var v = require('./helpers/values');
|
||||
|
||||
test('ToPrimitive', function (t) {
|
||||
t.test('primitives', function (st) {
|
||||
var testPrimitive = function (primitive) {
|
||||
st.ok(is(ES.ToPrimitive(primitive), primitive), debug(primitive) + ' is returned correctly');
|
||||
};
|
||||
forEach(v.primitives, testPrimitive);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('objects', function (st) {
|
||||
st.equal(ES.ToPrimitive(v.coercibleObject), v.coercibleObject.valueOf(), 'coercibleObject coerces to valueOf');
|
||||
st.equal(ES.ToPrimitive(v.coercibleObject, Number), v.coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf');
|
||||
st.equal(ES.ToPrimitive(v.coercibleObject, String), v.coercibleObject.toString(), 'coercibleObject with hint String coerces to toString');
|
||||
st.equal(ES.ToPrimitive(v.coercibleFnObject), v.coercibleFnObject.toString(), 'coercibleFnObject coerces to toString');
|
||||
st.equal(ES.ToPrimitive(v.toStringOnlyObject), v.toStringOnlyObject.toString(), 'toStringOnlyObject returns toString');
|
||||
st.equal(ES.ToPrimitive(v.valueOfOnlyObject), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf');
|
||||
st.equal(ES.ToPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString');
|
||||
st.equal(ES.ToPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString');
|
||||
st.equal(ES.ToPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString');
|
||||
st['throws'](function () { return ES.ToPrimitive(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError');
|
||||
st['throws'](function () { return ES.ToPrimitive(v.uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToBoolean', function (t) {
|
||||
t.equal(false, ES.ToBoolean(undefined), 'undefined coerces to false');
|
||||
t.equal(false, ES.ToBoolean(null), 'null coerces to false');
|
||||
t.equal(false, ES.ToBoolean(false), 'false returns false');
|
||||
t.equal(true, ES.ToBoolean(true), 'true returns true');
|
||||
forEach([0, -0, NaN], function (falsyNumber) {
|
||||
t.equal(false, ES.ToBoolean(falsyNumber), 'falsy number ' + falsyNumber + ' coerces to false');
|
||||
});
|
||||
forEach([Infinity, 42, 1, -Infinity], function (truthyNumber) {
|
||||
t.equal(true, ES.ToBoolean(truthyNumber), 'truthy number ' + truthyNumber + ' coerces to true');
|
||||
});
|
||||
t.equal(false, ES.ToBoolean(''), 'empty string coerces to false');
|
||||
t.equal(true, ES.ToBoolean('foo'), 'nonempty string coerces to true');
|
||||
forEach(v.objects, function (obj) {
|
||||
t.equal(true, ES.ToBoolean(obj), 'object coerces to true');
|
||||
});
|
||||
t.equal(true, ES.ToBoolean(v.uncoercibleObject), 'uncoercibleObject coerces to true');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToNumber', function (t) {
|
||||
t.ok(is(NaN, ES.ToNumber(undefined)), 'undefined coerces to NaN');
|
||||
t.ok(is(ES.ToNumber(null), 0), 'null coerces to +0');
|
||||
t.ok(is(ES.ToNumber(false), 0), 'false coerces to +0');
|
||||
t.equal(1, ES.ToNumber(true), 'true coerces to 1');
|
||||
t.ok(is(NaN, ES.ToNumber(NaN)), 'NaN returns itself');
|
||||
forEach([0, -0, 42, Infinity, -Infinity], function (num) {
|
||||
t.equal(num, ES.ToNumber(num), num + ' returns itself');
|
||||
});
|
||||
forEach(['foo', '0', '4a', '2.0', 'Infinity', '-Infinity'], function (numString) {
|
||||
t.ok(is(+numString, ES.ToNumber(numString)), '"' + numString + '" coerces to ' + Number(numString));
|
||||
});
|
||||
forEach(v.objects, function (object) {
|
||||
t.ok(is(ES.ToNumber(object), ES.ToNumber(ES.ToPrimitive(object))), 'object ' + object + ' coerces to same as ToPrimitive of object does');
|
||||
});
|
||||
t['throws'](function () { return ES.ToNumber(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToInteger', function (t) {
|
||||
t.ok(is(0, ES.ToInteger(NaN)), 'NaN coerces to +0');
|
||||
forEach([0, Infinity, 42], function (num) {
|
||||
t.ok(is(num, ES.ToInteger(num)), num + ' returns itself');
|
||||
t.ok(is(-num, ES.ToInteger(-num)), '-' + num + ' returns itself');
|
||||
});
|
||||
t.equal(3, ES.ToInteger(Math.PI), 'pi returns 3');
|
||||
t['throws'](function () { return ES.ToInteger(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToInt32', function (t) {
|
||||
t.ok(is(0, ES.ToInt32(NaN)), 'NaN coerces to +0');
|
||||
forEach([0, Infinity], function (num) {
|
||||
t.ok(is(0, ES.ToInt32(num)), num + ' returns +0');
|
||||
t.ok(is(0, ES.ToInt32(-num)), '-' + num + ' returns +0');
|
||||
});
|
||||
t['throws'](function () { return ES.ToInt32(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.ok(is(ES.ToInt32(0x100000000), 0), '2^32 returns +0');
|
||||
t.ok(is(ES.ToInt32(0x100000000 - 1), -1), '2^32 - 1 returns -1');
|
||||
t.ok(is(ES.ToInt32(0x80000000), -0x80000000), '2^31 returns -2^31');
|
||||
t.ok(is(ES.ToInt32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1');
|
||||
forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) {
|
||||
t.ok(is(ES.ToInt32(num), ES.ToInt32(ES.ToUint32(num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for 0x' + num.toString(16));
|
||||
t.ok(is(ES.ToInt32(-num), ES.ToInt32(ES.ToUint32(-num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for -0x' + num.toString(16));
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToUint32', function (t) {
|
||||
t.ok(is(0, ES.ToUint32(NaN)), 'NaN coerces to +0');
|
||||
forEach([0, Infinity], function (num) {
|
||||
t.ok(is(0, ES.ToUint32(num)), num + ' returns +0');
|
||||
t.ok(is(0, ES.ToUint32(-num)), '-' + num + ' returns +0');
|
||||
});
|
||||
t['throws'](function () { return ES.ToUint32(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.ok(is(ES.ToUint32(0x100000000), 0), '2^32 returns +0');
|
||||
t.ok(is(ES.ToUint32(0x100000000 - 1), 0x100000000 - 1), '2^32 - 1 returns 2^32 - 1');
|
||||
t.ok(is(ES.ToUint32(0x80000000), 0x80000000), '2^31 returns 2^31');
|
||||
t.ok(is(ES.ToUint32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1');
|
||||
forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) {
|
||||
t.ok(is(ES.ToUint32(num), ES.ToUint32(ES.ToInt32(num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for 0x' + num.toString(16));
|
||||
t.ok(is(ES.ToUint32(-num), ES.ToUint32(ES.ToInt32(-num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for -0x' + num.toString(16));
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToUint16', function (t) {
|
||||
t.ok(is(0, ES.ToUint16(NaN)), 'NaN coerces to +0');
|
||||
forEach([0, Infinity], function (num) {
|
||||
t.ok(is(0, ES.ToUint16(num)), num + ' returns +0');
|
||||
t.ok(is(0, ES.ToUint16(-num)), '-' + num + ' returns +0');
|
||||
});
|
||||
t['throws'](function () { return ES.ToUint16(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.ok(is(ES.ToUint16(0x100000000), 0), '2^32 returns +0');
|
||||
t.ok(is(ES.ToUint16(0x100000000 - 1), 0x10000 - 1), '2^32 - 1 returns 2^16 - 1');
|
||||
t.ok(is(ES.ToUint16(0x80000000), 0), '2^31 returns +0');
|
||||
t.ok(is(ES.ToUint16(0x80000000 - 1), 0x10000 - 1), '2^31 - 1 returns 2^16 - 1');
|
||||
t.ok(is(ES.ToUint16(0x10000), 0), '2^16 returns +0');
|
||||
t.ok(is(ES.ToUint16(0x10000 - 1), 0x10000 - 1), '2^16 - 1 returns 2^16 - 1');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToString', function (t) {
|
||||
t['throws'](function () { return ES.ToString(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToObject', function (t) {
|
||||
t['throws'](function () { return ES.ToObject(undefined); }, TypeError, 'undefined throws');
|
||||
t['throws'](function () { return ES.ToObject(null); }, TypeError, 'null throws');
|
||||
forEach(v.numbers, function (number) {
|
||||
var obj = ES.ToObject(number);
|
||||
t.equal(typeof obj, 'object', 'number ' + number + ' coerces to object');
|
||||
t.equal(true, obj instanceof Number, 'object of ' + number + ' is Number object');
|
||||
t.ok(is(obj.valueOf(), number), 'object of ' + number + ' coerces to ' + number);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('CheckObjectCoercible', function (t) {
|
||||
t['throws'](function () { return ES.CheckObjectCoercible(undefined); }, TypeError, 'undefined throws');
|
||||
t['throws'](function () { return ES.CheckObjectCoercible(null); }, TypeError, 'null throws');
|
||||
var checkCoercible = function (value) {
|
||||
t.doesNotThrow(function () { return ES.CheckObjectCoercible(value); }, debug(value) + ' does not throw');
|
||||
};
|
||||
forEach(v.objects.concat(v.nonNullPrimitives), checkCoercible);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('IsCallable', function (t) {
|
||||
t.equal(true, ES.IsCallable(function () {}), 'function is callable');
|
||||
var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(v.primitives);
|
||||
forEach(nonCallables, function (nonCallable) {
|
||||
t.equal(false, ES.IsCallable(nonCallable), debug(nonCallable) + ' is not callable');
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('SameValue', function (t) {
|
||||
t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN');
|
||||
t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0');
|
||||
forEach(v.objects.concat(v.primitives), function (val) {
|
||||
t.equal(val === val, ES.SameValue(val, val), debug(val) + ' is SameValue to itself');
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Type', function (t) {
|
||||
t.equal(ES.Type(), 'Undefined', 'Type() is Undefined');
|
||||
t.equal(ES.Type(undefined), 'Undefined', 'Type(undefined) is Undefined');
|
||||
t.equal(ES.Type(null), 'Null', 'Type(null) is Null');
|
||||
t.equal(ES.Type(true), 'Boolean', 'Type(true) is Boolean');
|
||||
t.equal(ES.Type(false), 'Boolean', 'Type(false) is Boolean');
|
||||
t.equal(ES.Type(0), 'Number', 'Type(0) is Number');
|
||||
t.equal(ES.Type(NaN), 'Number', 'Type(NaN) is Number');
|
||||
t.equal(ES.Type('abc'), 'String', 'Type("abc") is String');
|
||||
t.equal(ES.Type(function () {}), 'Object', 'Type(function () {}) is Object');
|
||||
t.equal(ES.Type({}), 'Object', 'Type({}) is Object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('IsPropertyDescriptor', function (t) {
|
||||
forEach(v.primitives, function (primitive) {
|
||||
t.equal(ES.IsPropertyDescriptor(primitive), false, debug(primitive) + ' is not a Property Descriptor');
|
||||
});
|
||||
|
||||
t.equal(ES.IsPropertyDescriptor({ invalid: true }), false, 'invalid keys not allowed on a Property Descriptor');
|
||||
|
||||
t.equal(ES.IsPropertyDescriptor({}), true, 'empty object is an incomplete Property Descriptor');
|
||||
|
||||
t.equal(ES.IsPropertyDescriptor(v.accessorDescriptor()), true, 'accessor descriptor is a Property Descriptor');
|
||||
t.equal(ES.IsPropertyDescriptor(v.mutatorDescriptor()), true, 'mutator descriptor is a Property Descriptor');
|
||||
t.equal(ES.IsPropertyDescriptor(v.dataDescriptor()), true, 'data descriptor is a Property Descriptor');
|
||||
t.equal(ES.IsPropertyDescriptor(v.genericDescriptor()), true, 'generic descriptor is a Property Descriptor');
|
||||
|
||||
t['throws'](
|
||||
function () { ES.IsPropertyDescriptor(v.bothDescriptor()); },
|
||||
TypeError,
|
||||
'a Property Descriptor can not be both a Data and an Accessor Descriptor'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { ES.IsPropertyDescriptor(v.bothDescriptorWritable()); },
|
||||
TypeError,
|
||||
'a Property Descriptor can not be both a Data and an Accessor Descriptor'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('IsAccessorDescriptor', function (t) {
|
||||
forEach(v.nonNullPrimitives.concat(null), function (primitive) {
|
||||
t['throws'](function () { ES.IsAccessorDescriptor(primitive); }, TypeError, debug(primitive) + ' is not a Property Descriptor');
|
||||
});
|
||||
|
||||
t.equal(ES.IsAccessorDescriptor(), false, 'no value is not an Accessor Descriptor');
|
||||
t.equal(ES.IsAccessorDescriptor(undefined), false, 'undefined value is not an Accessor Descriptor');
|
||||
|
||||
t.equal(ES.IsAccessorDescriptor(v.accessorDescriptor()), true, 'accessor descriptor is an Accessor Descriptor');
|
||||
t.equal(ES.IsAccessorDescriptor(v.mutatorDescriptor()), true, 'mutator descriptor is an Accessor Descriptor');
|
||||
t.equal(ES.IsAccessorDescriptor(v.dataDescriptor()), false, 'data descriptor is not an Accessor Descriptor');
|
||||
t.equal(ES.IsAccessorDescriptor(v.genericDescriptor()), false, 'generic descriptor is not an Accessor Descriptor');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('IsDataDescriptor', function (t) {
|
||||
forEach(v.nonNullPrimitives.concat(null), function (primitive) {
|
||||
t['throws'](function () { ES.IsDataDescriptor(primitive); }, TypeError, debug(primitive) + ' is not a Property Descriptor');
|
||||
});
|
||||
|
||||
t.equal(ES.IsDataDescriptor(), false, 'no value is not a Data Descriptor');
|
||||
t.equal(ES.IsDataDescriptor(undefined), false, 'undefined value is not a Data Descriptor');
|
||||
|
||||
t.equal(ES.IsDataDescriptor(v.accessorDescriptor()), false, 'accessor descriptor is not a Data Descriptor');
|
||||
t.equal(ES.IsDataDescriptor(v.mutatorDescriptor()), false, 'mutator descriptor is not a Data Descriptor');
|
||||
t.equal(ES.IsDataDescriptor(v.dataDescriptor()), true, 'data descriptor is a Data Descriptor');
|
||||
t.equal(ES.IsDataDescriptor(v.genericDescriptor()), false, 'generic descriptor is not a Data Descriptor');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('IsGenericDescriptor', function (t) {
|
||||
forEach(v.nonNullPrimitives.concat(null), function (primitive) {
|
||||
t['throws'](
|
||||
function () { ES.IsGenericDescriptor(primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not a Property Descriptor'
|
||||
);
|
||||
});
|
||||
|
||||
t.equal(ES.IsGenericDescriptor(), false, 'no value is not a Data Descriptor');
|
||||
t.equal(ES.IsGenericDescriptor(undefined), false, 'undefined value is not a Data Descriptor');
|
||||
|
||||
t.equal(ES.IsGenericDescriptor(v.accessorDescriptor()), false, 'accessor descriptor is not a generic Descriptor');
|
||||
t.equal(ES.IsGenericDescriptor(v.mutatorDescriptor()), false, 'mutator descriptor is not a generic Descriptor');
|
||||
t.equal(ES.IsGenericDescriptor(v.dataDescriptor()), false, 'data descriptor is not a generic Descriptor');
|
||||
|
||||
t.equal(ES.IsGenericDescriptor(v.genericDescriptor()), true, 'generic descriptor is a generic Descriptor');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('FromPropertyDescriptor', function (t) {
|
||||
t.equal(ES.FromPropertyDescriptor(), undefined, 'no value begets undefined');
|
||||
t.equal(ES.FromPropertyDescriptor(undefined), undefined, 'undefined value begets undefined');
|
||||
|
||||
forEach(v.nonNullPrimitives.concat(null), function (primitive) {
|
||||
t['throws'](
|
||||
function () { ES.FromPropertyDescriptor(primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not a Property Descriptor'
|
||||
);
|
||||
});
|
||||
|
||||
var accessor = v.accessorDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(accessor), {
|
||||
get: accessor['[[Get]]'],
|
||||
set: accessor['[[Set]]'],
|
||||
enumerable: !!accessor['[[Enumerable]]'],
|
||||
configurable: !!accessor['[[Configurable]]']
|
||||
});
|
||||
|
||||
var mutator = v.mutatorDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(mutator), {
|
||||
get: mutator['[[Get]]'],
|
||||
set: mutator['[[Set]]'],
|
||||
enumerable: !!mutator['[[Enumerable]]'],
|
||||
configurable: !!mutator['[[Configurable]]']
|
||||
});
|
||||
var data = v.dataDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(data), {
|
||||
value: data['[[Value]]'],
|
||||
writable: data['[[Writable]]'],
|
||||
enumerable: !!data['[[Enumerable]]'],
|
||||
configurable: !!data['[[Configurable]]']
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
function () { ES.FromPropertyDescriptor(v.genericDescriptor()); },
|
||||
TypeError,
|
||||
'a complete Property Descriptor is required'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('ToPropertyDescriptor', function (t) {
|
||||
forEach(v.nonNullPrimitives.concat(null), function (primitive) {
|
||||
t['throws'](
|
||||
function () { ES.ToPropertyDescriptor(primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not an Object'
|
||||
);
|
||||
});
|
||||
|
||||
var accessor = v.accessorDescriptor();
|
||||
t.deepEqual(ES.ToPropertyDescriptor({
|
||||
get: accessor['[[Get]]'],
|
||||
enumerable: !!accessor['[[Enumerable]]'],
|
||||
configurable: !!accessor['[[Configurable]]']
|
||||
}), accessor);
|
||||
|
||||
var mutator = v.mutatorDescriptor();
|
||||
t.deepEqual(ES.ToPropertyDescriptor({
|
||||
set: mutator['[[Set]]'],
|
||||
enumerable: !!mutator['[[Enumerable]]'],
|
||||
configurable: !!mutator['[[Configurable]]']
|
||||
}), mutator);
|
||||
|
||||
var data = v.descriptors.nonConfigurable(v.dataDescriptor());
|
||||
t.deepEqual(ES.ToPropertyDescriptor({
|
||||
value: data['[[Value]]'],
|
||||
writable: data['[[Writable]]'],
|
||||
configurable: !!data['[[Configurable]]']
|
||||
}), data);
|
||||
|
||||
var both = v.bothDescriptor();
|
||||
t['throws'](
|
||||
function () {
|
||||
ES.ToPropertyDescriptor({ get: both['[[Get]]'], value: both['[[Value]]'] });
|
||||
},
|
||||
TypeError,
|
||||
'data and accessor descriptors are mutually exclusive'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { ES.ToPropertyDescriptor({ get: 'not callable' }); },
|
||||
TypeError,
|
||||
'"get" must be undefined or callable'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { ES.ToPropertyDescriptor({ set: 'not callable' }); },
|
||||
TypeError,
|
||||
'"set" must be undefined or callable'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Abstract Equality Comparison', function (t) {
|
||||
t.test('same types use ===', function (st) {
|
||||
forEach(v.primitives.concat(v.objects), function (value) {
|
||||
st.equal(ES['Abstract Equality Comparison'](value, value), value === value, debug(value) + ' is abstractly equal to itself');
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('different types coerce', function (st) {
|
||||
var pairs = [
|
||||
[null, undefined],
|
||||
[3, '3'],
|
||||
[true, '3'],
|
||||
[true, 3],
|
||||
[false, 0],
|
||||
[false, '0'],
|
||||
[3, [3]],
|
||||
['3', [3]],
|
||||
[true, [1]],
|
||||
[false, [0]],
|
||||
[String(v.coercibleObject), v.coercibleObject],
|
||||
[Number(String(v.coercibleObject)), v.coercibleObject],
|
||||
[Number(v.coercibleObject), v.coercibleObject],
|
||||
[String(Number(v.coercibleObject)), v.coercibleObject]
|
||||
];
|
||||
forEach(pairs, function (pair) {
|
||||
var a = pair[0];
|
||||
var b = pair[1];
|
||||
// eslint-disable-next-line eqeqeq
|
||||
st.equal(ES['Abstract Equality Comparison'](a, b), a == b, debug(a) + ' == ' + debug(b));
|
||||
// eslint-disable-next-line eqeqeq
|
||||
st.equal(ES['Abstract Equality Comparison'](b, a), b == a, debug(b) + ' == ' + debug(a));
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Strict Equality Comparison', function (t) {
|
||||
t.test('same types use ===', function (st) {
|
||||
forEach(v.primitives.concat(v.objects), function (value) {
|
||||
st.equal(ES['Strict Equality Comparison'](value, value), value === value, debug(value) + ' is strictly equal to itself');
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('different types are not ===', function (st) {
|
||||
var pairs = [
|
||||
[null, undefined],
|
||||
[3, '3'],
|
||||
[true, '3'],
|
||||
[true, 3],
|
||||
[false, 0],
|
||||
[false, '0'],
|
||||
[3, [3]],
|
||||
['3', [3]],
|
||||
[true, [1]],
|
||||
[false, [0]],
|
||||
[String(v.coercibleObject), v.coercibleObject],
|
||||
[Number(String(v.coercibleObject)), v.coercibleObject],
|
||||
[Number(v.coercibleObject), v.coercibleObject],
|
||||
[String(Number(v.coercibleObject)), v.coercibleObject]
|
||||
];
|
||||
forEach(pairs, function (pair) {
|
||||
var a = pair[0];
|
||||
var b = pair[1];
|
||||
st.equal(ES['Strict Equality Comparison'](a, b), a === b, debug(a) + ' === ' + debug(b));
|
||||
st.equal(ES['Strict Equality Comparison'](b, a), b === a, debug(b) + ' === ' + debug(a));
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Abstract Relational Comparison', function (t) {
|
||||
t.test('at least one operand is NaN', function (st) {
|
||||
st.equal(ES['Abstract Relational Comparison'](NaN, {}, true), undefined, 'LeftFirst: first is NaN, returns undefined');
|
||||
st.equal(ES['Abstract Relational Comparison']({}, NaN, true), undefined, 'LeftFirst: second is NaN, returns undefined');
|
||||
st.equal(ES['Abstract Relational Comparison'](NaN, {}, false), undefined, '!LeftFirst: first is NaN, returns undefined');
|
||||
st.equal(ES['Abstract Relational Comparison']({}, NaN, false), undefined, '!LeftFirst: second is NaN, returns undefined');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.equal(ES['Abstract Relational Comparison'](3, 4, true), true, 'LeftFirst: 3 is less than 4');
|
||||
t.equal(ES['Abstract Relational Comparison'](4, 3, true), false, 'LeftFirst: 3 is not less than 4');
|
||||
t.equal(ES['Abstract Relational Comparison'](3, 4, false), true, '!LeftFirst: 3 is less than 4');
|
||||
t.equal(ES['Abstract Relational Comparison'](4, 3, false), false, '!LeftFirst: 3 is not less than 4');
|
||||
|
||||
t.equal(ES['Abstract Relational Comparison']('3', '4', true), true, 'LeftFirst: "3" is less than "4"');
|
||||
t.equal(ES['Abstract Relational Comparison']('4', '3', true), false, 'LeftFirst: "3" is not less than "4"');
|
||||
t.equal(ES['Abstract Relational Comparison']('3', '4', false), true, '!LeftFirst: "3" is less than "4"');
|
||||
t.equal(ES['Abstract Relational Comparison']('4', '3', false), false, '!LeftFirst: "3" is not less than "4"');
|
||||
|
||||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, 42, true), true, 'LeftFirst: coercible object is less than 42');
|
||||
t.equal(ES['Abstract Relational Comparison'](42, v.coercibleObject, true), false, 'LeftFirst: 42 is not less than coercible object');
|
||||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, 42, false), true, '!LeftFirst: coercible object is less than 42');
|
||||
t.equal(ES['Abstract Relational Comparison'](42, v.coercibleObject, false), false, '!LeftFirst: 42 is not less than coercible object');
|
||||
|
||||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, '3', true), false, 'LeftFirst: coercible object is not less than "3"');
|
||||
t.equal(ES['Abstract Relational Comparison']('3', v.coercibleObject, true), false, 'LeftFirst: "3" is not less than coercible object');
|
||||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, '3', false), false, '!LeftFirst: coercible object is not less than "3"');
|
||||
t.equal(ES['Abstract Relational Comparison']('3', v.coercibleObject, false), false, '!LeftFirst: "3" is not less than coercible object');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('FromPropertyDescriptor', function (t) {
|
||||
t.equal(ES.FromPropertyDescriptor(), undefined, 'no value begets undefined');
|
||||
t.equal(ES.FromPropertyDescriptor(undefined), undefined, 'undefined value begets undefined');
|
||||
|
||||
forEach(v.nonUndefinedPrimitives, function (primitive) {
|
||||
t['throws'](
|
||||
function () { ES.FromPropertyDescriptor(primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not a Property Descriptor'
|
||||
);
|
||||
});
|
||||
|
||||
var accessor = v.accessorDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(accessor), {
|
||||
get: accessor['[[Get]]'],
|
||||
set: accessor['[[Set]]'],
|
||||
enumerable: !!accessor['[[Enumerable]]'],
|
||||
configurable: !!accessor['[[Configurable]]']
|
||||
});
|
||||
|
||||
var mutator = v.mutatorDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(mutator), {
|
||||
get: mutator['[[Get]]'],
|
||||
set: mutator['[[Set]]'],
|
||||
enumerable: !!mutator['[[Enumerable]]'],
|
||||
configurable: !!mutator['[[Configurable]]']
|
||||
});
|
||||
var data = v.dataDescriptor();
|
||||
t.deepEqual(ES.FromPropertyDescriptor(data), {
|
||||
value: data['[[Value]]'],
|
||||
writable: data['[[Writable]]'],
|
||||
enumerable: !!data['[[Enumerable]]'],
|
||||
configurable: !!data['[[Configurable]]']
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
function () { ES.FromPropertyDescriptor(v.genericDescriptor()); },
|
||||
TypeError,
|
||||
'a complete Property Descriptor is required'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
18
node_modules/es-abstract/test/es6.js
generated
vendored
Normal file
18
node_modules/es-abstract/test/es6.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var ES = require('../');
|
||||
var ES6 = ES.ES6;
|
||||
var ES2015 = ES.ES2015;
|
||||
var ES6entry = require('../es6');
|
||||
|
||||
test('legacy es6 export', function (t) {
|
||||
t.equal(ES6, ES2015, 'main ES6 === main ES2015');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('legacy es6 entry point', function (t) {
|
||||
t.equal(ES6, ES6entry, 'main ES6 === ES6 entry point');
|
||||
t.end();
|
||||
});
|
18
node_modules/es-abstract/test/es7.js
generated
vendored
Normal file
18
node_modules/es-abstract/test/es7.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var ES = require('../');
|
||||
var ES7 = ES.ES7;
|
||||
var ES2016 = ES.ES2016;
|
||||
var ES7entry = require('../es7');
|
||||
|
||||
test('legacy es7 export', function (t) {
|
||||
t.equal(ES7, ES2016, 'main ES7 === main ES2016');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('legacy es7 entry point', function (t) {
|
||||
t.equal(ES7, ES7entry, 'main ES7 === ES7 entry point');
|
||||
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, record, 'arg', primitive); },
|
||||
TypeError,
|
||||
debug(primitive) + ' is not a Property Descriptor'
|
||||
);
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
function () { assertRecord(ES, record, 'arg', { invalid: true }); },
|
||||
TypeError,
|
||||
'invalid keys not allowed on a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES, record, 'arg', {}); },
|
||||
'empty object is an incomplete Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES, record, 'arg', v.accessorDescriptor()); },
|
||||
'accessor descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES, record, 'arg', v.mutatorDescriptor()); },
|
||||
'mutator descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES, record, 'arg', v.dataDescriptor()); },
|
||||
'data descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t.doesNotThrow(
|
||||
function () { assertRecord(ES, record, 'arg', v.genericDescriptor()); },
|
||||
'generic descriptor is a Property Descriptor'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { assertRecord(ES, record, 'arg', v.bothDescriptor()); },
|
||||
TypeError,
|
||||
'a Property Descriptor can not be both a Data and an Accessor Descriptor'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
};
|
117
node_modules/es-abstract/test/helpers/values.js
generated
vendored
Normal file
117
node_modules/es-abstract/test/helpers/values.js
generated
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
'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 numbers = [0, -0, Infinity, -Infinity, 42].concat(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,
|
||||
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
|
||||
};
|
30
node_modules/es-abstract/test/index.js
generated
vendored
Normal file
30
node_modules/es-abstract/test/index.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
var ES = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
var ESkeys = Object.keys(ES).sort();
|
||||
var ES6keys = Object.keys(ES.ES6).sort();
|
||||
|
||||
test('exposed properties', function (t) {
|
||||
t.deepEqual(ESkeys, ES6keys.concat(['ES2019', 'ES2018', 'ES2017', 'ES7', 'ES2016', 'ES6', 'ES2015', 'ES5']).sort(), 'main ES object keys match ES6 keys');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('methods match', function (t) {
|
||||
ES6keys.forEach(function (key) {
|
||||
t.equal(ES.ES6[key], ES[key], 'method ' + key + ' on main ES object is ES6 method');
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
require('./GetIntrinsic');
|
||||
|
||||
require('./es5');
|
||||
require('./es6');
|
||||
require('./es2015');
|
||||
require('./es7');
|
||||
require('./es2016');
|
||||
require('./es2017');
|
||||
require('./es2018');
|
||||
require('./es2019');
|
3584
node_modules/es-abstract/test/tests.js
generated
vendored
Normal file
3584
node_modules/es-abstract/test/tests.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue