var async=require("../lib/async"),expect=require("chai").expect,isBrowser=require("./support/is_browser");describe("forever",function(){context("function is asynchronous",function(){it("executes the function over and over until it yields an error",function(e){function o(e){return t++,50===t?e("too big!"):void async.setImmediate(function(){e()})}var t=0;async.forever(o,function(o){expect(o).to.eql("too big!"),expect(t).to.eql(50),e()})})}),context("function is synchronous",function(){it("does not cause a stack overflow",function(e){function o(e){return t++,5e4===t?e("too big!"):void e()}if(isBrowser())return e();var t=0;async.forever(o,function(o){expect(o).to.eql("too big!"),expect(t).to.eql(5e4),e()})})})});