chore(test): 初始化回归测试仓(新增 .gitignore,TestsOverview.md 改为 README.md)

把 Test/ 纳入 https://git.gvsds.com/GVSDS/Viper_RegressionTesting 。

1) 新增 .gitignore —— 只保留测试源码,剔除全部构建产物:
   目录   **/output*/(output / output_opt / output_orig / output_verify / output_dbg)、
          **/temp*/(temp / temp_opt)、**/.tpv_build/
   二进制 *.exe *.obj *.o *.out *.a *.lib *.dll
   中间物 *.ll *.vpi *.pyi *.deps.txt *.deps.json *.doc.json *_sha1_map.txt
          _pyi_cache_v1.pkl _pyi_cache_v1.sig.json _shared_sym.json _phase1_manifest.json
   其它   build_all.txt(构建日志)、*.log、__pycache__/、*.bak、IDE 目录
   保留   App/*.vp、project.json / project_opt.json / project.vpj、README.md、两个 .py
   实测 `git add -A --dry-run`:196 个文件,无任何构建产物混入。

2) TestsOverview.md → README.md(作为仓库首页文档)。

3) SequentialRegressionTest.py:7 处 TestsOverview.md 引用同步改为 README.md
   (文档串、OVERVIEW 路径、read_test_order 文档与报错文案、argparse description、
   启动横幅);同时修正入口路径 PROJECTRANS —— 旧值 <root>/Projectrans.py 已不存在,
   改为 <root>/TransPyC/Projectrans.py(与 regression_test.py:45-48 记录一致),
   否则本脚本会以 "can't open file" 全量失败。
   regression_test.py 无需改动:它按目录扫描 project.json 找项目,不引用该文档。
This commit is contained in:
TermiNexus committed 2026-09-29 15:14:59 +08:00
commit 3c6fb1d246
196 files changed
+24775

No files matched your search

+120
View File
@@ -0,0 +1,120 @@
from stdint import *
import t, c
from t import CPtr, CInt, CExport
import testcheck
# ============================================================
# super() 语义专项测试(由 TransPyV.exe 编译)
#
# 覆盖场景:
# 1. super().__init__(args) — 子类构造调父类构造(字段由父类设置)
# 2. super().method() 静态绑定父类实现(不触发子类 override / 虚分派)
# 3. super() 调未覆盖的父类方法(父类字段区前缀对齐,this 无需调整)
# 4. 三层继承链 super().__init__(Leaf → Mid → Grand 逐层传递,
# 每个中间类的 super() 沿各自 CurClassName 的 MRO 跳自身找父类)
# 5. super().method 沿 MRO 找实际定义类(Mid 未定义 Base → 找到 Grand.Base)
# ============================================================
# ========== 单继承:super().__init__ + super().method ==========
@t.CVTable
class Animal:
Tag: CInt
def __init__(self, tag: CInt):
self.Tag = tag
def Speak(self) -> CInt:
return 0
def Greet(self) -> CInt:
return self.Tag + 1000
@t.CVTable
class Dog(Animal):
Breed: CInt
def __init__(self, tag: CInt, breed: CInt):
super().__init__(tag) # 调 Animal.__init__ 设置 Tag
self.Breed = breed
def Speak(self) -> CInt:
return 1
def ParentSpeak(self) -> CInt:
return super().Speak() # 静态绑定 Animal.Speak → 0(不走虚分派)
def FullGreet(self) -> CInt:
# super() 调父类 Greet(Dog 未覆盖),再加自身字段
return super().Greet() + self.Breed
# ========== 三层继承链:Grand → Mid → Leaf ==========
@t.CVTable
class Grand:
G: CInt
def __init__(self, v: CInt):
self.G = v
def Base(self) -> CInt:
return self.G
@t.CVTable
class Mid(Grand):
M: CInt
def __init__(self, v: CInt):
super().__init__(v + 1) # 调 Grand.__init__
self.M = v
def MidOnly(self) -> CInt:
return self.M
@t.CVTable
class Leaf(Mid):
def __init__(self, v: CInt):
super().__init__(v + 2) # 调 Mid.__init__(Mid 内部再 super 到 Grand)
def GetBase(self) -> CInt:
return super().Base() # Mid 未定义 Base → 沿 MRO 找 Grand.Base
def CallMidOnly(self) -> CInt:
return super().MidOnly() # 调 Mid.MidOnly
def main() -> CInt | CExport:
testcheck.begin("SuperTest: super() 语义测试")
# --- 1. super().__init__ 设置父类字段 ---
d: Dog | CPtr = Dog(42, 7)
testcheck.check(d.Tag == 42, "super().__init__ 设置父类字段 OK",
"super().__init__ FAILED")
testcheck.check(d.Breed == 7, "子类字段 OK", "子类字段 FAILED")
# --- 2. super().method 静态绑定(不虚分派到子类 override) ---
testcheck.check(d.ParentSpeak() == 0, "super().Speak() 静态绑定父类 OK",
"super().Speak() FAILED")
testcheck.check(d.Speak() == 1, "子类 Speak() override OK", "Speak() FAILED")
# --- 3. super() 调未覆盖的父类方法(42+1000+7 = 1049) ---
testcheck.check(d.FullGreet() == 1049, "super() 调未覆盖父类方法 OK",
"FullGreet() FAILED")
# --- 4. 三层继承链 super().__init__(Leaf(10) → Mid(12) → Grand(13)) ---
lf: Leaf | CPtr = Leaf(10)
testcheck.check(lf.G == 13, "三层 super().__init__ 链 G OK", "三层 G FAILED")
testcheck.check(lf.M == 12, "中间类 M OK", "中间类 M FAILED")
# --- 5. super().method 沿 MRO 找实际定义类 ---
testcheck.check(lf.GetBase() == 13, "super().Base() 沿 MRO OK", "GetBase() FAILED")
testcheck.check(lf.CallMidOnly() == 12, "super().MidOnly() OK", "CallMidOnly() FAILED")
testcheck.ok("super() 全部测试完成")
return testcheck.end()