source: imaps-frontend/node_modules/has-bigints/test/index.js@ d565449

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: 1002 bytes
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var hasBigInts = require('..');
5
6test('interface', function (t) {
7 t.equal(typeof hasBigInts, 'function', 'is a function');
8 t.equal(typeof hasBigInts(), 'boolean', 'returns a boolean');
9 t.end();
10});
11
12test('BigInts are supported', { skip: !hasBigInts() }, function (t) {
13 t.equal(typeof BigInt, 'function', 'global BigInt is a function');
14 if (typeof BigInt !== 'function') {
15 return;
16 }
17
18 t.equal(BigInt(42), BigInt(42), '42n === 42n');
19 t['throws'](
20 function () { BigInt(NaN); },
21 RangeError,
22 'NaN is not an integer; BigInt(NaN) throws'
23 );
24
25 t['throws'](
26 function () { BigInt(Infinity); },
27 RangeError,
28 'Infinity is not an integer; BigInt(Infinity) throws'
29 );
30
31 t['throws'](
32 function () { BigInt(1.1); },
33 RangeError,
34 '1.1 is not an integer; BigInt(1.1) throws'
35 );
36
37 t.end();
38});
39
40test('BigInts are not supported', { skip: hasBigInts() }, function (t) {
41 t.equal(typeof BigInt, 'undefined', 'global BigInt is undefined');
42
43 t.end();
44});
Note: See TracBrowser for help on using the repository browser.