Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
QUnit.test('Reflect.hasOwnMetadata', assert => {
assert.isFunction(hasOwnMetadata);
assert.arity(hasOwnMetadata, 2);
assert.throws(() => hasOwnMetadata('key', undefined, undefined), TypeError);
assert.same(hasOwnMetadata('key', {}, undefined), false);
let object = {};
defineMetadata('key', 'value', object, undefined);
assert.same(hasOwnMetadata('key', object, undefined), true);
let prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, undefined);
assert.same(hasOwnMetadata('key', object, undefined), false);
assert.same(hasOwnMetadata('key', {}, 'name'), false);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.same(hasOwnMetadata('key', object, 'name'), true);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.same(hasOwnMetadata('key', object, 'name'), false);
});
QUnit.test('Reflect.deleteMetadata', assert => {
assert.isFunction(deleteMetadata);
assert.arity(deleteMetadata, 2);
assert.throws(() => deleteMetadata('key', undefined, undefined), TypeError);
assert.same(deleteMetadata('key', {}, undefined), false);
let object = {};
defineMetadata('key', 'value', object, undefined);
assert.same(deleteMetadata('key', object, undefined), true);
const prototype = {};
defineMetadata('key', 'value', prototype, undefined);
assert.same(deleteMetadata('key', create(prototype), undefined), false);
object = {};
defineMetadata('key', 'value', object, undefined);
deleteMetadata('key', object, undefined);
assert.same(hasOwnMetadata('key', object, undefined), false);
});
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), []);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
});
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
object = {};
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
defineMetadata('key0', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, undefined);
object = create(prototype);
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
object = {};
assert.deepEqual(getOwnMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), []);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
assert.throws(() => hasMetadata('key', undefined, undefined), TypeError);
assert.same(hasMetadata('key', {}, undefined), false);
let object = {};
defineMetadata('key', 'value', object, undefined);
assert.same(hasMetadata('key', object, undefined), true);
let prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, undefined);
assert.same(hasMetadata('key', object, undefined), true);
assert.same(hasMetadata('key', {}, 'name'), false);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.same(hasMetadata('key', object, 'name'), true);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.same(hasMetadata('key', object, 'name'), true);
});
defineMetadata('key0', 'value', object, undefined);
assert.deepEqual(getMetadataKeys(object, undefined), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, undefined);
object = create(prototype);
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getMetadataKeys(object, undefined), ['key0', 'key1', 'key2']);
object = {};
assert.deepEqual(getMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1', 'key2']);
});
object = {};
assert.deepEqual(getMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1', 'key2']);
});
object = create(prototype);
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
object = {};
assert.deepEqual(getOwnMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), []);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key0', 'key1']);
});
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getMetadataKeys(object, undefined), ['key0', 'key1', 'key2']);
object = {};
assert.deepEqual(getMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key']);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
defineMetadata('key0', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, 'name');
object = create(prototype);
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');
assert.deepEqual(getMetadataKeys(object, 'name'), ['key0', 'key1', 'key2']);
});
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key']);
let prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), []);
object = {};
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
object = {};
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
defineMetadata('key0', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
prototype = {};
defineMetadata('key2', 'value', prototype, undefined);
object = create(prototype);
defineMetadata('key0', 'value', object, undefined);
defineMetadata('key1', 'value', object, undefined);
assert.deepEqual(getOwnMetadataKeys(object, undefined), ['key0', 'key1']);
object = {};
assert.deepEqual(getOwnMetadataKeys({}, 'name'), []);
object = {};
defineMetadata('key', 'value', object, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), ['key']);
prototype = {};
object = create(prototype);
defineMetadata('key', 'value', prototype, 'name');
assert.deepEqual(getOwnMetadataKeys(object, 'name'), []);
object = {};
defineMetadata('key0', 'value', object, 'name');
defineMetadata('key1', 'value', object, 'name');