import asyncio
import pytest
from ezaudit import monitor


@monitor
async def quick_task(val, delay):
    await asyncio.sleep(delay)
    return val


@pytest.mark.asyncio
async def test_concurrent_execution():
    """Verify that multiple tasks don't corrupt each other's memory tracking."""
    # Run 3 tasks with different delays at the same time
    results = await asyncio.gather(
        quick_task("A", 0.2),
        quick_task("B", 0.1),
        quick_task("C", 0.3)
    )
    assert results == ["A", "B", "C"]
