Project rename

This commit is contained in:
2019-03-24 08:28:57 +01:00
parent 1728e0e6e1
commit 7926230faf
7262 changed files with 0 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
--require coffee-script/register
--compilers coffee:coffee-script/register
--reporter spec
@@ -0,0 +1,38 @@
assert = require "assert"
delay = (ms, fn) -> setTimeout fn, ms
now = undefined
describe "now", ->
it "initially gives a near zero (< 20 ms) time ", ->
now = require "../"
assert now() < 20
it "gives a positive time", ->
assert now() > 0
it "two subsequent calls return an increasing number", ->
a = now()
b = now()
assert now() < now()
it "has less than 10 microseconds overhead", ->
Math.abs(now() - now()) < 0.010
it "can do 1,000,000 calls really quickly", ->
now() for i in [0...1000000]
it "shows that at least 990 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) lower than 990." if diff < 990
return done null
it "shows that not more than 1020 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) higher than 1020." if diff > 1020
return done null
@@ -0,0 +1,65 @@
(function() {
var assert, delay, now;
assert = require("assert");
delay = function(ms, fn) {
return setTimeout(fn, ms);
};
now = void 0;
describe("now", function() {
it("initially gives a near zero (< 20 ms) time ", function() {
now = require("../");
return assert(now() < 20);
});
it("gives a positive time", function() {
return assert(now() > 0);
});
it("two subsequent calls return an increasing number", function() {
var a, b;
a = now();
b = now();
return assert(now() < now());
});
it("has less than 10 microseconds overhead", function() {
return Math.abs(now() - now()) < 0.010;
});
it("can do 1,000,000 calls really quickly", function() {
var i, j, results;
results = [];
for (i = j = 0; j < 1000000; i = ++j) {
results.push(now());
}
return results;
});
it("shows that at least 990 ms has passed after a timeout of 1 second", function(done) {
var a;
a = now();
return delay(1000, function() {
var b, diff;
b = now();
diff = b - a;
if (diff < 990) {
return done(new Error("Diff (" + diff + ") lower than 990."));
}
return done(null);
});
});
return it("shows that not more than 1020 ms has passed after a timeout of 1 second", function(done) {
var a;
a = now();
return delay(1000, function() {
var b, diff;
b = now();
diff = b - a;
if (diff > 1020) {
return done(new Error("Diff (" + diff + ") higher than 1020."));
}
return done(null);
});
});
});
}).call(this);