-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4ed25c
commit 41cdf6b
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'); | ||
var functionsHaveNames = require('functions-have-names')(); | ||
|
||
var implementation = require('../implementation'); | ||
var runTests = require('./tests'); | ||
|
||
test('implementation', function (t) { | ||
t.equal(implementation.length, 1, 'implementation has a length of 1'); | ||
|
||
t.test('Function name', { skip: !functionsHaveNames }, function (st) { | ||
st.equal(implementation.name, 'isFinite', 'implementation has name "isFinite"'); | ||
st.end(); | ||
}); | ||
|
||
runTests(implementation, t); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
var isFinite = require('../'); | ||
var test = require('tape'); | ||
var runTests = require('./tests'); | ||
|
||
test('as a function', function (t) { | ||
runTests(isFinite, t); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import isFinite, * as isFiniteModule from 'number.isfinite'; | ||
import test from 'tape'; | ||
import runTests from './tests.js'; | ||
|
||
test('as a function', (t) => { | ||
runTests(isFinite, t); | ||
|
||
t.end(); | ||
}); | ||
|
||
test('named exports', async (t) => { | ||
t.deepEqual( | ||
Object.keys(isFiniteModule).sort(), | ||
['default', 'shim', 'getPolyfill', 'implementation'].sort(), | ||
'has expected named exports', | ||
); | ||
|
||
const { shim, getPolyfill, implementation } = isFiniteModule; | ||
t.equal(await import('number.isfinite/shim'), shim, 'shim named export matches deep export'); | ||
t.equal(await import('number.isfinite/implementation'), implementation, 'implementation named export matches deep export'); | ||
t.equal(await import('number.isfinite/polyfill'), getPolyfill, 'getPolyfill named export matches deep export'); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
require('../shim')(); | ||
|
||
var test = require('tape'); | ||
var defineProperties = require('define-properties'); | ||
var isEnumerable = Object.prototype.propertyIsEnumerable; | ||
var functionsHaveNames = require('functions-have-names')(); | ||
|
||
var runTests = require('./tests'); | ||
|
||
test('shimmed', function (t) { | ||
t.equal(Number.isFinite.length, 1, 'Number.isFinite has a length of 1'); | ||
|
||
t.test('Function name', { skip: !functionsHaveNames }, function (st) { | ||
st.equal(Number.isFinite.name, 'isFinite', 'Number.isFinite has name "isFinite"'); | ||
st.end(); | ||
}); | ||
|
||
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) { | ||
et.equal(false, isEnumerable.call(Math, 'isFinite'), 'Number.isFinite is not enumerable'); | ||
et.end(); | ||
}); | ||
|
||
runTests(Number.isFinite, t); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = function (isFinite, t) { | ||
t.test('Number.isFinite', function (st) { | ||
st.equal(isFinite(Infinity), false); | ||
st.equal(isFinite(-Infinity), false); | ||
st.equal(isFinite(NaN), false); | ||
st.equal(isFinite(4), true); | ||
st.equal(isFinite(-4), true); | ||
st.equal(isFinite(4.5), true); | ||
st.equal(isFinite('hi'), false); | ||
st.equal(isFinite('1.3'), false); | ||
st.equal(isFinite('51'), false); | ||
st.equal(isFinite(0), true); | ||
st.equal(isFinite(-0), true); | ||
st.equal(isFinite({ valueOf: function () { return 3; } }), false); | ||
st.equal(isFinite({ valueOf: function () { throw new Error(); } }), false); | ||
|
||
st.end(); | ||
}); | ||
}; |