Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: appengine/config_service/ui/bower_components/async/mocha_test/forever.js

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var async = require('../lib/async');
2 var expect = require('chai').expect;
3 var isBrowser = require('./support/is_browser');
4
5 describe('forever', function(){
6 context('function is asynchronous', function(){
7 it('executes the function over and over until it yields an error', funct ion(done){
8 var counter = 0;
9 function addOne(callback) {
10 counter++;
11 if (counter === 50) {
12 return callback('too big!');
13 }
14 async.setImmediate(function () {
15 callback();
16 });
17 }
18 async.forever(addOne, function (err) {
19 expect(err).to.eql('too big!');
20 expect(counter).to.eql(50);
21 done();
22 });
23 });
24 });
25
26 context('function is synchronous', function(){
27 it('does not cause a stack overflow', function(done){
28 if (isBrowser()) return done(); // this will take forever in a brows er
29 var counter = 0;
30 function addOne(callback) {
31 counter++;
32 if (counter === 50000) { // needs to be huge to potentially over flow stack in node
33 return callback('too big!');
34 }
35 callback();
36 }
37 async.forever(addOne, function (err) {
38 expect(err).to.eql('too big!');
39 expect(counter).to.eql(50000);
40 done();
41 });
42 });
43 });
44 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698