You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

4 years ago
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var test = require('tape');
  4. var forEach = require('foreach');
  5. var debug = require('object-inspect');
  6. var v = require('./helpers/values');
  7. test('export', function (t) {
  8. t.equal(typeof GetIntrinsic, 'function', 'it is a function');
  9. t.equal(GetIntrinsic.length, 2, 'function has length of 2');
  10. t.end();
  11. });
  12. test('throws', function (t) {
  13. t['throws'](
  14. function () { GetIntrinsic('not an intrinsic'); },
  15. SyntaxError,
  16. 'nonexistent intrinsic throws a syntax error'
  17. );
  18. forEach(v.nonBooleans, function (nonBoolean) {
  19. t['throws'](
  20. function () { GetIntrinsic('%', nonBoolean); },
  21. TypeError,
  22. debug(nonBoolean) + ' is not a Boolean'
  23. );
  24. });
  25. t.end();
  26. });
  27. test('base intrinsics', function (t) {
  28. t.equal(GetIntrinsic('%Object%'), Object, '%Object% yields Object');
  29. t.equal(GetIntrinsic('%Array%'), Array, '%Array% yields Array');
  30. t.end();
  31. });
  32. test('dotted paths', function (t) {
  33. t.equal(GetIntrinsic('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% yields Object.prototype.toString');
  34. t.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push, '%Array.prototype.push% yields Array.prototype.push');
  35. t.end();
  36. });