1 | 'use strict';
|
2 |
|
3 | var inspect = require('../');
|
4 | var test = require('tape');
|
5 | var hasToStringTag = require('has-tostringtag/shams')();
|
6 |
|
7 | test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
|
8 | t.test('primitives', function (st) {
|
9 | st.plan(3);
|
10 |
|
11 | st.equal(inspect(BigInt(-256)), '-256n');
|
12 | st.equal(inspect(BigInt(0)), '0n');
|
13 | st.equal(inspect(BigInt(256)), '256n');
|
14 | });
|
15 |
|
16 | t.test('objects', function (st) {
|
17 | st.plan(3);
|
18 |
|
19 | st.equal(inspect(Object(BigInt(-256))), 'Object(-256n)');
|
20 | st.equal(inspect(Object(BigInt(0))), 'Object(0n)');
|
21 | st.equal(inspect(Object(BigInt(256))), 'Object(256n)');
|
22 | });
|
23 |
|
24 | t.test('syntactic primitives', function (st) {
|
25 | st.plan(3);
|
26 |
|
27 |
|
28 | st.equal(inspect(Function('return -256n')()), '-256n');
|
29 | st.equal(inspect(Function('return 0n')()), '0n');
|
30 | st.equal(inspect(Function('return 256n')()), '256n');
|
31 | });
|
32 |
|
33 | t.test('toStringTag', { skip: !hasToStringTag }, function (st) {
|
34 | st.plan(1);
|
35 |
|
36 | var faker = {};
|
37 | faker[Symbol.toStringTag] = 'BigInt';
|
38 | st.equal(
|
39 | inspect(faker),
|
40 | '{ [Symbol(Symbol.toStringTag)]: \'BigInt\' }',
|
41 | 'object lying about being a BigInt inspects as an object'
|
42 | );
|
43 | });
|
44 |
|
45 | t.end();
|
46 | });
|