10685196b75c7091db01fed08703b524b997bf023ef589fb9b20f31d001618671bd6dfd6c328cd36d7dae5755650c0a4ab0717185fff61640ea2aaa52b6a97 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. require('../auto');
  3. var test = require('tape');
  4. var defineProperties = require('define-properties');
  5. var callBind = require('call-bind');
  6. var isEnumerable = Object.prototype.propertyIsEnumerable;
  7. var functionsHaveNames = require('functions-have-names')();
  8. var hasStrictMode = require('has-strict-mode')();
  9. var getProto = require('get-proto');
  10. var runTests = require('./tests');
  11. test('shimmed', function (t) {
  12. t.test('Typed Array support', { skip: typeof Uint8Array === 'undefined' }, function (st) {
  13. var proto = getProto(Uint8Array.prototype);
  14. var method = proto.slice;
  15. st.equal(method.length, 2, 'TypedArray#slice has a length of 2');
  16. st.test('Function name', { skip: !functionsHaveNames }, function (s2t) {
  17. s2t.equal(method.name, 'slice', 'TypedArray#slice name "slice"');
  18. s2t.end();
  19. });
  20. st.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
  21. et.equal(false, isEnumerable.call(proto, 'slice'), 'TypedArray#slice is not enumerable');
  22. et.end();
  23. });
  24. st.test('bad array/this value', { skip: !hasStrictMode }, function (s2t) {
  25. /* eslint no-useless-call: 0 */
  26. s2t['throws'](function () { return method.call(undefined); }, TypeError, 'undefined is not an object');
  27. s2t['throws'](function () { return method.call(null); }, TypeError, 'null is not an object');
  28. s2t.end();
  29. });
  30. t.test('has the correct descriptor', { skip: !Object.getOwnPropertyDescriptor }, function (s2t) {
  31. var descriptor = Object.getOwnPropertyDescriptor(proto, 'slice');
  32. s2t.equal(descriptor.configurable, true);
  33. s2t.equal(descriptor.enumerable, false);
  34. s2t.equal(typeof descriptor.value, 'function');
  35. s2t.equal(descriptor.writable, true);
  36. s2t.end();
  37. });
  38. runTests(callBind(method), st);
  39. st.end();
  40. });
  41. t.end();
  42. });