e5cb0c70a2b9bb3d176d07fbb64596cd49411fea51543bf82a0875d3399afc6cbf86ffb3007b67825a0cd1f93118fd56e012707548263a421d19dcfb18f127 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. require('../auto');
  2. var test = require('tape');
  3. var defineProperties = require('define-properties');
  4. var callBind = require('call-bind');
  5. var isEnumerable = Object.prototype.propertyIsEnumerable;
  6. var functionsHaveNames = require('functions-have-names')();
  7. var runTests = require('./tests');
  8. test('shimmed', function (t) {
  9. t.equal(Array.prototype.reduce.length, 1, 'Array#reduce has a length of 1');
  10. t.test('Function name', { skip: !functionsHaveNames }, function (st) {
  11. st.equal(Array.prototype.reduce.name, 'reduce', 'Array#reduce has name "reduce"');
  12. st.end();
  13. });
  14. t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
  15. et.equal(false, isEnumerable.call(Array.prototype, 'reduce'), 'Array#reduce is not enumerable');
  16. et.end();
  17. });
  18. var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
  19. t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
  20. st['throws'](function () { return Array.prototype.reduce.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
  21. st['throws'](function () { return Array.prototype.reduce.call(null, 'a'); }, TypeError, 'null is not an object');
  22. st.end();
  23. });
  24. runTests(callBind(Array.prototype.reduce), t);
  25. t.end();
  26. });