main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var test = require('tape');
|
---|
| 4 | var forEach = require('for-each');
|
---|
| 5 | var v = require('es-value-fixtures');
|
---|
| 6 | var inspect = require('object-inspect');
|
---|
| 7 |
|
---|
| 8 | var dataViewByteLength = require('../');
|
---|
| 9 |
|
---|
| 10 | test('dataViewByteLength', function (t) {
|
---|
| 11 | forEach(
|
---|
| 12 | // @ts-expect-error TS sucks at [].concat
|
---|
| 13 | // eslint-disable-next-line no-extra-parens
|
---|
| 14 | /** @type {[...typeof v.primitives, ...typeof v.objects]} */ ([].concat(v.primitives, v.objects)),
|
---|
| 15 | function (nonDV) {
|
---|
| 16 | t['throws'](function () { dataViewByteLength(nonDV); }, TypeError, inspect(nonDV) + ' is not a DataView');
|
---|
| 17 | }
|
---|
| 18 | );
|
---|
| 19 |
|
---|
| 20 | t.test('DataView', { skip: typeof DataView !== 'function' }, function (st) {
|
---|
| 21 | var ab = new ArrayBuffer(42);
|
---|
| 22 | var dv = new DataView(ab);
|
---|
| 23 |
|
---|
| 24 | st.equal(dataViewByteLength(dv), 42, inspect(dv) + ' has the same byteLength as the buffer originally passed to the DataView');
|
---|
| 25 | st.equal(dataViewByteLength(dv), dv.buffer.byteLength, inspect(dv) + ' has the same byteLength as the buffer’s byteLength of its own buffer property');
|
---|
| 26 |
|
---|
| 27 | st.end();
|
---|
| 28 | });
|
---|
| 29 |
|
---|
| 30 | t.end();
|
---|
| 31 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.