6a70addb42a809a0e559a8fd3dbb315a5f42b0914f44120eabd2d7c979fd90e100ee84c9a8bf1d2cbc3fa53d95390f64f0684d1ca332750d261e20f3971967 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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 runTests = require('./tests');
  9. test('shimmed', function (t) {
  10. t.equal(String.prototype.trim.length, 0, 'String#trim has a length of 0');
  11. t.test('Function name', { skip: !functionsHaveNames }, function (st) {
  12. st.equal(String.prototype.trim.name, 'trim', 'String#trim has name "trim"');
  13. st.end();
  14. });
  15. t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
  16. et.equal(false, isEnumerable.call(String.prototype, 'trim'), 'String#trim is not enumerable');
  17. et.end();
  18. });
  19. var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
  20. t.test('bad string/this value', { skip: !supportsStrictMode }, function (st) {
  21. st['throws'](function () { return String.prototype.trim.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
  22. st['throws'](function () { return String.prototype.trim.call(null, 'a'); }, TypeError, 'null is not an object');
  23. st.end();
  24. });
  25. runTests(callBind(String.prototype.trim), t);
  26. t.end();
  27. });