index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. var test = require('tape');
  3. var debug = require('object-inspect');
  4. var forEach = require('for-each');
  5. var isSet = require('..');
  6. test('non-collections', function (t) {
  7. forEach([
  8. null,
  9. undefined,
  10. true,
  11. false,
  12. 42,
  13. 0,
  14. -0,
  15. NaN,
  16. Infinity,
  17. '',
  18. 'foo',
  19. /a/g,
  20. [],
  21. {},
  22. function () {}
  23. ], function (nonCollection) {
  24. t.equal(isSet(nonCollection), false, debug(nonCollection) + ' is not a Set');
  25. });
  26. t.end();
  27. });
  28. test('Maps', { skip: typeof Map !== 'function' }, function (t) {
  29. var m = new Map();
  30. t.equal(isSet(m), false, debug(m) + ' is not a Set');
  31. t.end();
  32. });
  33. test('Sets', { skip: typeof Set !== 'function' }, function (t) {
  34. var s = new Set();
  35. t.equal(isSet(s), true, debug(s) + ' is a Set');
  36. t.end();
  37. });
  38. test('WeakMaps', { skip: typeof WeakMap !== 'function' }, function (t) {
  39. var wm = new WeakMap();
  40. t.equal(isSet(wm), false, debug(wm) + ' is not a Set');
  41. t.end();
  42. });
  43. test('WeakSets', { skip: typeof WeakSet !== 'function' }, function (t) {
  44. var ws = new WeakSet();
  45. t.equal(isSet(ws), false, debug(ws) + ' is not a Set');
  46. t.end();
  47. });