-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
74 additions
and
194 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 @@ | ||
exports.int = require('./int') |
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,7 @@ | ||
var hash = require('string-hash') | ||
var stringify = require('fast-json-stable-stringify') | ||
|
||
module.exports = function int (inputs) { | ||
// todo: cache `inputs` using a WeakMap | ||
return hash(stringify(inputs)) | ||
} |
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
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,12 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`tests/fictional.test.js TAP generated values > must match snapshot 1`] = ` | ||
Object { | ||
"int": 5859428, | ||
} | ||
` |
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 |
---|---|---|
@@ -1,3 +1,34 @@ | ||
const fictional = require('..') | ||
const tap = require('tap') | ||
|
||
tap.equal(true, true) | ||
const types = getTypes() | ||
|
||
tap.test('generated values', t => { | ||
t.matchSnapshot(callTypes(23)) | ||
t.end() | ||
}) | ||
|
||
tap.test('consistency', t => { | ||
let i = -1 | ||
const firstResult = callTypes(23) | ||
|
||
while (++i < 100) { | ||
t.deepEquals(callTypes(23), firstResult) | ||
} | ||
|
||
t.end() | ||
}) | ||
|
||
function callTypes(input) { | ||
const result = {} | ||
|
||
for (const name of Object.keys(types)) { | ||
result[name] = types[name](input) | ||
} | ||
|
||
return result | ||
} | ||
|
||
function getTypes() { | ||
return fictional | ||
} |
Oops, something went wrong.