|
911 | 911 | assert.ok(_.isError(new URIError()), 'URIErrors are Errors'); |
912 | 912 | }); |
913 | 913 |
|
| 914 | + if (typeof ArrayBuffer != 'undefined') { |
| 915 | + QUnit.test('isArrayBuffer, isDataView and isTypedArray', function(assert) { |
| 916 | + var buffer = new ArrayBuffer(16); |
| 917 | + var checkValues = { |
| 918 | + 'null': null, |
| 919 | + 'a string': '', |
| 920 | + 'an array': [], |
| 921 | + 'an ArrayBuffer': buffer, |
| 922 | + 'a DataView': new DataView(buffer), |
| 923 | + 'a TypedArray': new Uint8Array(buffer) |
| 924 | + }; |
| 925 | + var types = ['an ArrayBuffer', 'a DataView', 'a TypedArray']; |
| 926 | + _.each(types, function(type) { |
| 927 | + var typeCheck = _['is' + type.split(' ')[1]]; |
| 928 | + _.each(checkValues, function(value, description) { |
| 929 | + if (description === type) { |
| 930 | + assert.ok(typeCheck(value), description + ' is ' + type); |
| 931 | + } else { |
| 932 | + assert.ok(!typeCheck(value), description + ' is not ' + type); |
| 933 | + } |
| 934 | + }); |
| 935 | + }); |
| 936 | + }); |
| 937 | + |
| 938 | + QUnit.test('isTypedArray', function(assert) { |
| 939 | + var buffer = new ArrayBuffer(16); |
| 940 | + _.each([Uint8ClampedArray, Int8Array, Uint16Array, Int16Array, Uint32Array, Int32Array, Float32Array, Float64Array], function(ctor) { |
| 941 | + assert.ok(_.isTypedArray(new ctor(buffer)), ctor.name + ' is a typed array'); |
| 942 | + }); |
| 943 | + |
| 944 | + if (typeof BigInt64Array != 'undefined') { |
| 945 | + assert.ok(_.isTypedArray(new BigInt64Array(buffer)), 'BigInt64Array is a typed array'); |
| 946 | + } |
| 947 | + }); |
| 948 | + } |
| 949 | + |
914 | 950 | QUnit.test('tap', function(assert) { |
915 | 951 | var intercepted = null; |
916 | 952 | var interceptor = function(obj) { intercepted = obj; }; |
|
0 commit comments