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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: appengine/config_service/ui/bower_components/async/mocha_test/forever.js
diff --git a/appengine/config_service/ui/bower_components/async/mocha_test/forever.js b/appengine/config_service/ui/bower_components/async/mocha_test/forever.js
new file mode 100644
index 0000000000000000000000000000000000000000..970c42289b01d5528dd16b290696d92e8dbaf647
--- /dev/null
+++ b/appengine/config_service/ui/bower_components/async/mocha_test/forever.js
@@ -0,0 +1,44 @@
+var async = require('../lib/async');
+var expect = require('chai').expect;
+var 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(done){
+ var counter = 0;
+ function addOne(callback) {
+ counter++;
+ if (counter === 50) {
+ return callback('too big!');
+ }
+ async.setImmediate(function () {
+ callback();
+ });
+ }
+ async.forever(addOne, function (err) {
+ expect(err).to.eql('too big!');
+ expect(counter).to.eql(50);
+ done();
+ });
+ });
+ });
+
+ context('function is synchronous', function(){
+ it('does not cause a stack overflow', function(done){
+ if (isBrowser()) return done(); // this will take forever in a browser
+ var counter = 0;
+ function addOne(callback) {
+ counter++;
+ if (counter === 50000) { // needs to be huge to potentially overflow stack in node
+ return callback('too big!');
+ }
+ callback();
+ }
+ async.forever(addOne, function (err) {
+ expect(err).to.eql('too big!');
+ expect(counter).to.eql(50000);
+ done();
+ });
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698