[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var test = require('tape');
|
---|
| 4 | var isNumber = require('../');
|
---|
| 5 | var hasToStringTag = require('has-tostringtag/shams')();
|
---|
| 6 |
|
---|
| 7 | test('not Numbers', function (t) {
|
---|
| 8 | t.notOk(isNumber(), 'undefined is not Number');
|
---|
| 9 | t.notOk(isNumber(null), 'null is not Number');
|
---|
| 10 | t.notOk(isNumber(false), 'false is not Number');
|
---|
| 11 | t.notOk(isNumber(true), 'true is not Number');
|
---|
| 12 | t.notOk(isNumber('foo'), 'string is not Number');
|
---|
| 13 | t.notOk(isNumber([]), 'array is not Number');
|
---|
| 14 | t.notOk(isNumber({}), 'object is not Number');
|
---|
| 15 | t.notOk(isNumber(function () {}), 'function is not Number');
|
---|
| 16 | t.notOk(isNumber(/a/g), 'regex literal is not Number');
|
---|
| 17 | t.notOk(isNumber(new RegExp('a', 'g')), 'regex object is not Number');
|
---|
| 18 | t.notOk(isNumber(new Date()), 'new Date() is not Number');
|
---|
| 19 | t.end();
|
---|
| 20 | });
|
---|
| 21 |
|
---|
| 22 | test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
|
---|
| 23 | var fakeNumber = {
|
---|
| 24 | toString: function () { return '7'; },
|
---|
| 25 | valueOf: function () { return 42; }
|
---|
| 26 | };
|
---|
| 27 | fakeNumber[Symbol.toStringTag] = 'Number';
|
---|
| 28 | t.notOk(isNumber(fakeNumber), 'fake Number with @@toStringTag "Number" is not Number');
|
---|
| 29 | t.end();
|
---|
| 30 | });
|
---|
| 31 |
|
---|
| 32 | test('Numbers', function (t) {
|
---|
| 33 | t.ok(isNumber(42), 'number is Number');
|
---|
| 34 | t.ok(isNumber(Object(42)), 'number object is Number');
|
---|
| 35 | t.ok(isNumber(NaN), 'NaN is Number');
|
---|
| 36 | t.ok(isNumber(Infinity), 'Infinity is Number');
|
---|
| 37 | t.end();
|
---|
| 38 | });
|
---|