MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 36 lines 971 B view raw
1// Test timer list mutation during callback execution 2// This tests the case where a setTimeout callback adds new timers 3 4let results = []; 5let expected = ['timer1', 'timer2', 'timer3', 'done']; 6 7// Timer 1 fires and adds timer 2 at head of list 8setTimeout(() => { 9 results.push('timer1'); 10 11 // Add a new timer with 0ms delay - inserts at head of timer list 12 setTimeout(() => { 13 results.push('timer2'); 14 15 // Add another timer from within timer2 16 setTimeout(() => { 17 results.push('timer3'); 18 }, 0); 19 }, 0); 20}, 10); 21 22// Final check after all timers should have fired 23setTimeout(() => { 24 results.push('done'); 25 26 const passed = JSON.stringify(results) === JSON.stringify(expected); 27 console.log('Results:', JSON.stringify(results)); 28 console.log('Expected:', JSON.stringify(expected)); 29 console.log('Test:', passed ? 'PASSED' : 'FAILED'); 30 31 if (!passed) { 32 process.exit(1); 33 } 34}, 100); 35 36console.log('Timer mutation test started...');