Files
Viper_RegressionTesting/CoroTest/App/main.vp
T
TermiNexus 44ce29200e refactor(test): 收尾 6 个测试用例的新规范语法迁移
CoroTest/DefaultArgTest/FormatStringTest/FuncTest/MLIRLiteTest/ThreadingTest 的 App/main.vp 从旧写法(t.CInt/t.CPtr 注解、多行单语句体)迁到新规范(int 短别名、T* 后缀、单语句体并一行),为既有迁移的遗留未提交部分。验证:TPV 自举产物顺序回归 77/77 全通过。
2026-10-05 09:24:42 +08:00

41 lines
786 B
Plaintext

import t, c
from stdint import *
import stdio
import coro
class MyError(Exception):
pass
async def leaf(x: int) -> int:
return x + 1
async def boom() -> int:
raise MyError("boom msg")
return 0
async def task() -> int:
fin: int = 0
try:
fin = 1
await boom()
finally:
fin = fin + 1
stdio.printf("finally ran, fin = %d\n", fin)
return 99
def main() -> t.CInt:
n: t.CInt = 0
for i in range(3):
tt: coro.Coroutine = coro.Coroutine(*&task())
r: t.CInt = coro.coro_run(tt)
e: t.CInt = coro.coro_exception(tt)
m: t.CPtr = coro.coro_exception_msg(tt)
stdio.printf("[%d] r = %d, exc = %d, msg = %s\n", i, r, e, m)
coro.coro_destroy(tt)
n = n + 1
return 0