Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('native', function (t) {
t.equal(Object.assign.length, 2, 'Object.assign has a length of 2');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Object.assign.name, 'assign', 'Object.assign has name "assign"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Object, 'assign'), 'Object.assign is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return Object.assign(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Object.assign(null); }, TypeError, 'null is not an object');
st.end();
});
// v8 in node 0.8 and 0.10 have non-enumerable string properties
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
/*
test('shimmed', function (t) {
t.equal(Object.assign.length, 2, 'Object.assign has a length of 2');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Object.assign.name, 'assign', 'Object.assign has name "assign"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Object, 'assign'), 'Object.assign is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return Object.assign(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Object.assign(null); }, TypeError, 'null is not an object');
st.end();
});
// v8 in node 0.8 and 0.10 have non-enumerable string properties
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
/*
'use strict';
/* eslint-disable no-invalid-this */
var test = require('tape');
var ES = require('es-abstract/es6');
var supportsDescriptors = require('define-properties').supportsDescriptors;
var makeIterator = function (array) {
var nextIndex = 0;
var value;
return {
'next': function () {
if (nextIndex < array.length) {
value = array[nextIndex];
nextIndex = nextIndex + 1;
return {
'done': false,
'value': value
};
} else {
return {
'done': true,
test('shimmed', function (t) {
t.equal(String.prototype.padStart.length, 1, 'String#padStart has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(String.prototype.padStart.name, 'padStart', 'String#padStart has name "padStart"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(String.prototype, 'padStart'), 'String#padStart is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad string/this value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return padStart(undefined, 'a'); }, TypeError, 'undefined is not an object');
st['throws'](function () { return padStart(null, 'a'); }, TypeError, 'null is not an object');
st.end();
});
runTests(bind.call(Function.call, String.prototype.padStart), t);
t.end();
});
test('shimmed', function (t) {
t.equal(Object.values.length, 1, 'Object.values has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Object.values.name, 'values', 'Object.values has name "values"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Object, 'values'), 'Object.values is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return Object.values(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Object.values(null); }, TypeError, 'null is not an object');
st.end();
});
runTests(Object.values, t);
t.end();
});
'use strict';
var assert = require('assert');
var has = require('has');
var wrap = require('../..');
var thunk = function (v) { return function () { return v; }; };
var supportsDescriptors = require('define-properties').supportsDescriptors;
describe('withOverrides plugin', function () {
var obj = {};
before(function () {
obj.foo = 'before foo';
obj.bar = 'before bar';
obj.baz = -1;
obj.quux = 'quux';
});
it('has properties set to initial values', function () {
assert.deepEqual(obj, { foo: 'before foo', bar: 'before bar', baz: -1, quux: 'quux' });
});
wrap().withOverrides(thunk(obj), thunk({ foo: 'after foo' }))
.it('foo is "after foo"', function () {
test('shimmed', function (t) {
t.equal(String.prototype.padEnd.length, 1, 'String#padEnd has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(String.prototype.padEnd.name, 'padEnd', 'String#padEnd has name "padEnd"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(String.prototype, 'padEnd'), 'String#padEnd is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad string/this value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return padEnd(undefined, 'a'); }, TypeError, 'undefined is not an object');
st['throws'](function () { return padEnd(null, 'a'); }, TypeError, 'null is not an object');
st.end();
});
runTests(bind.call(Function.call, String.prototype.padEnd), t);
t.end();
});
test('shimmed', function (t) {
t.equal(String.prototype.trimLeft.length, 0, 'String#trimLeft has a length of 0');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal((/^(?:trimLeft|trimStart)$/).test(String.prototype.trimLeft.name), true, 'String#trimLeft has name "trimLeft" or "trimStart"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(String.prototype, 'trimLeft'), 'String#trimLeft is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad string/this value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return trimLeft(undefined, 'a'); }, TypeError, 'undefined is not an object');
st['throws'](function () { return trimLeft(null, 'a'); }, TypeError, 'null is not an object');
st.end();
});
runTests(bind.call(Function.call, String.prototype.trimLeft), t);
t.end();
});
st.deepEqual(values(f), [b], 'only own properties are included');
st.end();
});
t.test('Symbol properties are omitted', { skip: !hasSymbols }, function (st) {
var object = { a: a, b: b, c: c };
var enumSym = Symbol('enum');
var nonEnumSym = Symbol('non enum');
object[enumSym] = enumSym;
object.d = enumSym;
Object.defineProperty(object, nonEnumSym, { enumerable: false, value: nonEnumSym });
st.deepEqual(values(object), [a, b, c, enumSym], 'symbol properties are omitted');
st.end();
});
t.test('not-yet-visited keys deleted on [[Get]] must not show up in output', { skip: !define.supportsDescriptors }, function (st) {
var o = { a: 1, b: 2, c: 3 };
Object.defineProperty(o, 'a', {
get: function () {
delete this.b;
return 1;
}
});
st.deepEqual(values(o), [1, 3], 'when "b" is deleted prior to being visited, it should not show up');
st.end();
});
t.test('not-yet-visited keys made non-enumerable on [[Get]] must not show up in output', { skip: !define.supportsDescriptors }, function (st) {
var o = { a: 'A', b: 'B' };
Object.defineProperty(o, 'a', {
get: function () {
Object.defineProperty(o, 'b', { enumerable: false });
'use strict';
var supportsDescriptors = require('define-properties').supportsDescriptors;
var getPolyfill = require('./polyfill');
var gOPD = Object.getOwnPropertyDescriptor;
var defineProperty = Object.defineProperty;
var TypeErr = TypeError;
var getProto = Object.getPrototypeOf;
var regex = /a/;
module.exports = function shimFlags() {
if (!supportsDescriptors || !getProto) {
throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
}
var polyfill = getPolyfill();
var proto = getProto(regex);
var descriptor = gOPD(proto, 'flags');
if (!descriptor || descriptor.get !== polyfill) {
defineProperty(proto, 'flags', {