Something went wrong. Try again.
javascript for 🐜's, a tiny runtime with big ambitions antjs.org
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637// Test timer list mutation during callback execution// This tests the case where a setTimeout callback adds new timers
let results = [];let expected = ['timer1', 'timer2', 'timer3', 'done'];
// Timer 1 fires and adds timer 2 at head of listsetTimeout(() => { results.push('timer1'); // Add a new timer with 0ms delay - inserts at head of timer list setTimeout(() => { results.push('timer2'); // Add another timer from within timer2 setTimeout(() => { results.push('timer3'); }, 0); }, 0);}, 10);
// Final check after all timers should have firedsetTimeout(() => { results.push('done'); const passed = JSON.stringify(results) === JSON.stringify(expected); console.log('Results:', JSON.stringify(results)); console.log('Expected:', JSON.stringify(expected)); console.log('Test:', passed ? 'PASSED' : 'FAILED'); if (!passed) { process.exit(1); }}, 100);
console.log('Timer mutation test started...');