snapshot before regression test

This commit is contained in:
t
2026-07-18 19:25:40 +08:00
commit 796222a300
2295 changed files with 206453 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
import stdio
import t, c
# ============================================================
# 命名空间隔离测试:定义类模块
#
# 本文件定义供其他文件 import 使用的类,验证跨模块命名空间隔离:
# - 裸名 Class(): 需要 from namespace_defs import Class
# - 模块限定 namespace_defs.Class(): 需要 import namespace_defs
# ============================================================
# ============================================================
# 带虚表的类 Widget
# ============================================================
@t.CVTable
class Widget:
id: t.CInt
def __init__(self, i: t.CInt):
self.id = i
def GetId(self) -> t.CInt:
return self.id
def Render(self) -> t.CInt:
return 100
# ============================================================
# 子类 Gadget继承 Widget覆盖 Render
# ============================================================
class Gadget(Widget):
extra: t.CInt
def __init__(self, i: t.CInt, e: t.CInt):
self.id = i
self.extra = e
def Render(self) -> t.CInt:
return 200
def GetExtra(self) -> t.CInt:
return self.extra
# ============================================================
# 普通结构体 PlainStruct无虚表
# ============================================================
class PlainStruct:
x: t.CInt
y: t.CInt
def __init__(self, ax: t.CInt, ay: t.CInt):
self.x = ax
self.y = ay
def Sum(self) -> t.CInt:
return self.x + self.y