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:
commit
3c6fb1d246
196 files changed
+24775
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import t, c
|
||||
|
||||
|
||||
POSMAX: t.CDefine = 100
|
||||
MAX_RETRY: t.CDefine = 5
|
||||
BUFFER_SIZE: t.CDefine = 256
|
||||
PI: t.CDefine = 3.14159
|
||||
EULER: t.CDefine = 2.71828
|
||||
TRUE: t.CDefine = 1
|
||||
FALSE: t.CDefine = 0
|
||||
NULL: t.CDefine = 0
|
||||
|
||||
|
||||
MATH_OFFSET: t.CDefine = 10
|
||||
MATH_SCALE: t.CDefine = 2
|
||||
THRESHOLD: t.CDefine = 50
|
||||
LOOP_LIMIT: t.CDefine = 20
|
||||
SHIFT_AMOUNT: t.CDefine = 2
|
||||
MASK_VALUE: t.CDefine = 0xFF
|
||||
BIT_RANGE: t.CDefine = 4
|
||||
EXPONENT_BASE: t.CDefine = 3
|
||||
MODULO_DIVISOR: t.CDefine = 7
|
||||
SCALE_SHIFT: t.CDefine = 4
|
||||
HALF_SCALE: t.CDefine = 0.5
|
||||
@@ -0,0 +1,372 @@
|
||||
import config
|
||||
import t, c
|
||||
|
||||
|
||||
def ForRangeBasicTest(stop: t.CInt):
|
||||
i: t.CInt = 0
|
||||
for i in range(stop):
|
||||
print("For range: ", i)
|
||||
print("Done")
|
||||
|
||||
|
||||
def ForRangeWithStartStop(start: t.CInt, stop: t.CInt, step: t.CInt):
|
||||
i: t.CInt = 0
|
||||
for i in range(start, stop, step):
|
||||
print("Range: ", i)
|
||||
print("Done")
|
||||
|
||||
|
||||
def NestedForRangeTest(rows: t.CInt, cols: t.CInt):
|
||||
r: t.CInt = 0
|
||||
c_val: t.CInt = 0
|
||||
for r in range(rows):
|
||||
for c_val in range(cols):
|
||||
print("Cell: ", r, c_val)
|
||||
print("Grid done")
|
||||
|
||||
|
||||
def ForWithIfBreakTest(data_size: t.CInt):
|
||||
i: t.CInt = 0
|
||||
found: t.CInt = 0
|
||||
for i in range(data_size):
|
||||
if i == 5:
|
||||
print("Found at: ", i)
|
||||
found = 1
|
||||
break
|
||||
print("Checking: ", i)
|
||||
if found == 0:
|
||||
print("Not found")
|
||||
|
||||
|
||||
def ForWithIfContinueTest(n: t.CInt):
|
||||
i: t.CInt = 0
|
||||
count: t.CInt = 0
|
||||
for i in range(n):
|
||||
if i % 2 == 0:
|
||||
continue
|
||||
print("Odd: ", i)
|
||||
count += 1
|
||||
print("Total odd: ", count)
|
||||
|
||||
|
||||
def ForWithElifBranchTest(value: t.CInt):
|
||||
i: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
for i in range(value):
|
||||
if i < 3:
|
||||
result += 1
|
||||
elif i < 6:
|
||||
result += 2
|
||||
elif i < 9:
|
||||
result += 3
|
||||
else:
|
||||
result += 4
|
||||
print("Elif branch result: ", result)
|
||||
|
||||
|
||||
def WhileWithIfElifElseTest(iterations: t.CInt):
|
||||
counter: t.CInt = 0
|
||||
while counter < iterations:
|
||||
if counter < 2:
|
||||
print("Phase 1: ", counter)
|
||||
elif counter < 4:
|
||||
print("Phase 2: ", counter)
|
||||
elif counter < 6:
|
||||
print("Phase 3: ", counter)
|
||||
else:
|
||||
print("Phase 4: ", counter)
|
||||
counter += 1
|
||||
print("While done")
|
||||
|
||||
|
||||
def WhileWithNestedIfTest(limit: t.CInt):
|
||||
outer: t.CInt = 0
|
||||
while outer < limit:
|
||||
inner: t.CInt = 0
|
||||
while inner < limit:
|
||||
if inner == 2 and outer == 1:
|
||||
print("Target: ", outer, inner)
|
||||
inner += 1
|
||||
continue
|
||||
if inner > 3:
|
||||
break
|
||||
print("Inner: ", inner)
|
||||
inner += 1
|
||||
outer += 1
|
||||
|
||||
|
||||
def WhileWithMatchCaseTest(value: t.CInt):
|
||||
result: t.CInt = 0
|
||||
match value:
|
||||
case 1:
|
||||
result = 100
|
||||
print("Case 1")
|
||||
case 2:
|
||||
result = 200
|
||||
print("Case 2")
|
||||
case 3:
|
||||
result = 300
|
||||
print("Case 3")
|
||||
case _:
|
||||
result = 999
|
||||
print("Default case")
|
||||
print("Match result: ", result)
|
||||
|
||||
|
||||
def WhileWithMatchCaseNoBreakTest(value: t.CInt):
|
||||
result: t.CInt = 0
|
||||
match value:
|
||||
case 1:
|
||||
result = 10
|
||||
print("Case 1: ", result)
|
||||
case 2:
|
||||
result = 20
|
||||
print("Case 2: ", result)
|
||||
result += 5
|
||||
case 3:
|
||||
result = 30
|
||||
print("Case 3: ", result)
|
||||
case _:
|
||||
result = 0
|
||||
print("No break match result: ", result)
|
||||
|
||||
|
||||
def ComplexForWhileMatchTest(outer_limit: t.CInt, inner_limit: t.CInt):
|
||||
i: t.CInt = 0
|
||||
j: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
for i in range(outer_limit):
|
||||
j = 0
|
||||
while j < inner_limit:
|
||||
match (i, j):
|
||||
case (0, 0):
|
||||
result += 1
|
||||
case (1, 1):
|
||||
result += 10
|
||||
case (2, _):
|
||||
result += 100
|
||||
case (_, 0):
|
||||
result += 1000
|
||||
case _:
|
||||
result += 10000
|
||||
j += 1
|
||||
print("Complex match result: ", result)
|
||||
|
||||
|
||||
def ForWithCaseAndNoBreakTest(n: t.CInt):
|
||||
i: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
for i in range(n):
|
||||
match i:
|
||||
case 0:
|
||||
result += 1
|
||||
case 1:
|
||||
result += 2
|
||||
case 2:
|
||||
result += 3
|
||||
result += 10
|
||||
case _:
|
||||
result += i
|
||||
c.NoBreak
|
||||
print("NoBreak result: ", result)
|
||||
|
||||
|
||||
def WhileWithBreakConditionTest(limit: t.CInt):
|
||||
i: t.CInt = 0
|
||||
early_exit: t.CInt = 0
|
||||
while i < limit:
|
||||
if i == 3:
|
||||
early_exit = 1
|
||||
break
|
||||
if i == 2:
|
||||
i += 1
|
||||
continue
|
||||
print("While i: ", i)
|
||||
i += 1
|
||||
|
||||
|
||||
def NestedWhileWithMultipleBreakPoints(depth: t.CInt, width: t.CInt):
|
||||
d: t.CInt = 0
|
||||
w: t.CInt = 0
|
||||
count: t.CInt = 0
|
||||
while d < depth:
|
||||
w = 0
|
||||
while w < width:
|
||||
if w == 2:
|
||||
break
|
||||
if d == 1 and w == 1:
|
||||
c.Break
|
||||
count += 1
|
||||
w += 1
|
||||
d += 1
|
||||
print("Nested break count: ", count)
|
||||
|
||||
|
||||
def ForWithMatchCaseInLoopTest(iterations: t.CInt):
|
||||
i: t.CInt = 0
|
||||
sum_even: t.CInt = 0
|
||||
sum_odd: t.CInt = 0
|
||||
for i in range(iterations):
|
||||
match i % 3:
|
||||
case 0:
|
||||
sum_even += i
|
||||
case 1:
|
||||
sum_odd += i
|
||||
case 2:
|
||||
sum_even += i * 2
|
||||
case _:
|
||||
pass
|
||||
print("Sum even: ", sum_even)
|
||||
print("Sum odd: ", sum_odd)
|
||||
|
||||
|
||||
def ComplexLogicWithElifChains(a: t.CInt, b: t.CInt, c_val: t.CInt):
|
||||
i: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
while i < 10:
|
||||
if i < a:
|
||||
if i < b:
|
||||
result += 1
|
||||
elif i < c_val:
|
||||
result += 2
|
||||
else:
|
||||
result += 3
|
||||
elif i < b:
|
||||
if i < c_val:
|
||||
result += 4
|
||||
else:
|
||||
result += 5
|
||||
elif i < c_val:
|
||||
result += 6
|
||||
else:
|
||||
result += 7
|
||||
i += 1
|
||||
print("Complex elif chain result: ", result)
|
||||
|
||||
|
||||
def ForRangeWithStepAndCondition(n: t.CInt, step: t.CInt):
|
||||
i: t.CInt = 0
|
||||
count: t.CInt = 0
|
||||
for i in range(0, n, step):
|
||||
if i % 2 == 0:
|
||||
print("Even step: ", i)
|
||||
count += 1
|
||||
else:
|
||||
if i > 5:
|
||||
print("Large odd: ", i)
|
||||
else:
|
||||
print("Small odd: ", i)
|
||||
print("Total steps: ", count)
|
||||
|
||||
|
||||
def MatchCaseWithGuardConditions(value: t.CInt):
|
||||
result: t.CInt = 0
|
||||
match value:
|
||||
case 1 if config.TRUE == 1:
|
||||
result = 100
|
||||
case 2 if config.FALSE == 0:
|
||||
result = 200
|
||||
case 3:
|
||||
result = 300
|
||||
case _:
|
||||
result = 0
|
||||
print("Guard match result: ", result)
|
||||
|
||||
|
||||
def WhileWithMultipleMatchCases(iterations: t.CInt):
|
||||
i: t.CInt = 0
|
||||
state: t.CInt = 0
|
||||
while i < iterations:
|
||||
match state:
|
||||
case 0:
|
||||
if i > 3:
|
||||
state = 1
|
||||
case 1:
|
||||
if i > 6:
|
||||
state = 2
|
||||
case 2:
|
||||
if i > 9:
|
||||
state = 0
|
||||
print("State at i=", i, ": ", state)
|
||||
i += 1
|
||||
|
||||
|
||||
def ForWhileMixWithBreakAndContinue(n: t.CInt):
|
||||
i: t.CInt = 0
|
||||
j: t.CInt = 0
|
||||
count: t.CInt = 0
|
||||
for i in range(n):
|
||||
j = 0
|
||||
while j < n:
|
||||
if j == 2:
|
||||
j += 1
|
||||
continue
|
||||
if i == 3 and j == 3:
|
||||
break
|
||||
count += 1
|
||||
j += 1
|
||||
print("Mix break continue count: ", count)
|
||||
|
||||
|
||||
def ComplexCaseMatchingWithRanges(start: t.CInt, end: t.CInt):
|
||||
i: t.CInt = 0
|
||||
bucket0: t.CInt = 0
|
||||
bucket1: t.CInt = 0
|
||||
bucket2: t.CInt = 0
|
||||
bucket3: t.CInt = 0
|
||||
for i in range(start, end):
|
||||
match i:
|
||||
case _ if i < 10:
|
||||
bucket0 += 1
|
||||
case _ if i < 20:
|
||||
bucket1 += 1
|
||||
case _ if i < 30:
|
||||
bucket2 += 1
|
||||
case _:
|
||||
bucket3 += 1
|
||||
print("Bucket0 (<10): ", bucket0)
|
||||
print("Bucket1 (10-19): ", bucket1)
|
||||
print("Bucket2 (20-29): ", bucket2)
|
||||
print("Bucket3 (>=30): ", bucket3)
|
||||
|
||||
|
||||
def WhileWithElifInElifChain(limit: t.CInt):
|
||||
i: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
while i < limit:
|
||||
if i < 2:
|
||||
if i == 0:
|
||||
result = 1
|
||||
else:
|
||||
result = 2
|
||||
elif i < 4:
|
||||
if i == 2:
|
||||
result = 3
|
||||
else:
|
||||
result = 4
|
||||
elif i < 6:
|
||||
if i == 4:
|
||||
result = 5
|
||||
else:
|
||||
result = 6
|
||||
else:
|
||||
result = 7
|
||||
print("Chain result[", i, "]: ", result)
|
||||
i += 1
|
||||
|
||||
|
||||
def ForWithCaseNoBreakNested(inner_limit: t.CInt):
|
||||
i: t.CInt = 0
|
||||
j: t.CInt = 0
|
||||
result: t.CInt = 0
|
||||
for i in range(3):
|
||||
for j in range(inner_limit):
|
||||
match j:
|
||||
case 0:
|
||||
result += 1
|
||||
case 1:
|
||||
result += 2
|
||||
case _:
|
||||
result += 3
|
||||
c.NoBreak
|
||||
print("Nested NoBreak result: ", result)
|
||||
@@ -0,0 +1,106 @@
|
||||
import t, c
|
||||
import config
|
||||
import logic_test
|
||||
import testcheck
|
||||
|
||||
|
||||
def main() -> t.CInt:
|
||||
testcheck.begin("LogicFlowTest: For/While/Match/控制流测试")
|
||||
|
||||
testcheck.section("For Range Basic Test (stop=5)")
|
||||
logic_test.ForRangeBasicTest(5)
|
||||
testcheck.ok("For Range Basic Test (5)")
|
||||
|
||||
testcheck.section("For Range With Start Stop Step (start=1, stop=10, step=2)")
|
||||
logic_test.ForRangeWithStartStop(1, 10, 2)
|
||||
testcheck.ok("For Range With Start Stop (1, 10, 2)")
|
||||
|
||||
testcheck.section("Nested For Range Test (rows=2, cols=3)")
|
||||
logic_test.NestedForRangeTest(2, 3)
|
||||
testcheck.ok("Nested For Range Test (2, 3)")
|
||||
|
||||
testcheck.section("For With If Break Test (size=8)")
|
||||
logic_test.ForWithIfBreakTest(8)
|
||||
testcheck.ok("For With If Break Test (8)")
|
||||
|
||||
testcheck.section("For With If Continue Test (n=10)")
|
||||
logic_test.ForWithIfContinueTest(10)
|
||||
testcheck.ok("For With If Continue Test (10)")
|
||||
|
||||
testcheck.section("For With Elif Branch Test (value=10)")
|
||||
logic_test.ForWithElifBranchTest(10)
|
||||
testcheck.ok("For With Elif Branch Test (10)")
|
||||
|
||||
testcheck.section("While With If Elif Else Test (iterations=7)")
|
||||
logic_test.WhileWithIfElifElseTest(7)
|
||||
testcheck.ok("While With If Elif Else Test (7)")
|
||||
|
||||
testcheck.section("While With Nested If Test (limit=4)")
|
||||
logic_test.WhileWithNestedIfTest(4)
|
||||
testcheck.ok("While With Nested If Test (4)")
|
||||
|
||||
testcheck.section("While With Match Case Test (value=2)")
|
||||
logic_test.WhileWithMatchCaseTest(2)
|
||||
testcheck.ok("While With Match Case Test (2)")
|
||||
|
||||
testcheck.section("While With Match Case Test (value=99)")
|
||||
logic_test.WhileWithMatchCaseTest(99)
|
||||
testcheck.ok("While With Match Case Test (99)")
|
||||
|
||||
testcheck.section("While With Match Case NoBreak Test (value=3)")
|
||||
logic_test.WhileWithMatchCaseNoBreakTest(3)
|
||||
testcheck.ok("While With Match Case NoBreak Test (3)")
|
||||
|
||||
testcheck.section("Complex For While Match Test (outer=3, inner=3)")
|
||||
logic_test.ComplexForWhileMatchTest(3, 3)
|
||||
testcheck.ok("Complex For While Match Test (3, 3)")
|
||||
|
||||
testcheck.section("For With Case And NoBreak Test (n=5)")
|
||||
logic_test.ForWithCaseAndNoBreakTest(5)
|
||||
testcheck.ok("For With Case And NoBreak Test (5)")
|
||||
|
||||
testcheck.section("While With Break Condition Test (limit=6)")
|
||||
logic_test.WhileWithBreakConditionTest(6)
|
||||
testcheck.ok("While With Break Condition Test (6)")
|
||||
|
||||
testcheck.section("Nested While With Multiple BreakPoints (depth=3, width=4)")
|
||||
logic_test.NestedWhileWithMultipleBreakPoints(3, 4)
|
||||
testcheck.ok("Nested While With Multiple BreakPoints (3, 4)")
|
||||
|
||||
testcheck.section("For With Match Case In Loop Test (iterations=9)")
|
||||
logic_test.ForWithMatchCaseInLoopTest(9)
|
||||
testcheck.ok("For With Match Case In Loop Test (9)")
|
||||
|
||||
testcheck.section("Complex Logic With Elif Chains (a=3, b=5, c=7)")
|
||||
logic_test.ComplexLogicWithElifChains(3, 5, 7)
|
||||
testcheck.ok("Complex Logic With Elif Chains (3, 5, 7)")
|
||||
|
||||
testcheck.section("For Range With Step And Condition (n=12, step=2)")
|
||||
logic_test.ForRangeWithStepAndCondition(12, 2)
|
||||
testcheck.ok("For Range With Step And Condition (12, 2)")
|
||||
|
||||
testcheck.section("Match Case With Guard Conditions (value=1)")
|
||||
logic_test.MatchCaseWithGuardConditions(1)
|
||||
testcheck.ok("Match Case With Guard Conditions (1)")
|
||||
|
||||
testcheck.section("While With Multiple Match Cases (iterations=12)")
|
||||
logic_test.WhileWithMultipleMatchCases(12)
|
||||
testcheck.ok("While With Multiple Match Cases (12)")
|
||||
|
||||
testcheck.section("For While Mix With Break And Continue (n=5)")
|
||||
logic_test.ForWhileMixWithBreakAndContinue(5)
|
||||
testcheck.ok("For While Mix With Break And Continue (5)")
|
||||
|
||||
testcheck.section("Complex Case Matching With Ranges (start=0, end=35)")
|
||||
logic_test.ComplexCaseMatchingWithRanges(0, 35)
|
||||
testcheck.ok("Complex Case Matching With Ranges (0, 35)")
|
||||
|
||||
testcheck.section("While With Elif In Elif Chain (limit=7)")
|
||||
logic_test.WhileWithElifInElifChain(7)
|
||||
testcheck.ok("While With Elif In Elif Chain (7)")
|
||||
|
||||
testcheck.section("For With Case NoBreak Nested (inner_limit=4)")
|
||||
logic_test.ForWithCaseNoBreakNested(4)
|
||||
testcheck.ok("For With Case NoBreak Nested (4)")
|
||||
|
||||
return testcheck.end()
|
||||
Reference in new issue
Block a user