is 0.2.3 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +30 -28
  2. package/package.json +4 -4
  3. package/test/index.js +288 -276
package/index.js CHANGED
@@ -7,11 +7,11 @@
7
7
  * @license MIT
8
8
  */
9
9
 
10
- var object = {};
11
- var owns = object.hasOwnProperty;
12
- var toString = object.toString;
10
+ var objProto = Object.prototype;
11
+ var owns = objProto.hasOwnProperty;
12
+ var toString = objProto.toString;
13
13
  var isActualNaN = function (value) {
14
- return is.number(value) && value !== value;
14
+ return value !== value;
15
15
  };
16
16
  var NON_HOST_TYPES = {
17
17
  "boolean": 1,
@@ -205,7 +205,9 @@ is.undefined = function (value) {
205
205
  */
206
206
 
207
207
  is.arguments = function (value) {
208
- return '[object Arguments]' === toString.call(value);
208
+ var isStandardArguments = '[object Arguments]' === toString.call(value);
209
+ var isOldArguments = !is.array(value) && is.arraylike(value) && is.object(value) && is.fn(value.callee);
210
+ return isStandardArguments || isOldArguments;
209
211
  };
210
212
 
211
213
  /**
@@ -343,7 +345,6 @@ is.element = function (value) {
343
345
  return value !== undefined
344
346
  && typeof HTMLElement !== 'undefined'
345
347
  && value instanceof HTMLElement
346
- && owns.call(value, 'nodeType')
347
348
  && value.nodeType === 1;
348
349
  };
349
350
 
@@ -377,8 +378,9 @@ is.error = function (value) {
377
378
  * @api public
378
379
  */
379
380
 
380
- is.fn = is['function'] = function(value) {
381
- return '[object Function]' === toString.call(value);
381
+ is.fn = is['function'] = function (value) {
382
+ var isAlert = typeof window !== 'undefined' && value === window.alert;
383
+ return isAlert || '[object Function]' === toString.call(value);
382
384
  };
383
385
 
384
386
  /**
@@ -420,7 +422,7 @@ is.infinite = function (value) {
420
422
  */
421
423
 
422
424
  is.decimal = function (value) {
423
- return is.number(value) && !isActualNaN(value) && value % 1 !== 0;
425
+ return is.number(value) && !isActualNaN(value) && !is.infinite(value) && value % 1 !== 0;
424
426
  };
425
427
 
426
428
  /**
@@ -558,7 +560,7 @@ is.odd = function (value) {
558
560
 
559
561
  is.ge = function (value, other) {
560
562
  if (isActualNaN(value) || isActualNaN(other)) {
561
- throw new TypeError('NaN is not a value value');
563
+ throw new TypeError('NaN is not a valid value');
562
564
  }
563
565
  return !is.infinite(value) && !is.infinite(other) && value >= other;
564
566
  };
@@ -575,7 +577,7 @@ is.ge = function (value, other) {
575
577
 
576
578
  is.gt = function (value, other) {
577
579
  if (isActualNaN(value) || isActualNaN(other)) {
578
- throw new TypeError('NaN is not a value value');
580
+ throw new TypeError('NaN is not a valid value');
579
581
  }
580
582
  return !is.infinite(value) && !is.infinite(other) && value > other;
581
583
  };
@@ -592,7 +594,7 @@ is.gt = function (value, other) {
592
594
 
593
595
  is.le = function (value, other) {
594
596
  if (isActualNaN(value) || isActualNaN(other)) {
595
- throw new TypeError('NaN is not a value value');
597
+ throw new TypeError('NaN is not a valid value');
596
598
  }
597
599
  return !is.infinite(value) && !is.infinite(other) && value <= other;
598
600
  };
@@ -609,7 +611,7 @@ is.le = function (value, other) {
609
611
 
610
612
  is.lt = function (value, other) {
611
613
  if (isActualNaN(value) || isActualNaN(other)) {
612
- throw new TypeError('NaN is not a value value');
614
+ throw new TypeError('NaN is not a valid value');
613
615
  }
614
616
  return !is.infinite(value) && !is.infinite(other) && value < other;
615
617
  };
@@ -626,7 +628,7 @@ is.lt = function (value, other) {
626
628
  */
627
629
  is.within = function (value, start, finish) {
628
630
  if (isActualNaN(value) || isActualNaN(start) || isActualNaN(finish)) {
629
- throw new TypeError('NaN is not a value value');
631
+ throw new TypeError('NaN is not a valid value');
630
632
  } else if (!is.number(value) || !is.number(start) || !is.number(finish)) {
631
633
  throw new TypeError('all arguments must be numbers');
632
634
  }
@@ -648,7 +650,20 @@ is.within = function (value, start, finish) {
648
650
  */
649
651
 
650
652
  is.object = function (value) {
651
- return '[object Object]' === toString.call(value);
653
+ return value && '[object Object]' === toString.call(value);
654
+ };
655
+
656
+ /**
657
+ * is.hash
658
+ * Test if `value` is a hash - a plain object literal.
659
+ *
660
+ * @param {Mixed} value value to test
661
+ * @return {Boolean} true if `value` is a hash, false otherwise
662
+ * @api public
663
+ */
664
+
665
+ is.hash = function (value) {
666
+ return is.object(value) && value.constructor === Object && !value.nodeType && !value.setInterval;
652
667
  };
653
668
 
654
669
  /**
@@ -685,16 +700,3 @@ is.string = function (value) {
685
700
  return '[object String]' === toString.call(value);
686
701
  };
687
702
 
688
- /**
689
- * is.hash
690
- * Test if `value` is a plain object, ie a hash.
691
- *
692
- * @param {Mixed} value value to test
693
- * @return {Boolean} true if `value` is a hash, false otherwise
694
- * @api public
695
- */
696
-
697
- is.hash = function (value) {
698
- return is.object(value) && value.constructor === Object && !value.nodeType && !value.setInterval;
699
- };
700
-
package/package.json CHANGED
@@ -23,16 +23,16 @@
23
23
  "url": "git://github.com/enricomarino/is.git"
24
24
  },
25
25
  "main": "index.js",
26
- "version": "0.2.3",
26
+ "version": "0.2.7",
27
27
  "scripts": {
28
28
  "test": "node test/index.js"
29
29
  },
30
30
  "devDependencies": {
31
- "tape": "~0.3.3",
32
- "foreach": "~2.0.2"
31
+ "tape": "~2.3.2",
32
+ "foreach": "~2.0.4"
33
33
  },
34
34
  "testling": {
35
- "files": "test.js",
35
+ "files": "test/index.js",
36
36
  "browsers": [
37
37
  "iexplore/6.0..latest",
38
38
  "firefox/3.0",
package/test/index.js CHANGED
@@ -2,469 +2,481 @@ var test = require('tape');
2
2
  var is = require('../index.js');
3
3
 
4
4
  var forEach = require('foreach');
5
+ var now = Date.now || function () { return +new Date(); };
5
6
 
6
7
  test('is.type', function (t) {
7
8
  var booleans = [true, false];
8
9
  forEach(booleans, function (boolean) {
9
- t.true(is.type(boolean, 'boolean'), '"' + boolean + '" is a boolean');
10
+ t.ok(is.type(boolean, 'boolean'), '"' + boolean + '" is a boolean');
10
11
  });
11
12
 
12
13
  var numbers = [1, 0 / 1, 0 / -1, NaN, Infinity, -Infinity];
13
14
  forEach(numbers, function (number) {
14
- t.true(is.type(number, 'number'), '"' + number + '" is a number');
15
+ t.ok(is.type(number, 'number'), '"' + number + '" is a number');
15
16
  });
16
17
 
17
18
  var objects = [{}, null, new Date()];
18
19
  forEach(objects, function (object) {
19
- t.true(is.type(object, 'object'), '"' + object + '" is an object');
20
+ t.ok(is.type(object, 'object'), '"' + object + '" is an object');
20
21
  });
21
22
 
22
23
  var strings = ['', 'abc'];
23
24
  forEach(strings, function (string) {
24
- t.true(is.type(string, 'string'), '"' + string + '" is a string');
25
+ t.ok(is.type(string, 'string'), '"' + string + '" is a string');
25
26
  });
26
27
 
27
- t.true(is.type(undefined, 'undefined'), 'undefined is undefined');
28
+ t.ok(is.type(undefined, 'undefined'), 'undefined is undefined');
28
29
 
29
30
  t.end();
30
31
  });
31
32
 
32
33
  test('is.undefined', function (t) {
33
- t.true(is.undefined(), 'undefined is undefined');
34
- t.false(is.undefined(null), 'null is not undefined');
35
- t.false(is.undefined({}), 'object is not undefined');
34
+ t.ok(is.undefined(), 'undefined is undefined');
35
+ t.notOk(is.undefined(null), 'null is not undefined');
36
+ t.notOk(is.undefined({}), 'object is not undefined');
36
37
  t.end();
37
38
  });
38
39
 
39
40
  test('is.defined', function (t) {
40
- t.false(is.defined(), 'undefined is not defined');
41
- t.true(is.defined(null), 'null is defined');
42
- t.true(is.defined({}), 'object is undefined');
41
+ t.notOk(is.defined(), 'undefined is not defined');
42
+ t.ok(is.defined(null), 'null is defined');
43
+ t.ok(is.defined({}), 'object is undefined');
43
44
  t.end();
44
45
  });
45
46
 
46
47
  test('is.empty', function (t) {
47
- t.true(is.empty(''), 'empty string is empty');
48
- t.true(is.empty([]), 'empty array is empty');
49
- t.true(is.empty({}), 'empty object is empty');
50
- (function () { t.true(is.empty(arguments), 'empty arguments is empty'); }());
48
+ t.ok(is.empty(''), 'empty string is empty');
49
+ t.ok(is.empty([]), 'empty array is empty');
50
+ t.ok(is.empty({}), 'empty object is empty');
51
+ (function () { t.ok(is.empty(arguments), 'empty arguments is empty'); }());
51
52
  t.end();
52
53
  });
53
54
 
54
55
  test('is.equal', function (t) {
55
- t.true(is.equal([1, 2, 3], [1, 2, 3]), 'arrays are shallowly equal');
56
- t.true(is.equal([1, 2, [3, 4]], [1, 2, [3, 4]]), 'arrays are deep equal');
57
- t.true(is.equal({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 }), 'objects are shallowly equal');
58
- t.true(is.equal({ a: { b: 1 } }, { a: { b: 1 } }), 'objects are deep equal');
59
- var now = Date.now();
60
- t.true(is.equal(new Date(now), new Date(now)), 'two equal date objects are equal');
56
+ t.ok(is.equal([1, 2, 3], [1, 2, 3]), 'arrays are shallowly equal');
57
+ t.ok(is.equal([1, 2, [3, 4]], [1, 2, [3, 4]]), 'arrays are deep equal');
58
+ t.ok(is.equal({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 }), 'objects are shallowly equal');
59
+ t.ok(is.equal({ a: { b: 1 } }, { a: { b: 1 } }), 'objects are deep equal');
60
+ var nowTS = now();
61
+ t.ok(is.equal(new Date(nowTS), new Date(nowTS)), 'two equal date objects are equal');
61
62
 
62
63
  var F = function () {};
63
64
  F.prototype = {};
64
- t.true(is.equal(new F(), new F()), 'two object instances are equal when the prototype is the same');
65
+ t.ok(is.equal(new F(), new F()), 'two object instances are equal when the prototype is the same');
65
66
  t.end();
66
67
  });
67
68
 
68
69
  test('is.hosted', function (t) {
69
- t.true(is.hosted('a', { a: {} }), 'object is hosted');
70
- t.true(is.hosted('a', { a: [] }), 'array is hosted');
71
- t.true(is.hosted('a', { a: function () {} }), 'function is hosted');
72
- t.false(is.hosted('a', { a: true }), 'boolean value is not hosted');
73
- t.false(is.hosted('a', { a: false }), 'boolean value is not hosted');
74
- t.false(is.hosted('a', { a: 3 }), 'number value is not hosted');
75
- t.false(is.hosted('a', { a: undefined }), 'undefined value is not hosted');
76
- t.false(is.hosted('a', { a: 'abc' }), 'string value is not hosted');
77
- t.false(is.hosted('a', { a: null }), 'null value is not hosted');
70
+ t.ok(is.hosted('a', { a: {} }), 'object is hosted');
71
+ t.ok(is.hosted('a', { a: [] }), 'array is hosted');
72
+ t.ok(is.hosted('a', { a: function () {} }), 'function is hosted');
73
+ t.notOk(is.hosted('a', { a: true }), 'boolean value is not hosted');
74
+ t.notOk(is.hosted('a', { a: false }), 'boolean value is not hosted');
75
+ t.notOk(is.hosted('a', { a: 3 }), 'number value is not hosted');
76
+ t.notOk(is.hosted('a', { a: undefined }), 'undefined value is not hosted');
77
+ t.notOk(is.hosted('a', { a: 'abc' }), 'string value is not hosted');
78
+ t.notOk(is.hosted('a', { a: null }), 'null value is not hosted');
78
79
  t.end();
79
80
  });
80
81
 
81
82
  test('is.instance', function (t) {
82
- t.true(is.instance(new Date(), Date), 'new Date is instanceof Date');
83
+ t.ok(is.instance(new Date(), Date), 'new Date is instanceof Date');
83
84
  var F = function () {};
84
- t.true(is.instance(new F(), F), 'new constructor is instanceof constructor');
85
+ t.ok(is.instance(new F(), F), 'new constructor is instanceof constructor');
85
86
  t.end();
86
87
  });
87
88
 
88
89
  test('is.null', function (t) {
89
90
  var isNull = is['null'];
90
- t.true(isNull(null), 'null is null');
91
- t.false(isNull(undefined), 'undefined is not null');
92
- t.false(isNull({}), 'object is not null');
91
+ t.ok(isNull(null), 'null is null');
92
+ t.notOk(isNull(undefined), 'undefined is not null');
93
+ t.notOk(isNull({}), 'object is not null');
93
94
  t.end();
94
95
  });
95
96
 
96
97
  test('is.arguments', function (t) {
97
- t.false(is.arguments([]), 'array is not arguments');
98
- (function () { t.true(is.arguments(arguments), 'arguments is arguments'); }());
99
- (function () { t.false(is.arguments(Array.prototype.slice.call(arguments)), 'sliced arguments is not arguments'); }());
98
+ t.notOk(is.arguments([]), 'array is not arguments');
99
+ (function () { t.ok(is.arguments(arguments), 'arguments is arguments'); }());
100
+ (function () { t.notOk(is.arguments(Array.prototype.slice.call(arguments)), 'sliced arguments is not arguments'); }());
100
101
  t.end();
101
102
  });
102
103
 
103
104
  test('is.array', function (t) {
104
- t.true(is.array([]), 'array is array');
105
- (function () { t.true(is.array(Array.prototype.slice.call(arguments)), 'sliced arguments is array'); }());
105
+ t.ok(is.array([]), 'array is array');
106
+ (function () { t.ok(is.array(Array.prototype.slice.call(arguments)), 'sliced arguments is array'); }());
106
107
  t.end();
107
108
  });
108
109
 
109
110
  test('is.array.empty', function (t) {
110
- t.true(is.array.empty([]), 'empty array is empty array');
111
- (function () { t.false(is.array.empty(arguments), 'empty arguments is not empty array'); }());
112
- (function () { t.true(is.array.empty(Array.prototype.slice.call(arguments)), 'empty sliced arguments is empty array'); }());
111
+ t.ok(is.array.empty([]), 'empty array is empty array');
112
+ (function () { t.notOk(is.array.empty(arguments), 'empty arguments is not empty array'); }());
113
+ (function () { t.ok(is.array.empty(Array.prototype.slice.call(arguments)), 'empty sliced arguments is empty array'); }());
113
114
  t.end();
114
115
  });
115
116
 
116
117
  test('is.arguments.empty', function (t) {
117
- t.false(is.arguments.empty([]), 'empty array is not empty arguments');
118
- (function () { t.true(is.arguments.empty(arguments), 'empty arguments is empty arguments'); }());
119
- (function () { t.false(is.arguments.empty(Array.prototype.slice.call(arguments)), 'empty sliced arguments is not empty arguments'); }());
118
+ t.notOk(is.arguments.empty([]), 'empty array is not empty arguments');
119
+ (function () { t.ok(is.arguments.empty(arguments), 'empty arguments is empty arguments'); }());
120
+ (function () { t.notOk(is.arguments.empty(Array.prototype.slice.call(arguments)), 'empty sliced arguments is not empty arguments'); }());
120
121
  t.end();
121
122
  });
122
123
 
123
124
  test('is.isarraylike', function (t) {
124
- t.false(is.arraylike(), 'undefined is not array-like');
125
- t.false(is.arraylike(null), 'null is not array-like');
126
- t.false(is.arraylike(false), 'false is not array-like');
127
- t.false(is.arraylike(true), 'true is not array-like');
128
- t.true(is.arraylike({ length: 0 }), 'object with zero length is array-like');
129
- t.true(is.arraylike({ length: 1 }), 'object with positive length is array-like');
130
- t.false(is.arraylike({ length: -1 }), 'object with negative length is not array-like');
131
- t.false(is.arraylike({ length: NaN }), 'object with NaN length is not array-like');
132
- t.false(is.arraylike({ length: 'foo' }), 'object with string length is not array-like');
133
- t.false(is.arraylike({ length: '' }), 'object with empty string length is not array-like');
134
- t.true(is.arraylike([]), 'array is array-like');
135
- (function () { t.true(is.arraylike(arguments), 'empty arguments is array-like'); }());
136
- (function () { t.true(is.arraylike(arguments), 'nonempty arguments is array-like'); }(1, 2, 3));
125
+ t.notOk(is.arraylike(), 'undefined is not array-like');
126
+ t.notOk(is.arraylike(null), 'null is not array-like');
127
+ t.notOk(is.arraylike(false), 'false is not array-like');
128
+ t.notOk(is.arraylike(true), 'true is not array-like');
129
+ t.ok(is.arraylike({ length: 0 }), 'object with zero length is array-like');
130
+ t.ok(is.arraylike({ length: 1 }), 'object with positive length is array-like');
131
+ t.notOk(is.arraylike({ length: -1 }), 'object with negative length is not array-like');
132
+ t.notOk(is.arraylike({ length: NaN }), 'object with NaN length is not array-like');
133
+ t.notOk(is.arraylike({ length: 'foo' }), 'object with string length is not array-like');
134
+ t.notOk(is.arraylike({ length: '' }), 'object with empty string length is not array-like');
135
+ t.ok(is.arraylike([]), 'array is array-like');
136
+ (function () { t.ok(is.arraylike(arguments), 'empty arguments is array-like'); }());
137
+ (function () { t.ok(is.arraylike(arguments), 'nonempty arguments is array-like'); }(1, 2, 3));
137
138
  t.end();
138
139
  });
139
140
 
140
141
  test('is.boolean', function (t) {
141
- t.true(is.boolean(true), 'literal true is a boolean');
142
- t.true(is.boolean(false), 'literal false is a boolean');
143
- t.true(is.boolean(new Boolean(true)), 'object true is a boolean');
144
- t.true(is.boolean(new Boolean(false)), 'object false is a boolean');
145
- t.false(is.boolean(), 'undefined is not a boolean');
146
- t.false(is.boolean(null), 'null is not a boolean');
142
+ t.ok(is.boolean(true), 'literal true is a boolean');
143
+ t.ok(is.boolean(false), 'literal false is a boolean');
144
+ t.ok(is.boolean(new Boolean(true)), 'object true is a boolean');
145
+ t.ok(is.boolean(new Boolean(false)), 'object false is a boolean');
146
+ t.notOk(is.boolean(), 'undefined is not a boolean');
147
+ t.notOk(is.boolean(null), 'null is not a boolean');
147
148
  t.end();
148
149
  });
149
150
 
150
151
  test('is.false', function (t) {
151
152
  var isFalse = is['false'];
152
- t.true(isFalse(false), 'false is false');
153
- t.true(isFalse(new Boolean(false)), 'object false is false');
154
- t.false(isFalse(true), 'true is not false');
155
- t.false(isFalse(), 'undefined is not false');
156
- t.false(isFalse(null), 'null is not false');
157
- t.false(isFalse(''), 'empty string is not false');
153
+ t.ok(isFalse(false), 'false is false');
154
+ t.ok(isFalse(new Boolean(false)), 'object false is false');
155
+ t.notOk(isFalse(true), 'true is not false');
156
+ t.notOk(isFalse(), 'undefined is not false');
157
+ t.notOk(isFalse(null), 'null is not false');
158
+ t.notOk(isFalse(''), 'empty string is not false');
158
159
  t.end();
159
160
  });
160
161
 
161
162
  test('is.true', function (t) {
162
163
  var isTrue = is['true'];
163
- t.true(isTrue(true), 'true is true');
164
- t.true(isTrue(new Boolean(true)), 'object true is true');
165
- t.false(isTrue(false), 'false is not true');
166
- t.false(isTrue(), 'undefined is not true');
167
- t.false(isTrue(null), 'null is not true');
168
- t.false(isTrue(''), 'empty string is not true');
164
+ t.ok(isTrue(true), 'true is true');
165
+ t.ok(isTrue(new Boolean(true)), 'object true is true');
166
+ t.notOk(isTrue(false), 'false is not true');
167
+ t.notOk(isTrue(), 'undefined is not true');
168
+ t.notOk(isTrue(null), 'null is not true');
169
+ t.notOk(isTrue(''), 'empty string is not true');
169
170
  t.end();
170
171
  });
171
172
 
172
173
  test('is.date', function (t) {
173
- t.true(is.date(new Date()), 'new Date is date');
174
- t.false(is.date(), 'undefined is not date');
175
- t.false(is.date(null), 'null is not date');
176
- t.false(is.date(''), 'empty string is not date');
177
- t.false(is.date(Date.now()), 'timestamp is not date');
174
+ t.ok(is.date(new Date()), 'new Date is date');
175
+ t.notOk(is.date(), 'undefined is not date');
176
+ t.notOk(is.date(null), 'null is not date');
177
+ t.notOk(is.date(''), 'empty string is not date');
178
+ t.notOk(is.date(now()), 'timestamp is not date');
178
179
  var F = function () {};
179
180
  F.prototype = new Date();
180
- t.false(is.date(new F()), 'Date subtype is not date');
181
+ t.notOk(is.date(new F()), 'Date subtype is not date');
181
182
  t.end();
182
183
  });
183
184
 
184
185
  test('is.element', function (t) {
185
186
  if (typeof HTMLElement !== 'undefined') {
186
187
  var element = document.createElement('div');
187
- t.true(is.element(element), 'HTMLElement is element');
188
- t.false(is.element({ nodeType: 1 }), 'object with nodeType is not element');
188
+ t.ok(is.element(element), 'HTMLElement is element');
189
+ t.notOk(is.element({ nodeType: 1 }), 'object with nodeType is not element');
189
190
  } else {
190
- t.true(true, 'Skipping is.element test in a non-browser environment');
191
+ t.ok(true, 'Skipping is.element test in a non-browser environment');
191
192
  }
192
193
  t.end();
193
194
  });
194
195
 
195
196
  test('is.error', function (t) {
196
197
  var err = new Error('foo');
197
- t.true(is.error(err), 'Error is error');
198
- t.false(is.error({}), 'object is not error');
199
- t.false(is.error({ toString: function () { return '[object Error]'; } }), 'object with error\'s toString is not error');
198
+ t.ok(is.error(err), 'Error is error');
199
+ t.notOk(is.error({}), 'object is not error');
200
+ t.notOk(is.error({ toString: function () { return '[object Error]'; } }), 'object with error\'s toString is not error');
200
201
  t.end();
201
202
  });
202
203
 
203
204
  test('is.fn', function (t) {
204
205
  t.equal(is['function'], is.fn, 'alias works');
205
- t.true(is.fn(function () {}), 'function is function');
206
- t.true(is.fn(console.log), 'console.log is function');
206
+ t.ok(is.fn(function () {}), 'function is function');
207
+ t.ok(is.fn(console.log), 'console.log is function');
207
208
  if (typeof window !== 'undefined') {
208
209
  // in IE7/8, typeof alert === 'object'
209
- t.true(is.fn(window.alert), 'window.alert is function');
210
+ t.ok(is.fn(window.alert), 'window.alert is function');
210
211
  }
211
- t.false(is.fn({}), 'object is not function');
212
- t.false(is.fn(null), 'null is not function');
212
+ t.notOk(is.fn({}), 'object is not function');
213
+ t.notOk(is.fn(null), 'null is not function');
213
214
  t.end();
214
215
  });
215
216
 
216
217
  test('is.number', function (t) {
217
- t.true(is.number(0), 'positive zero is number');
218
- t.true(is.number(0 / -1), 'negative zero is number');
219
- t.true(is.number(3), 'three is number');
220
- t.true(is.number(NaN), 'NaN is number');
221
- t.true(is.number(Infinity), 'infinity is number');
222
- t.true(is.number(-Infinity), 'negative infinity is number');
223
- t.true(is.number(new Number(42)), 'object number is number');
224
- t.false(is.number(), 'undefined is not number');
225
- t.false(is.number(null), 'null is not number');
226
- t.false(is.number(true), 'true is not number');
218
+ t.ok(is.number(0), 'positive zero is number');
219
+ t.ok(is.number(0 / -1), 'negative zero is number');
220
+ t.ok(is.number(3), 'three is number');
221
+ t.ok(is.number(NaN), 'NaN is number');
222
+ t.ok(is.number(Infinity), 'infinity is number');
223
+ t.ok(is.number(-Infinity), 'negative infinity is number');
224
+ t.ok(is.number(new Number(42)), 'object number is number');
225
+ t.notOk(is.number(), 'undefined is not number');
226
+ t.notOk(is.number(null), 'null is not number');
227
+ t.notOk(is.number(true), 'true is not number');
227
228
  t.end();
228
229
  });
229
230
 
230
231
  test('is.infinite', function (t) {
231
- t.true(is.infinite(Infinity), 'positive infinity is infinite');
232
- t.true(is.infinite(-Infinity), 'negative infinity is infinite');
233
- t.false(is.infinite(NaN), 'NaN is not infinite');
234
- t.false(is.infinite(0), 'a number is not infinite');
232
+ t.ok(is.infinite(Infinity), 'positive infinity is infinite');
233
+ t.ok(is.infinite(-Infinity), 'negative infinity is infinite');
234
+ t.notOk(is.infinite(NaN), 'NaN is not infinite');
235
+ t.notOk(is.infinite(0), 'a number is not infinite');
235
236
  t.end();
236
237
  });
237
238
 
238
239
  test('is.decimal', function (t) {
239
- t.true(is.decimal(1.1), 'decimal is decimal');
240
- t.false(is.decimal(0), 'zero is not decimal');
241
- t.false(is.decimal(1), 'integer is not decimal');
242
- t.false(is.decimal(NaN), 'NaN is not decimal');
240
+ t.ok(is.decimal(1.1), 'decimal is decimal');
241
+ t.notOk(is.decimal(0), 'zero is not decimal');
242
+ t.notOk(is.decimal(1), 'integer is not decimal');
243
+ t.notOk(is.decimal(NaN), 'NaN is not decimal');
244
+ t.notOk(is.decimal(Infinity), 'Infinity is not decimal');
243
245
  t.end();
244
246
  });
245
247
 
246
248
  test('is.divisibleBy', function (t) {
247
- t.true(is.divisibleBy(4, 2), '4 is divisible by 2');
248
- t.true(is.divisibleBy(4, 2), '4 is divisible by 2');
249
- t.true(is.divisibleBy(0, 1), '0 is divisible by 1');
250
- t.true(is.divisibleBy(Infinity, 1), 'infinity is divisible by anything');
251
- t.true(is.divisibleBy(1, Infinity), 'anything is divisible by infinity');
252
- t.true(is.divisibleBy(Infinity, Infinity), 'infinity is divisible by infinity');
253
- t.false(is.divisibleBy(1, 0), '1 is not divisible by 0');
254
- t.false(is.divisibleBy(NaN, 1), 'NaN is not divisible by 1');
255
- t.false(is.divisibleBy(1, NaN), '1 is not divisible by NaN');
256
- t.false(is.divisibleBy(NaN, NaN), 'NaN is not divisible by NaN');
257
- t.false(is.divisibleBy(1, 3), '1 is not divisible by 3');
249
+ t.ok(is.divisibleBy(4, 2), '4 is divisible by 2');
250
+ t.ok(is.divisibleBy(4, 2), '4 is divisible by 2');
251
+ t.ok(is.divisibleBy(0, 1), '0 is divisible by 1');
252
+ t.ok(is.divisibleBy(Infinity, 1), 'infinity is divisible by anything');
253
+ t.ok(is.divisibleBy(1, Infinity), 'anything is divisible by infinity');
254
+ t.ok(is.divisibleBy(Infinity, Infinity), 'infinity is divisible by infinity');
255
+ t.notOk(is.divisibleBy(1, 0), '1 is not divisible by 0');
256
+ t.notOk(is.divisibleBy(NaN, 1), 'NaN is not divisible by 1');
257
+ t.notOk(is.divisibleBy(1, NaN), '1 is not divisible by NaN');
258
+ t.notOk(is.divisibleBy(NaN, NaN), 'NaN is not divisible by NaN');
259
+ t.notOk(is.divisibleBy(1, 3), '1 is not divisible by 3');
258
260
  t.end();
259
261
  });
260
262
 
261
263
  test('is.int', function (t) {
262
- t.true(is.int(0), '0 is integer');
263
- t.true(is.int(3), '3 is integer');
264
- t.false(is.int(1.1), '1.1 is not integer');
265
- t.false(is.int(NaN), 'NaN is not integer');
266
- t.false(is.int(Infinity), 'infinity is not integer');
267
- t.false(is.int(null), 'null is not integer');
268
- t.false(is.int(), 'undefined is not integer');
264
+ t.ok(is.int(0), '0 is integer');
265
+ t.ok(is.int(3), '3 is integer');
266
+ t.notOk(is.int(1.1), '1.1 is not integer');
267
+ t.notOk(is.int(NaN), 'NaN is not integer');
268
+ t.notOk(is.int(Infinity), 'infinity is not integer');
269
+ t.notOk(is.int(null), 'null is not integer');
270
+ t.notOk(is.int(), 'undefined is not integer');
269
271
  t.end();
270
272
  });
271
273
 
272
274
  test('is.maximum', function (t) {
273
- t.true(is.maximum(3, [3, 2, 1]), '3 is maximum of [3,2,1]');
274
- t.true(is.maximum(3, [1, 2, 3]), '3 is maximum of [1,2,3]');
275
- t.true(is.maximum(4, [1, 2, 3]), '4 is maximum of [1,2,3]');
276
- t.true(is.maximum('c', ['a', 'b', 'c']), 'c is maximum of [a,b,c]');
277
- t.false(is.maximum(2, [1, 2, 3]), '2 is not maximum of [1,2,3]');
278
- t.throws(function () { return is.maximum(2, null); }, TypeError, 'throws when second value is not array-like');
279
- t.throws(function () { return is.maximum(2, {}); }, TypeError, 'throws when second value is not array-like');
275
+ t.ok(is.maximum(3, [3, 2, 1]), '3 is maximum of [3,2,1]');
276
+ t.ok(is.maximum(3, [1, 2, 3]), '3 is maximum of [1,2,3]');
277
+ t.ok(is.maximum(4, [1, 2, 3]), '4 is maximum of [1,2,3]');
278
+ t.ok(is.maximum('c', ['a', 'b', 'c']), 'c is maximum of [a,b,c]');
279
+ t.notOk(is.maximum(2, [1, 2, 3]), '2 is not maximum of [1,2,3]');
280
+ var error = new TypeError('second argument must be array-like');
281
+ t.throws(function () { return is.maximum(2, null); }, error, 'throws when second value is not array-like');
282
+ t.throws(function () { return is.maximum(2, {}); }, error, 'throws when second value is not array-like');
280
283
  t.end();
281
284
  });
282
285
 
283
286
  test('is.minimum', function (t) {
284
- t.true(is.minimum(1, [1, 2, 3]), '1 is minimum of [1,2,3]');
285
- t.true(is.minimum(0, [1, 2, 3]), '0 is minimum of [1,2,3]');
286
- t.true(is.minimum('a', ['a', 'b', 'c']), 'a is minimum of [a,b,c]');
287
- t.false(is.minimum(2, [1, 2, 3]), '2 is not minimum of [1,2,3]');
288
- t.throws(function () { return is.minimum(2, null); }, TypeError, 'throws when second value is not array-like');
289
- t.throws(function () { return is.minimum(2, {}); }, TypeError, 'throws when second value is not array-like');
287
+ t.ok(is.minimum(1, [1, 2, 3]), '1 is minimum of [1,2,3]');
288
+ t.ok(is.minimum(0, [1, 2, 3]), '0 is minimum of [1,2,3]');
289
+ t.ok(is.minimum('a', ['a', 'b', 'c']), 'a is minimum of [a,b,c]');
290
+ t.notOk(is.minimum(2, [1, 2, 3]), '2 is not minimum of [1,2,3]');
291
+ var error = new TypeError('second argument must be array-like');
292
+ t.throws(function () { return is.minimum(2, null); }, error, 'throws when second value is not array-like');
293
+ t.throws(function () { return is.minimum(2, {}); }, error, 'throws when second value is not array-like');
290
294
  t.end();
291
295
  });
292
296
 
293
297
  test('is.nan', function (t) {
294
- t.true(is.nan(NaN), 'NaN is not a number');
295
- t.true(is.nan('abc'), 'string is not a number');
296
- t.true(is.nan(true), 'boolean is not a number');
297
- t.true(is.nan({}), 'object is not a number');
298
- t.true(is.nan([]), 'array is not a number');
299
- t.true(is.nan(function () {}), 'function is not a number');
300
- t.false(is.nan(0), 'zero is a number');
301
- t.false(is.nan(3), 'three is a number');
302
- t.false(is.nan(1.1), '1.1 is a number');
303
- t.false(is.nan(Infinity), 'infinity is a number');
298
+ t.ok(is.nan(NaN), 'NaN is not a number');
299
+ t.ok(is.nan('abc'), 'string is not a number');
300
+ t.ok(is.nan(true), 'boolean is not a number');
301
+ t.ok(is.nan({}), 'object is not a number');
302
+ t.ok(is.nan([]), 'array is not a number');
303
+ t.ok(is.nan(function () {}), 'function is not a number');
304
+ t.notOk(is.nan(0), 'zero is a number');
305
+ t.notOk(is.nan(3), 'three is a number');
306
+ t.notOk(is.nan(1.1), '1.1 is a number');
307
+ t.notOk(is.nan(Infinity), 'infinity is a number');
304
308
  t.end();
305
309
  });
306
310
 
307
311
  test('is.even', function (t) {
308
- t.true(is.even(0), 'zero is even');
309
- t.true(is.even(2), 'two is even');
310
- t.true(is.even(Infinity), 'infinity is even');
311
- t.false(is.even(1), '1 is not even');
312
- t.false(is.even(), 'undefined is not even');
313
- t.false(is.even(null), 'null is not even');
314
- t.false(is.even(NaN), 'NaN is not even');
312
+ t.ok(is.even(0), 'zero is even');
313
+ t.ok(is.even(2), 'two is even');
314
+ t.ok(is.even(Infinity), 'infinity is even');
315
+ t.notOk(is.even(1), '1 is not even');
316
+ t.notOk(is.even(), 'undefined is not even');
317
+ t.notOk(is.even(null), 'null is not even');
318
+ t.notOk(is.even(NaN), 'NaN is not even');
315
319
  t.end();
316
320
  });
317
321
 
318
322
  test('is.odd', function (t) {
319
- t.true(is.odd(1), 'zero is odd');
320
- t.true(is.odd(3), 'two is odd');
321
- t.true(is.odd(Infinity), 'infinity is odd');
322
- t.false(is.odd(0), '0 is not odd');
323
- t.false(is.odd(2), '2 is not odd');
324
- t.false(is.odd(), 'undefined is not odd');
325
- t.false(is.odd(null), 'null is not odd');
326
- t.false(is.odd(NaN), 'NaN is not odd');
323
+ t.ok(is.odd(1), 'zero is odd');
324
+ t.ok(is.odd(3), 'two is odd');
325
+ t.ok(is.odd(Infinity), 'infinity is odd');
326
+ t.notOk(is.odd(0), '0 is not odd');
327
+ t.notOk(is.odd(2), '2 is not odd');
328
+ t.notOk(is.odd(), 'undefined is not odd');
329
+ t.notOk(is.odd(null), 'null is not odd');
330
+ t.notOk(is.odd(NaN), 'NaN is not odd');
327
331
  t.end();
328
332
  });
329
333
 
330
334
  test('is.ge', function (t) {
331
- t.true(is.ge(3, 2), '3 is greater than 2');
332
- t.false(is.ge(2, 3), '2 is not greater than 3');
333
- t.true(is.ge(3, 3), '3 is greater than or equal to 3');
334
- t.true(is.ge('abc', 'a'), 'abc is greater than a');
335
- t.true(is.ge('abc', 'abc'), 'abc is greater than or equal to abc');
336
- t.false(is.ge('a', 'abc'), 'a is not greater than abc');
337
- t.false(is.ge(Infinity, 0), 'infinity is not greater than anything');
338
- t.false(is.ge(0, Infinity), 'anything is not greater than infinity');
339
- t.throws(function () { return is.ge(NaN, 2); }, TypeError, 'throws when first value is NaN');
340
- t.throws(function () { return is.ge(2, NaN); }, TypeError, 'throws when second value is NaN');
335
+ t.ok(is.ge(3, 2), '3 is greater than 2');
336
+ t.notOk(is.ge(2, 3), '2 is not greater than 3');
337
+ t.ok(is.ge(3, 3), '3 is greater than or equal to 3');
338
+ t.ok(is.ge('abc', 'a'), 'abc is greater than a');
339
+ t.ok(is.ge('abc', 'abc'), 'abc is greater than or equal to abc');
340
+ t.notOk(is.ge('a', 'abc'), 'a is not greater than abc');
341
+ t.notOk(is.ge(Infinity, 0), 'infinity is not greater than anything');
342
+ t.notOk(is.ge(0, Infinity), 'anything is not greater than infinity');
343
+ var error = new TypeError('NaN is not a valid value');
344
+ t.throws(function () { return is.ge(NaN, 2); }, error, 'throws when first value is NaN');
345
+ t.throws(function () { return is.ge(2, NaN); }, error, 'throws when second value is NaN');
341
346
  t.end();
342
347
  });
343
348
 
344
349
  test('is.gt', function (t) {
345
- t.true(is.gt(3, 2), '3 is greater than 2');
346
- t.false(is.gt(2, 3), '2 is not greater than 3');
347
- t.false(is.gt(3, 3), '3 is not greater than 3');
348
- t.true(is.gt('abc', 'a'), 'abc is greater than a');
349
- t.false(is.gt('abc', 'abc'), 'abc is not greater than abc');
350
- t.false(is.gt('a', 'abc'), 'a is not greater than abc');
351
- t.false(is.gt(Infinity, 0), 'infinity is not greater than anything');
352
- t.false(is.gt(0, Infinity), 'anything is not greater than infinity');
353
- t.throws(function () { return is.gt(NaN, 2); }, TypeError, 'throws when first value is NaN');
354
- t.throws(function () { return is.gt(2, NaN); }, TypeError, 'throws when second value is NaN');
350
+ t.ok(is.gt(3, 2), '3 is greater than 2');
351
+ t.notOk(is.gt(2, 3), '2 is not greater than 3');
352
+ t.notOk(is.gt(3, 3), '3 is not greater than 3');
353
+ t.ok(is.gt('abc', 'a'), 'abc is greater than a');
354
+ t.notOk(is.gt('abc', 'abc'), 'abc is not greater than abc');
355
+ t.notOk(is.gt('a', 'abc'), 'a is not greater than abc');
356
+ t.notOk(is.gt(Infinity, 0), 'infinity is not greater than anything');
357
+ t.notOk(is.gt(0, Infinity), 'anything is not greater than infinity');
358
+ var error = new TypeError('NaN is not a valid value');
359
+ t.throws(function () { return is.gt(NaN, 2); }, error, 'throws when first value is NaN');
360
+ t.throws(function () { return is.gt(2, NaN); }, error, 'throws when second value is NaN');
355
361
  t.end();
356
362
  });
357
363
 
358
364
  test('is.le', function (t) {
359
- t.true(is.le(2, 3), '2 is lesser than or equal to 3');
360
- t.false(is.le(3, 2), '3 is not lesser than or equal to 2');
361
- t.true(is.le(3, 3), '3 is lesser than or equal to 3');
362
- t.true(is.le('a', 'abc'), 'a is lesser than or equal to abc');
363
- t.true(is.le('abc', 'abc'), 'abc is lesser than or equal to abc');
364
- t.false(is.le('abc', 'a'), 'abc is not lesser than or equal to a');
365
- t.false(is.le(Infinity, 0), 'infinity is not lesser than or equal to anything');
366
- t.false(is.le(0, Infinity), 'anything is not lesser than or equal to infinity');
367
- t.throws(function () { return is.le(NaN, 2); }, TypeError, 'throws when first value is NaN');
368
- t.throws(function () { return is.le(2, NaN); }, TypeError, 'throws when second value is NaN');
365
+ t.ok(is.le(2, 3), '2 is lesser than or equal to 3');
366
+ t.notOk(is.le(3, 2), '3 is not lesser than or equal to 2');
367
+ t.ok(is.le(3, 3), '3 is lesser than or equal to 3');
368
+ t.ok(is.le('a', 'abc'), 'a is lesser than or equal to abc');
369
+ t.ok(is.le('abc', 'abc'), 'abc is lesser than or equal to abc');
370
+ t.notOk(is.le('abc', 'a'), 'abc is not lesser than or equal to a');
371
+ t.notOk(is.le(Infinity, 0), 'infinity is not lesser than or equal to anything');
372
+ t.notOk(is.le(0, Infinity), 'anything is not lesser than or equal to infinity');
373
+ var error = new TypeError('NaN is not a valid value');
374
+ t.throws(function () { return is.le(NaN, 2); }, error, 'throws when first value is NaN');
375
+ t.throws(function () { return is.le(2, NaN); }, error, 'throws when second value is NaN');
369
376
  t.end();
370
377
  });
371
378
 
372
379
  test('is.lt', function (t) {
373
- t.true(is.lt(2, 3), '2 is lesser than 3');
374
- t.false(is.lt(3, 2), '3 is not lesser than 2');
375
- t.false(is.lt(3, 3), '3 is not lesser than 3');
376
- t.true(is.lt('a', 'abc'), 'a is lesser than abc');
377
- t.false(is.lt('abc', 'abc'), 'abc is not lesser than abc');
378
- t.false(is.lt('abc', 'a'), 'abc is not lesser than a');
379
- t.false(is.lt(Infinity, 0), 'infinity is not lesser than anything');
380
- t.false(is.lt(0, Infinity), 'anything is not lesser than infinity');
381
- t.throws(function () { return is.lt(NaN, 2); }, TypeError, 'throws when first value is NaN');
382
- t.throws(function () { return is.lt(2, NaN); }, TypeError, 'throws when second value is NaN');
380
+ t.ok(is.lt(2, 3), '2 is lesser than 3');
381
+ t.notOk(is.lt(3, 2), '3 is not lesser than 2');
382
+ t.notOk(is.lt(3, 3), '3 is not lesser than 3');
383
+ t.ok(is.lt('a', 'abc'), 'a is lesser than abc');
384
+ t.notOk(is.lt('abc', 'abc'), 'abc is not lesser than abc');
385
+ t.notOk(is.lt('abc', 'a'), 'abc is not lesser than a');
386
+ t.notOk(is.lt(Infinity, 0), 'infinity is not lesser than anything');
387
+ t.notOk(is.lt(0, Infinity), 'anything is not lesser than infinity');
388
+ var error = new TypeError('NaN is not a valid value');
389
+ t.throws(function () { return is.lt(NaN, 2); }, error, 'throws when first value is NaN');
390
+ t.throws(function () { return is.lt(2, NaN); }, error, 'throws when second value is NaN');
383
391
  t.end();
384
392
  });
385
393
 
386
394
  test('is.within', function (t) {
387
- t.test('argument checking', function (st) {
388
- st.throws(function () { return is.within(NaN, 0, 0); }, TypeError, 'throws when first value is NaN');
389
- st.throws(function () { return is.within(0, NaN, 0); }, TypeError, 'throws when second value is NaN');
390
- st.throws(function () { return is.within(0, 0, NaN); }, TypeError, 'throws when third value is NaN');
391
- st.throws(function () { return is.within('', 0, 0); }, TypeError, 'throws when first value is string');
392
- st.throws(function () { return is.within(0, '', 0); }, TypeError, 'throws when second value is string');
393
- st.throws(function () { return is.within(0, 0, ''); }, TypeError, 'throws when third value is string');
394
- st.throws(function () { return is.within({}, 0, 0); }, TypeError, 'throws when first value is object');
395
- st.throws(function () { return is.within(0, {}, 0); }, TypeError, 'throws when second value is object');
396
- st.throws(function () { return is.within(0, 0, {}); }, TypeError, 'throws when third value is object');
397
- st.throws(function () { return is.within(null, 0, 0); }, TypeError, 'throws when first value is null');
398
- st.throws(function () { return is.within(0, null, 0); }, TypeError, 'throws when second value is null');
399
- st.throws(function () { return is.within(0, 0, null); }, TypeError, 'throws when third value is null');
400
- st.throws(function () { return is.within(undefined, 0, 0); }, TypeError, 'throws when first value is undefined');
401
- st.throws(function () { return is.within(0, undefined, 0); }, TypeError, 'throws when second value is undefined');
402
- st.throws(function () { return is.within(0, 0, undefined); }, TypeError, 'throws when third value is undefined');
403
- st.end();
404
- });
405
- t.true(is.within(2, 1, 3), '2 is between 1 and 3');
406
- t.true(is.within(0, -1, 1), '0 is between -1 and 1');
407
- t.true(is.within(2, 0, Infinity), 'infinity always returns true');
408
- t.true(is.within(2, Infinity, 2), 'infinity always returns true');
409
- t.true(is.within(Infinity, 0, 1), 'infinity always returns true');
410
- t.false(is.within(2, -1, -1), '2 is not between -1 and 1');
395
+ var nanError = new TypeError('NaN is not a valid value');
396
+ t.throws(function () { return is.within(NaN, 0, 0); }, nanError, 'throws when first value is NaN');
397
+ t.throws(function () { return is.within(0, NaN, 0); }, nanError, 'throws when second value is NaN');
398
+ t.throws(function () { return is.within(0, 0, NaN); }, nanError, 'throws when third value is NaN');
399
+
400
+ var error = new TypeError('all arguments must be numbers');
401
+ t.throws(function () { return is.within('', 0, 0); }, error, 'throws when first value is string');
402
+ t.throws(function () { return is.within(0, '', 0); }, error, 'throws when second value is string');
403
+ t.throws(function () { return is.within(0, 0, ''); }, error, 'throws when third value is string');
404
+ t.throws(function () { return is.within({}, 0, 0); }, error, 'throws when first value is object');
405
+ t.throws(function () { return is.within(0, {}, 0); }, error, 'throws when second value is object');
406
+ t.throws(function () { return is.within(0, 0, {}); }, error, 'throws when third value is object');
407
+ t.throws(function () { return is.within(null, 0, 0); }, error, 'throws when first value is null');
408
+ t.throws(function () { return is.within(0, null, 0); }, error, 'throws when second value is null');
409
+ t.throws(function () { return is.within(0, 0, null); }, error, 'throws when third value is null');
410
+ t.throws(function () { return is.within(undefined, 0, 0); }, error, 'throws when first value is undefined');
411
+ t.throws(function () { return is.within(0, undefined, 0); }, error, 'throws when second value is undefined');
412
+ t.throws(function () { return is.within(0, 0, undefined); }, error, 'throws when third value is undefined');
413
+
414
+ t.ok(is.within(2, 1, 3), '2 is between 1 and 3');
415
+ t.ok(is.within(0, -1, 1), '0 is between -1 and 1');
416
+ t.ok(is.within(2, 0, Infinity), 'infinity always returns true');
417
+ t.ok(is.within(2, Infinity, 2), 'infinity always returns true');
418
+ t.ok(is.within(Infinity, 0, 1), 'infinity always returns true');
419
+ t.notOk(is.within(2, -1, -1), '2 is not between -1 and 1');
411
420
  t.end();
412
421
  });
413
422
 
414
423
  test('is.object', function (t) {
415
- t.true(is.object({}), 'object literal is object');
416
- t.false(is.object(), 'undefined is not an object');
417
- t.false(is.object(null), 'null is not an object');
418
- t.false(is.object(true), 'true is not an object');
419
- t.false(is.object(''), 'string is not an object');
420
- t.false(is.object(NaN), 'NaN is not an object');
421
- t.false(is.object(Object), 'object constructor is not an object');
422
- t.false(is.object(function () {}), 'function is not an object');
424
+ t.ok(is.object({}), 'object literal is object');
425
+ t.notOk(is.object(), 'undefined is not an object');
426
+ t.notOk(is.object(null), 'null is not an object');
427
+ t.notOk(is.object(true), 'true is not an object');
428
+ t.notOk(is.object(''), 'string is not an object');
429
+ t.notOk(is.object(NaN), 'NaN is not an object');
430
+ t.notOk(is.object(Object), 'object constructor is not an object');
431
+ t.notOk(is.object(function () {}), 'function is not an object');
432
+ t.end();
433
+ });
434
+
435
+ test('is.hash', function (t) {
436
+ t.ok(is.hash({}), 'empty object literal is hash');
437
+ t.ok(is.hash({ 1: 2, a: "b" }), 'object literal is hash');
438
+ t.notOk(is.hash(), 'undefined is not a hash');
439
+ t.notOk(is.hash(null), 'null is not a hash');
440
+ t.notOk(is.hash(new Date()), 'date is not a hash');
441
+ t.notOk(is.hash(new String()), 'string object is not a hash');
442
+ t.notOk(is.hash(''), 'string literal is not a hash');
443
+ t.notOk(is.hash(new Number()), 'number object is not a hash');
444
+ t.notOk(is.hash(1), 'number literal is not a hash');
445
+ t.notOk(is.hash(true), 'true is not a hash');
446
+ t.notOk(is.hash(false), 'false is not a hash');
447
+ t.notOk(is.hash(new Boolean()), 'boolean obj is not hash');
448
+ t.notOk(is.hash(false), 'literal false is not hash');
449
+ t.notOk(is.hash(true), 'literal true is not hash');
450
+ if (typeof module !== 'undefined') {
451
+ t.ok(is.hash(module.exports), 'module.exports is a hash');
452
+ }
453
+ if (typeof window !== 'undefined') {
454
+ t.notOk(is.hash(window), 'window is not a hash');
455
+ t.notOk(is.hash(document.createElement('div')), 'element is not a hash');
456
+ } else if (typeof process !== 'undefined') {
457
+ t.notOk(is.hash(global), 'global is not a hash');
458
+ t.notOk(is.hash(process), 'process is not a hash');
459
+ }
423
460
  t.end();
424
461
  });
425
462
 
426
463
  test('is.regexp', function (t) {
427
- t.true(is.regexp(/a/g), 'regex literal is regex');
428
- t.true(is.regexp(new RegExp('a', 'g')), 'regex object is regex');
429
- t.false(is.regexp(), 'undefined is not regex');
430
- t.false(is.regexp(function () {}), 'function is not regex');
431
- t.false(is.regexp('/a/g'), 'string regex is not regex');
464
+ t.ok(is.regexp(/a/g), 'regex literal is regex');
465
+ t.ok(is.regexp(new RegExp('a', 'g')), 'regex object is regex');
466
+ t.notOk(is.regexp(), 'undefined is not regex');
467
+ t.notOk(is.regexp(function () {}), 'function is not regex');
468
+ t.notOk(is.regexp('/a/g'), 'string regex is not regex');
432
469
  t.end();
433
470
  });
434
471
 
435
472
  test('is.string', function (t) {
436
- t.true(is.string('foo'), 'string literal is string');
437
- t.true(is.string(new String('foo')), 'string literal is string');
438
- t.false(is.string(), 'undefined is not string');
439
- t.false(is.string(String), 'string constructor is not string');
473
+ t.ok(is.string('foo'), 'string literal is string');
474
+ t.ok(is.string(new String('foo')), 'string literal is string');
475
+ t.notOk(is.string(), 'undefined is not string');
476
+ t.notOk(is.string(String), 'string constructor is not string');
440
477
  var F = function () {};
441
478
  F.prototype = new String();
442
- t.false(is.string(F), 'string subtype is not string');
443
- t.end();
444
- });
445
-
446
- test('is.hash', function (t) {
447
- t.true(is.hash({}), 'empty object literal is hash');
448
- t.true(is.hash({ 1: 2, a: "b" }), 'object literal is hash');
449
- t.false(is.hash(), 'undefined is not a hash');
450
- t.false(is.hash(null), 'null is not a hash');
451
- t.false(is.hash(new Date()), 'date is not a hash');
452
- t.false(is.hash(new String()), 'string object is not a hash');
453
- t.false(is.hash(''), 'string literal is not a hash');
454
- t.false(is.hash(new Number()), 'number object is not a hash');
455
- t.false(is.hash(1), 'number literal is not a hash');
456
- t.false(is.hash(true), 'true is not a hash');
457
- t.false(is.hash(false), 'false is not a hash');
458
- if (typeof module !== 'undefined') {
459
- t.true(is.hash(module.exports), 'module.exports is a hash');
460
- }
461
- if (typeof window !== 'undefined') {
462
- t.false(is.hash(window), 'window is not a hash');
463
- t.false(is.hash(document.createElement('div')), 'element is not a hash');
464
- } else if (typeof process !== 'undefined') {
465
- t.false(is.hash(global), 'global is not a hash');
466
- t.false(is.hash(process), 'process is not a hash');
467
- }
479
+ t.notOk(is.string(F), 'string subtype is not string');
468
480
  t.end();
469
481
  });
470
482