You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -42,48 +40,100 @@ tape( 'main export is a function', function test( t ) {
42
40
t.end();
43
41
});
44
42
45
-
tape('the function returns `true` if provided an `ArrayBuffer` view',functiontest(t){
43
+
tape('if an environment does not support array buffers, the main export is a polyfill which always returns `false`',functiontest(t){
44
+
varisArrayBufferView;
46
45
varvalues;
47
46
vari;
48
47
48
+
isArrayBufferView=proxyquire('./../lib',{
49
+
'./../../has-arraybuffer-support': hasSupport
50
+
});
51
+
52
+
t.strictEqual(isArrayBufferView,require('./../lib/no_arraybuffer.js'),'exports a polyfill');
53
+
49
54
values=[
50
-
newFloat64Array(10),
51
-
newFloat32Array(10),
52
-
newUint32Array(10),
53
-
newInt32Array(10),
54
-
newUint16Array(10),
55
-
newInt16Array(10),
56
-
newUint8Array(10),
57
-
newInt8Array(10),
58
-
newUint8ClampedArray(10)
55
+
'5',
56
+
5,
57
+
NaN,
58
+
null,
59
+
void0,
60
+
false,
61
+
true,
62
+
[],
63
+
{},
64
+
functionnoop(){}
59
65
];
60
66
61
67
for(i=0;i<values.length;i++){
62
-
t.strictEqual(isArrayBufferView(values[i]),true,'returns true when provided '+values[i]);
68
+
t.strictEqual(isArrayBufferView(values[i]),false,'returns false when provided '+values[i]);
63
69
}
64
70
t.end();
71
+
72
+
functionhasSupport(){
73
+
returnfalse;
74
+
}
65
75
});
66
76
67
-
tape('the function returns `false` if not provided an `ArrayBuffer` view',functiontest(t){
77
+
tape('if an environment does support array buffers but not the `ArrayBuffer.isView` method, the main export is a polyfill checking for data views or typed arrays',functiontest(t){
78
+
varisArrayBufferView;
68
79
varvalues;
69
80
vari;
70
81
82
+
isArrayBufferView=proxyquire('./../lib',{
83
+
'@stdlib/array/buffer': {
84
+
'isView': null
85
+
}
86
+
});
87
+
88
+
t.strictEqual(isArrayBufferView,require('./../lib/polyfill.js'),'exports a polyfill');
89
+
71
90
values=[
72
91
'5',
73
92
5,
74
93
NaN,
75
-
true,
76
94
null,
77
95
void0,
96
+
false,
97
+
true,
78
98
[],
79
99
{},
80
-
functionnoop(){},
81
-
newArray(10),
82
-
newArrayBuffer(10)
100
+
functionnoop(){}
83
101
];
84
102
85
103
for(i=0;i<values.length;i++){
86
-
t.strictEqual(isArrayBufferView(values[i]),false,'returns false when provided '+values[i]);
104
+
t.strictEqual(isArrayBufferView(values[i]),false,'returns false when provided '+values[i]);
105
+
}
106
+
107
+
values=[
108
+
newFloat64Array(10),
109
+
newFloat32Array(10),
110
+
newInt32Array(10),
111
+
newUint32Array(10),
112
+
newInt16Array(10),
113
+
newUint16Array(10),
114
+
newInt8Array(10)
115
+
];
116
+
for(i=0;i<values.length;i++){
117
+
t.strictEqual(isArrayBufferView(values[i]),true,'returns true when provided '+values[i]);
87
118
}
119
+
120
+
t.end();
121
+
});
122
+
123
+
tape('if an environment does support array buffers and the `ArrayBuffer.isView` method, the main export is not any of the polyfills',functiontest(t){
0 commit comments