Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. // 36: Symbol.keyFor - retrieves a shared symbol key from the global symbol registry
  2. // To do: make all tests pass, leave the assert lines unchanged!
  3. // Follow the hints of the failure messages!
  4.  
  5. describe('`Symbol.keyFor()` gets the symbol key for a given symbol', function() {
  6. it('pass the symbol to `keyFor()` and you get its key', function() {
  7. const key = Symbol.keyFor(Symbol.for('foo'));
  8. assert.equal(key, 'foo');
  9. });
  10. it('local symbols are not in the runtime-wide registry', function() {
  11. // Hint: `Symbol()` creates a local symbol!
  12. const localSymbol = Symbol('foo');
  13. const key = Symbol.keyFor(localSymbol);
  14. assert.equal(key, void 0);
  15. });
  16. it('predefined symbols are not in the runtime-wide registry either', function() {
  17. const key = Symbol.keyFor(Symbol.iterator);
  18. assert.equal(key, void 0);
  19. });
  20. it('for non-Symbols throws an error', function() {
  21. function fn() {
  22. Symbol.keyFor(Symbol.for(sym));
  23. }
  24. assert.throws(fn);
  25. });
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement