validate-array-like-object.js 581 B

123456789101112131415
  1. 'use strict';
  2. module.exports = function (t, a) {
  3. var x;
  4. a.throws(function () { t(0); }, TypeError, "0");
  5. a.throws(function () { t(false); }, TypeError, "false");
  6. a.throws(function () { t(''); }, TypeError, "String");
  7. a.throws(function () { t({}); }, TypeError, "Plain Object");
  8. a.throws(function () { t(function () {}); }, TypeError, "Function");
  9. a(t(x = new String('raz')), x, "String object"); //jslint: ignore
  10. a(t(x = { length: 1 }), x, "Array like");
  11. a.throws(function () { t(); }, TypeError, "Undefined");
  12. a.throws(function () { t(null); }, TypeError, "null");
  13. };