This commit is contained in:
eric sciple 2020-01-24 12:20:47 -05:00
parent a004f0ae58
commit fc725ba36b
7280 changed files with 19 additions and 1796407 deletions

View file

@ -1,3 +0,0 @@
--require coffee-script/register
--compilers coffee:coffee-script/register
--reporter spec

View file

@ -1,43 +0,0 @@
chai = require "chai"
chai.use(require "chai-increasing")
{assert,expect} = chai
Bluebird = require "bluebird"
now = require "../"
getUptime = -> process.uptime() * 1e3
describe "now", ->
it "reported time differs at most 1ms from a freshly reported uptime", ->
assert.isAtMost Math.abs(now()-getUptime()), 1
it "two subsequent calls return an increasing number", ->
assert.isBelow now(), now()
it "has less than 10 microseconds overhead", ->
assert.isBelow Math.abs(now() - now()), 0.010
it "can be called 1 million times in under 1 second (averaging under 1 microsecond per call)", ->
@timeout 1000
now() for [0...1e6]
undefined
it "for 10,000 numbers, number n is never bigger than number n-1", ->
stamps = (now() for [1...10000])
expect(stamps).to.be.increasing
it "shows that at least 0.2 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isAbove (now()-earlier), 0.2
it "shows that at most 3 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isBelow (now()-earlier), 3
it "shows that at least 190ms ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isAbove (now()-earlier), 190
it "shows that at most 220 ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isBelow (now()-earlier), 220

View file

@ -1,27 +0,0 @@
Bluebird = require "bluebird"
exec = require("child_process").execSync
{assert} = require "chai"
describe "scripts/initital-value.coffee (module.uptime(), expressed in milliseconds)", ->
result = exec("./test/scripts/initial-value.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 100", -> assert.isAbove result, 100
it "printed a value below 350", -> assert.isBelow result, 350
describe "scripts/delayed-require.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-require.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/delayed-call.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-call.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/difference.coffee", ->
result = exec("./test/scripts/difference.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 0.005", -> assert.isAbove result, 0.005
it "printed a value below 0.07", -> assert.isBelow result, 0.07

View file

@ -1,11 +0,0 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
now = require "../../lib/performance-now"
delay 250, -> console.log now().toFixed 3

View file

@ -1,12 +0,0 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
delay 250, ->
now = require "../../lib/performance-now"
console.log now().toFixed 3

View file

@ -1,6 +0,0 @@
#!/usr/bin/env ./node_modules/.bin/coffee
# Expected output is above 0.005 and below 0.07.
now = require('../../lib/performance-now')
console.log -(now() - now()).toFixed 3

View file

@ -1,10 +0,0 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 100 and below 350.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
now = require '../../lib/performance-now'
console.log now().toFixed 3