Bringing setTimeout to ECMAScript

Kyle Simpson getify at gmail.com
Sun Mar 20 09:14:49 PDT 2011


>> I don't see why "you can't verify your expectation".
> If you think you can verify your expectation, please write ECMAScript
> interoperable test cases that show how to test whether an ECMAScript
> engine is conform to your scheduling policy or not. It will be enough to
> convince me.
> Testing one timer ("When you do a setTimeout( f, ms ) you know you are
> saying "fire this @ t >= Date.now() + ms" ") will not be difficult.
> Testing your scheduling policy is a different story.

Forgive my naivety, but would it not be possible to test such a scheduling 
policy with something like this:

var test = 1;

function a() {
   test *= -1;
}
function b() {
   assertEquals(test,-1);
}

setTimeout(a,0);
for(i=0;i<1E10;i++){i=i;}  // or any other sufficiently long running 
algorithm
setTimeout(b,0);


--Kyle 



More information about the es-discuss mailing list