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:
842 bytes
|
Line | |
---|
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 byteLength = require('../');
|
---|
9 |
|
---|
10 | test('byteLength', function (t) {
|
---|
11 | forEach(v.objects.concat(v.primitives), function (nonAB) {
|
---|
12 | t.equal(byteLength(nonAB), NaN, inspect(nonAB) + ' is not an ArrayBuffer, and yields NaN');
|
---|
13 | });
|
---|
14 |
|
---|
15 | t.test('ArrayBuffers', { skip: typeof ArrayBuffer !== 'function' }, function (st) {
|
---|
16 | var ab32 = new ArrayBuffer(32);
|
---|
17 | st.equal(byteLength(ab32), 32, 'works on an ArrayBuffer of length 32: ' + inspect(ab32));
|
---|
18 |
|
---|
19 | var ab0 = new ArrayBuffer(0);
|
---|
20 | st.equal(byteLength(ab0), 0, 'works on an ArrayBuffer of length 0: ' + inspect(ab0));
|
---|
21 |
|
---|
22 | var dv = new DataView(ab32);
|
---|
23 | st.equal(byteLength(dv), NaN, 'a DataView returns NaN');
|
---|
24 |
|
---|
25 | st.end();
|
---|
26 | });
|
---|
27 |
|
---|
28 | t.end();
|
---|
29 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.