-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
test.js
58 lines (48 loc) · 1.13 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
var isArray = require('./');
var test = require('tape');
var nativeIsArray = Array.isArray;
test('is array (only polyfill)', function (t) {
delete Array.isArray;
t.ok(isArray([]));
t.notOk(isArray({}));
t.notOk(isArray(null));
t.notOk(isArray(false));
t.notOk(isArray(''));
t.notOk(isArray('42'));
t.notOk(isArray(42));
t.notOk(isArray(34.00));
t.notOk(isArray(123e-5));
t.notOk(isArray('[]'));
t.notOk(isArray(undefined));
t.notOk(isArray(function () {}));
var obj = {};
obj[0] = true;
t.notOk(isArray(obj));
var arr = [];
arr.foo = 'bar';
t.ok(isArray(arr));
t.end();
});
test('is array (native)', function (t) {
Array.isArray = nativeIsArray;
t.ok(isArray([]));
t.notOk(isArray({}));
t.notOk(isArray(null));
t.notOk(isArray(false));
t.notOk(isArray(''));
t.notOk(isArray('42'));
t.notOk(isArray(42));
t.notOk(isArray(34.00));
t.notOk(isArray(123e-5));
t.notOk(isArray('[]'));
t.notOk(isArray(undefined));
t.notOk(isArray(function () {}));
var obj = {};
obj[0] = true;
t.notOk(isArray(obj));
var arr = [];
arr.foo = 'bar';
t.ok(isArray(arr));
t.end();
});