Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

getSymbolDescription.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. var test = require('tape');
  3. var debug = require('object-inspect');
  4. var forEach = require('foreach');
  5. var v = require('./values');
  6. var getSymbolDescription = require('../../helpers/getSymbolDescription');
  7. test('getSymbolDescription', function (t) {
  8. t.test('no symbols', { skip: v.hasSymbols }, function (st) {
  9. st['throws'](
  10. getSymbolDescription,
  11. SyntaxError,
  12. 'requires Symbol support'
  13. );
  14. st.end();
  15. });
  16. forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) {
  17. t['throws'](
  18. function () { getSymbolDescription(nonSymbol); },
  19. TypeError,
  20. debug(nonSymbol) + ' is not a Symbol'
  21. );
  22. });
  23. t.test('with symbols', { skip: !v.hasSymbols }, function (st) {
  24. forEach(
  25. [
  26. [Symbol(), undefined],
  27. [Symbol(undefined), undefined],
  28. [Symbol(null), 'null'],
  29. [Symbol(''), ''],
  30. [Symbol.iterator, 'Symbol.iterator'],
  31. [Symbol('foo'), 'foo']
  32. ],
  33. function (pair) {
  34. var sym = pair[0];
  35. var desc = pair[1];
  36. st.equal(getSymbolDescription(sym), desc, debug(sym) + ' yields ' + debug(desc));
  37. }
  38. );
  39. st.end();
  40. });
  41. t.end();
  42. });