Permalink
Browse files

tests for async benchmarks

  • Loading branch information...
1 parent 86afe05 commit c0eac552f404d3eb43a3f0a1b05b27e77317d6e5 @brianc committed Dec 23, 2010
Showing with 32 additions and 1 deletion.
  1. +31 −0 test/initial-tests.js
  2. +1 −1 test/test-helper.js
View
@@ -85,3 +85,34 @@ test('multiple actions', function() {
})
})
+
+var timeout = 10;
+var calls = 0;
+test('async actions', function() {
+ var bm = bench({
+ name: 'async bench',
+ repeat: 20,
+ actions:[{
+ name: 'first',
+ run: function(next) {
+ setTimeout(function() {
+ test('timeout', function() {
+ calls++;
+ next();
+ })
+ }, timeout+=5)
+ }
+ },{
+ name: 'second',
+ run: function(next) {
+ test('executed after first action', function() {
+ calls.should.be.greaterThan(19)
+ })
+ next();
+ }
+ }]
+ })
+ bm(should.call(function() {
+ calls.should.equal(20)
+ }))
+})
View
@@ -5,7 +5,7 @@ var assert = require('assert');
Assertion.prototype.call = function(method, timeout) {
var called = false
- timeout = timeout || 100;
+ timeout = timeout || 10000;
var id = setTimeout(function() {
assert.ok(false, "Timeout wasn't called within " + timeout);
}, timeout)

0 comments on commit c0eac55

Please sign in to comment.