···11+// Test timer list mutation during callback execution
22+// This tests the case where a setTimeout callback adds new timers
33+44+let results = [];
55+let expected = ['timer1', 'timer2', 'timer3', 'done'];
66+77+// Timer 1 fires and adds timer 2 at head of list
88+setTimeout(() => {
99+ results.push('timer1');
1010+1111+ // Add a new timer with 0ms delay - inserts at head of timer list
1212+ setTimeout(() => {
1313+ results.push('timer2');
1414+1515+ // Add another timer from within timer2
1616+ setTimeout(() => {
1717+ results.push('timer3');
1818+ }, 0);
1919+ }, 0);
2020+}, 10);
2121+2222+// Final check after all timers should have fired
2323+setTimeout(() => {
2424+ results.push('done');
2525+2626+ const passed = JSON.stringify(results) === JSON.stringify(expected);
2727+ console.log('Results:', JSON.stringify(results));
2828+ console.log('Expected:', JSON.stringify(expected));
2929+ console.log('Test:', passed ? 'PASSED' : 'FAILED');
3030+3131+ if (!passed) {
3232+ process.exit(1);
3333+ }
3434+}, 100);
3535+3636+console.log('Timer mutation test started...');