"""
Exercise 1: async def, await, and asyncio.run (easy)

STEP 1: Implement `fetch_greeting(name)` — an async function that
        `await`s `asyncio.sleep(0.05)` (simulating I/O), then returns
        f"hello, {name}".

STEP 2: Implement `fetch_two_greetings(name_a, name_b)` — an async function
        that awaits `fetch_greeting` for name_a, THEN awaits it again for
        name_b (sequentially, one after the other — do not use gather
        here, that's the next exercise), and returns a tuple of both
        results in order: (greeting_a, greeting_b).
"""

import asyncio


async def fetch_greeting(name):
    # TODO: await asyncio.sleep(0.05), then return f"hello, {name}"
    pass


async def fetch_two_greetings(name_a, name_b):
    # TODO: await fetch_greeting(name_a), then await fetch_greeting(name_b),
    # return (result_a, result_b)
    pass


# --- self-check: do not modify below this line ---
checks = []

single_result = asyncio.run(fetch_greeting("ana"))
checks.append(("fetch_greeting returns formatted string", single_result, "hello, ana"))

raw_call = fetch_greeting("bob")
checks.append(("calling an async def returns a coroutine object, not a string",
                asyncio.iscoroutine(raw_call), True))
raw_call.close()  # avoid a "never awaited" warning for this intentionally-unused coroutine

pair_result = asyncio.run(fetch_two_greetings("x", "y"))
checks.append(("fetch_two_greetings returns both results in order",
                pair_result, ("hello, x", "hello, y")))

passed = 0
for label, actual, expected in checks:
    ok = actual == expected
    passed += ok
    print(f"{'PASS' if ok else 'FAIL'}: {label} (got {actual!r}, expected {expected!r})")

print("PASS" if passed == len(checks) else "FAIL")
