index.js 696 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var test = require('tape');
  3. var inspect = require('object-inspect');
  4. var forEach = require('for-each');
  5. var isWeakRef = require('..');
  6. test('isWeakRef', function (t) {
  7. t.equal(typeof isWeakRef, 'function', 'is a function');
  8. var nonWeakRefs = [undefined, null, true, false, 42, 0, Infinity, NaN, /a/g, function () {}, {}, []];
  9. forEach(nonWeakRefs, function (nonWeakRef) {
  10. t.equal(isWeakRef(nonWeakRef), false, inspect(nonWeakRef) + ' is not a WeakRef');
  11. });
  12. t.test('actual WeakRefs', { skip: typeof WeakRef === 'undefined' }, function (st) {
  13. var ref = new WeakRef({});
  14. st.equal(isWeakRef(ref), true, inspect(ref) + ' is a WeakRef');
  15. st.end();
  16. });
  17. t.end();
  18. });